Posts

Showing posts from July, 2011

Cant connect port 9150 c++ -

i trying connect port 9150 on localhost ( tor ) code: word wversionrequested = makeword(2,0); wsadata wsadata; if(wsastartup(wversionrequested,&wsadata) != 0) { return 1; } int fd = socket(af_inet, sock_stream, 0); if(fd < 0) { printf("error 0"); } struct sockaddr_in saddr; saddr.sin_port = htons(9150); saddr.sin_family = af_inet; saddr.sin_addr.s_addr = inet_addr("127.0.0.1"); connect(fd, (struct sockaddr *)&saddr, sizeof(saddr)); if(fd > 0) { printf("error 1"); } and failing "error 1". tor/vidalia runing on port , ok, erro must in code. me please. minor things here: #include <stdio.h> /* perror() */ word wversionrequested = makeword(2,0); wsadata wsadata; if(wsastartup(wversionrequested,&wsadata) != 0) { return 1; } int fd = socket(af_inet, sock_stream, 0); int rv = 0; if(fd < 0) { perror("socket"); exit(fd); /* or return */ } struct sockaddr_in saddr; saddr.

Why can't I get the Jenkins Powershell plugin to work? -

why can't jenkins "powershell plugin" work? i can run powershell script on jenkins using "execute windows batch command" build step following command: powershell -executionpolicy bypass -file script.ps1 but unable run powershell script jenkins "powershell plugin" using "windows powershell" build step , command, because of windows execution policy not set error disallowing run: script.ps1 does know proper arg give jenkins "powershell plugin" succesfully run script? otherwise, use batch script work-around. the correct thing set execution policy on machine (a one-time action), @ point won't need bypass every time, , jenkins plugin should "just work". unable to? a reasonable starting setting remotesigned, allow execute local scripts fine still disallow scripts downloaded internet. from elevated powershell prompt, run: set-executionpolicy remotesigned see also: http://technet.microsoft.com/l

scala - Converting from a lift-json AST to a json4s AST -

i'm bit amazed can't find other information on this. as understand json4s same thing lift-json, decoupled lift. cool, great. have library i'm using, class can't modify, can produce lift-json jobject. want convert json4s jobject. a straight cast doesn't work, makes sense. is there simple way this? preferably faster dumping string , reading in again right type?

ruby on rails - Rspec Test Haml Template Output in Object Presenter -

i trying figure out class/method/instantiation process should use in rspec functioning view template includes both standard actionview herlper methods , haml helper methods. i have implemented presenters in rails app done in railscast #287 i have presenter want output uses 1 of haml helpers. here base presenter: class basepresenter attr_reader :object, :template def initialize(object, template) @object = object @template = template end end here example of theoretical presentable object , it's presenter class: class fakeobject def a_number rand(10).to_s end end class fakepresenter < basepresenter def output_stuff # #content_tag standard actionview template.content_tag(:span) # #succeed haml gem template.succeed('.') object.a_number end end end end if write test in rspec , #content_tag method being used, work, it's part of actionview. however, #succeed haml gem , isn't ava

vb.net - programs' systray icon remains after program stops running in some cases -

i have (vb.net) program creates systray icon when launched. when exits systray icon removed correctly. however, in cases, example when program 'end tasked' using ms task manager program's systray icon remains. this presents unfortunate illusion program still running when not. however, in these situations, once user moves mouse on program's systray icon program's systray icon disappears. is there anyway ensure systray icon removed in cases? when application killed ("end tasked"), don't chance tidy first. app removed memory, , there's no warning (or way prevent it). it's having hole in ground appear beneath feet - don't chance call home goodbye spouse or significant other first. you're gone.) for other problems (the occasional "phantom icon" remains after app closed properly), there solution. i'm not sure how it's resolved using .net, plain old winapi programming can use postmessage send wind

java - JavaFX in jdk 1.8.0-91 get green and half GUI in 16-bit color Windows 7 x64 -

javafx in jdk 1.8.0-91 green , half gui in 16-bit color windows 7 x64 when login host windows remote desktop, color limited 16-bit , javafx functions unexpected. i write simple example websites, follows: import javafx.application.application; import javafx.fxml.fxmlloader; import javafx.scene.parent; import javafx.scene.scene; import javafx.stage.stage; public class fxmlexample extends application{ @override public void start(stage stage) throws exception { parent root = fxmlloader.load(getclass().getresource("fxmldocument.fxml")); scene scene = new scene(root, 300, 275); stage.settitle("fxml welcome"); stage.setscene(scene); stage.show(); } public static void main(string[] args) { launch(args); } } the fxml: <?xml version="1.0" encoding="utf-8"?> <?language javascript?> <?import java.net.*?> <

Cross Compile allJoyn on Ubuntu for RaspberryPI -

i trying cross-compile alljoyn on ubuntu 16.04 raspberrypi2. followed steps mentioned https://wiki.allseenalliance.org/develop/building_and_running under section linux cross-compiling. when try compile alljoyn using command scons os=openwrt cpu=openwrt bindings=cpp,c,java ws=off bt=off ice=off service="about,notification,controlpannel,config,onboarding,sample_apps" following error scons: reading sconscript files ... checking c++ compiler support -std=c++11 flag... printing env dump... { 'cpath': '/home/jha/rpi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot/usr/include', 'home': '/home/jha', 'library_path': '/home/jha/rpi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot/usr/lib:/home/jha/rpi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot/usr/libexec', 'path': '/home/jha/rpi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-g

java - Why does my content_detail.xml doesn't show the action bar? -

mainactivity.java package com.example.android.sunshine.app; import android.os.bundle; import android.support.v7.app.actionbaractivity; import android.view.menu; import android.view.menuitem; public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); if (savedinstancestate == null) { getsupportfragmentmanager().begintransaction() .add(r.id.container, new forecastfragment()) .commit(); } } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle

c# - Write text from .txt file to Rich Text Box from different text files? -

so i'm making program needs write info text box txt file read info txt file in rich text box. heres have far. private void btn_write_click(object sender, eventargs e) { if (file.exists(@"c:\windows\temp\" + txt_key.text + ".txt")) messagebox.show("file exists"); system.diagnostics.process.start(@"c:\windows\temp\" + txt_key.text + ".txt"); else { streamwriter sw = new streamwriter(@"c:\windows\temp\" + txt_key.text + ".txt", true); sw.writeline("dog: " + txt_name.text); txt_name.clear(); sw.writeline("owner: " + txt_owner.text); txt_owner.clear(); sw.writeline("age: " + nud_age.value.tostring()); nud_age.value = 0; sw.writeline("breed: " + cmb_breed.selecteditem.tostring()); if (cmb_breed.selectedindex == 0) { sw.writeline("sub specie: &quo

jquery - how to add Django media javascript on the fly to a widget in an ajaxed form? -

i can't widget media js render in ajaxed form. widget's css gets rendered. how can js render per widget? don't want have stick in base template head , have waiting on each page in case needs called. want make use of widget.media class load js, , not stick script tags in ajaxed form template somewhere. i have custom django splitdatetimewidget have modified adding twitter-bootstrap classes/js it's component input widgets so: class tbssplitdatetimewidget(widgets.multiwidget): """ widget splits datetime input 2 <input type="text"> boxes. """ def __init__(self, attrs=none, date_format=none, time_format=none): widgets = (tbsdateinput(attrs=attrs, format=date_format), tbstimeinput(attrs=attrs, format=time_format)) super(tbssplitdatetimewidget, self).__init__(widgets, attrs) the tbsdateinput looks this: class tbsdateinput(widgets.dateinput): """ renders twitter bootstrap date

bash - C: execlp() and > -

i want run execlp() c file , write result output file. use line: buff = "./cgi-bin/smth"; execlp(buff, buff, "> /cgi-bin/tmp", null); where smth compiled c script. smth prints stdout, , no file appears. happens, , how put script result output file? you have handle dup2 if using execlp . can @ how handle file out execvp in comparison. pass flag out redirection , handle it: if (structpipeline->option[0] == 1) { /* output redirection */ int length = structpipeline[i].size; char *filename = structpipeline->data[length - 1]; (int k = length - 2; k < length; k++) structpipeline->data[k] = '\0'; fd[1] = open(filename, o_wronly | o_creat, 0666); dup2(fd[1], stdout_fileno); close(fd[1]); } /* todo: input redirection */ execvp(structpipeline[i].data[0], structpipeline[i].data); see question redirecting exec output buffer or file

Project settings outside of project folder in PhpStorm -

Image
i've been using phpstorm while , although i'm still learning features, stick it. work on 4 machines (a mac, pc, macbook , office pc) , keep project in dropbox location works except server settings debugging set main machine (the mac) because config , locations different - between osx , windows. (on other machines, test google app engine) my question is: can have project settings stored in separate folder project files. have not yet found way , online not great. if could, keep project settings on each machine allow me run project full server support on each machine. sadly there no easy means change project configuration directory ( project/.idea ) location within phpstorm. i suggest instead of changing .idea location, use git repository dropbox acting server, opposed raw dropbox files. alternatively see: phpstorm - how can avoid creating .idea folder? along ticket https://youtrack.jetbrains.com/issue/wi-343 you can use .gitignore omit .idea folder (or

javascript - Is it possible to show retrieved comments as elapsed time goes by? -

assuming there media(video) player on web page. on flash, <button name="test" onclick="alert(math.floor(jwplayer().getposition())+ 'secs elapsed!');">elapsed time</button> this code shows elapsed time of video on html5, <button name="test" onclick="alert(math.floor(document.getelementbyid('video').currenttime) + 'secs elapsed!');">elapsed time</button> this code shows elapsed time of video i'm thinking of storing comments, , it's elapsed time database. then automatically loads comments of particular video when user load page. , displays each comment elapsed time goes by(my image pop-up) is possible jquery(or javascript)? if how? can show me how implement easily. if there comment this at 5 secs "hello! 5 secs has past" at 20 secs "hello! 20 secs has past" at 35 secs "hello! 35 secs has past" at 35 secs "hello! 35 secs has

ios - implicit declaration of function '_strnicmp' is invalid in C99 -

i'm new in ios now counter problem #define strncasecmp _strnicmp it has warning: implicit declaration of function '_strnicmp' invalid in c99 and has error: undefined symbols architecture armv7: "__strnicmp", referenced from: _avi_open_input_file in avilib.o ld: symbol(s) not found architecture armv7 clang: error: linker command failed exit code 1 (use -v see invocation) how solve problem? quite simply, c runtime doesn't have function _strnicmp , microsoft-specific function , not standard c function. you should remove #define , use function strncasecmp , since strncasecmp posix function , , ios posix-compliant.

java - Method is not working with reflection -

one of methods not working used both map , java reflection. not sure because of reflection or other reason working in other class didn't use reflection. the method findaccessors() should retrieve value map2 . method defined in class readedges . method called method findmethod() defined in class findmethod . whenever call method findaccessors() method findmethod() , returning empty linked list instead of returning value map2 . classes given below: class readedges : import java.io.bufferedreader; import java.io.chararrayreader; import java.io.ioexception; import java.util.arraylist; import java.util.hashmap; import java.util.linkedhashset; import java.util.linkedlist; import java.util.list; import java.util.map; import java.util.stringtokenizer; import java.util.regex.pattern; import javax.swing.joptionpane; public class readedges { static dfsclass dfs = new dfsclass(); list<string> sourcenodes=new arraylist<string>(); // source node list&l

wsh - using SET in VBscript command -

i'm trying run vbscript runs command line statement contains word set in cmd line command. vbscript recognizing reserved word , giving error: expected ')' the command i'm trying run in vbscript is: objshell.run(appcmd set config /section:isapifilters /-[name='jakartaxapi']) how can escape reserved word? microsoft vbscript compilation error: expected ')' syntax error . run method requires first argument string subtype , given space-delimited word sequence can't reckoned string . need enclose in quotation marks ( " " ). run method (windows script host) runs program in new process. syntax object.run(strcommand, [intwindowstyle], [bwaitonreturn]) arguments object wshshell object. strcommand string value indicating command line want run. must include parameters want pass executable file. intwindowstyle optional. integer value indicating appearance of program's window

scala - Akka-http and handling an empty body during POST -

suppose handling post message. the content-type may application/xml or application/json. can unmarshal xml , json documents fine. however, handle case post method called empty body (the content-type may still xml or json, document empty string). various logging , analytics purposes. right now, method fails since empty body cannot processed either 1 of unmarshallers. how write unmarshaller case? or can unmarshaller handle null body? somewhere in code have following. need more marshallers? implicit def myunmarshaller(implicit mat: materializer): fromentityunmarshaller[myclass] = unmarshaller.firstof[httpentity, myclass]( /* mynullbodymarshaller, */ // need this? myjsonunmarshaller, myxmlunmarshaller ) or can modify existing one? example, one? def myjsonunmarshaller(implicit mat: materializer): fromentityunmarshaller[myclass] = unmarshaller.bytestringunmarshaller.forcontenttypes(mediatypes.`application/json`).mapwithcharset { (data, chars

python - Pandas dataframe vectorized sampling -

i have simple df forming pivot_table: d = {'one' : ['a', 'b', 'b', 'c', 'c', 'c'], 'two' : [6., 5., 4., 3., 2., 1.], 'three' : [6., 5., 4., 3., 2., 1.], 'four' : [6., 5., 4., 3., 2., 1.]} df = pd.dataframe(d) pivot = pd.pivot_table(df,index=['one','two']) i randomly sample 1 row each different element column 'one' of resulting pivot object. (in example, 'a' sampled while there more options 'b' , 'c'.) began using 0.18.0 version of pandas , aware of .sample method. messed .groupby method applying sampling function this: grouped = pivot.groupby('one').apply(lambda x: x.sample(n=1, replace=false)) i raise keyerror when tried variations on theme thought time fresh perspective on seemingly simple question... thanks assistance! the keyerror raised since 'one' not column in pivot name of index: in [11]:

python - Read first row in loop using sqlite's fetchone() -

i using loop contents of fetchone(), every time code reads fetchone() cursor moves next row. understand need careful. using example found here https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursor-fetchone.html works when have more 1 row when there single row error k, v in cur.fetchone().items(): attributeerror: 'nonetype' object has no attribute 'items' the 2 relevant functions def dict_factory(cursor, row): d = {} idx, col in enumerate(cursor.description): d[col[0]] = row[idx] return d def open_sql(sql_folder, sql_name, sql_table): # databases located @ /work/jmjohnso1/db_project path_name = os.path.join(sql_folder,sql_name).strip() con = lite.connect(path_name) con.row_factory = dict_factory cur = con.cursor() cur.execute('select * ' + sql_table) dict_contents = defaultdict(list) row in cur: k, v in cur.fetchone().items(): dict_contents[k].a

angularjs - Problems installing angular 2 packages using npm in VS2015 Update 2 -

i attempting use latest angular2 quickstart files new empty asp.net core 1.0 web application. vs2015 update 2 - w/ core 1.0 rc2 installed steps reproduce: create new project using asp.net core web application (.net core) - empty template add 4 angular quick-start files root directory, not hitting save on package.json until other 3 added , saved. finally, hit save on package.json , npm start installing of packages. however, @ end see dependencies - not installed, npm - not installed. can't figure out causing this. has vs2015 / npm bug because if use vscode , npm command line installs package.json file. this bug in web tools asp.net core rc2, discovered after rc2 shipped. it's "- not installed" ui showing incorrectly. packages installed. i'm not sure causing yet, aware of issue , try fix in future release of web tools.

osx - "rpm -qa" not working ("Segmentation fault: 11") -

problem rpm -qa not working $ rpm -qa * segmentation fault: 11 state mac os x 10.10.5 rpm version $ sudo port search rpm rpm @4.4.9_18 (sysutils, archivers) rpm package management system. rpm2html @1.9.6_1 (sysutils) translates rpm database , dependency information html rpm52 @5.2.1_9 (sysutils, archivers) obsolete port, replaced rpm54 rpm53 @5.3.11_4 (sysutils, archivers) obsolete port, replaced rpm54 rpm54 @5.4.15_1 (sysutils, archivers) rpm package management system. yum @3.2.29_1 (sysutils, archivers) automatic updater , package installer/remover rpm found 6 ports. either there bug in rpm (not likely) or missing dependency. try run: ldd /usr/bin/rpm and show libraries using. if there missing on right side of => , problem.

ruby on rails - how to stop dockerized nginx in foreground from flooding logs? -

i'm running nginx , unicorn in docker container managed supervisord. so, supervisord docker command. in turn spawns nginx , unicorn. unicorn talks nginx on socket. nginx listens on port 80. i have logspout docker container running, piping docker logs papertrail listening docker.sock. the problem nginx spewing thousands of mundane entries logs: 172.31.45.231 - - [25/may/2016:05:53:33 +0000] "get / http/1.0" 200 12961 0.0090 i'm trying disable it. so far i've: set access_logs /dev/null; in nginx.conf , vhost files. tried tell supervisord stop logging requests [program:nginx] command=bash -c "/usr/sbin/nginx -c /etc/nginx/nginx.conf" stdout_logfile=/dev/null stderr_logfile=/dev/null tried tell supervisord send logs syslog not stdout: [program:nginx] command=bash -c "/usr/sbin/nginx -c /etc/nginx/nginx.conf" stdout_logfile=syslog stderr_logfile=syslog set log level in unicorn warn in rails code, , via env var. full su

forms - Radiobutton in instances of Django ModelChoiceField -

i trying manually render modelchoicefield instances in template. working ok, not able add radio button in last cell. how do add radio button ? forms.py: class submissionform(forms.form): name = forms.charfield(max_length=100) spl_candidates = forms.modelchoicefield(queryset=candidate.objects.filter(category="spl"), widget=forms.radioselect, empty_label=none) template <table> {% data in form.spl_candidates.field.queryset %} <tr> <td> {{ data.name }} </td> <td> {{ data.description }} </td> <td> </td> </tr> {% endfor %} </table> add custom html radio button achieve this, in template this, <table> {% data in form.spl_candidates.field.queryset %}

c# - Design approach for class objects with many common and some unique methods -

in example below, have 2 instances of terrier class, derives dog . 1 instance referenced variable of type terrier . using variable, have access members of terrier class. on other hand, variable type dog can reference members of dog class, though reference points instance of terrier . terrier bubba = new terrier("bubba", 2, "happy"); bubba.growl(); // can call terrier.growl dog jack = new terrier("jack", 17, "surly"); jack.growl(); // error: can't call growl method i need implement class mypets has list<pets> can hold either of cat object or dog object. both these object have common methods makenoise() unique methods not in base class cat has method climbtree() . mypets class have method iterate through list<animals> , calls makenoise() method , climbtree() method. what should best approach achieve this, using abstract base class or other method? with regards comment, along these lines sh

html - SVG text element breaking out of parent width -

Image
so set width of svg element 100% , width of last text element have in there exceeds width of svg element parent. i've tried using word-wrap , setting max-width text element no avail. basically, want text element not break out of parent svg element it's doing, , words wrap when reach edge of parent element's width. also, don't want move text element on left, have it's @ purposefully. <svg height="1000" width="100%"> <circle cx="50%" cy="50" r=40 stroke="black" stroke-width="2" fill="white"/> <text x="49.8%" y="50" font-family="sans-serif" font-size="20px" text-anchor="middle" fill="black" dy=".38em">1939</text> <line x1="50%" y1="90" x2="50%" y2="950" style="stroke:black;stroke-width:2"/> <text id="f

multithreading - How to apply threading in vb.net with passing an object of a custom class for a method -

i newbie here. need help. trying develop tool want implement multi-threading in vb.net. stuck in place not resolve. let me explain you. i have created custom class below: public class testclass 'few private members of class private string,b string public structure abc dim xx object dim yy object dim zz object end structure public aa(10) abc 'now needed override constructor initialization of 'instance of class can made in 2 different ways due 'requirement public sub new(byval xy string,byref yz object) 'some internal method initialize object me.a=xy me.b=xy end sub 'another way create instance public sub new(byval xy string,byval yz string) 'some internal method initialize object me.a=xy me.b=yz end sub 'now public method want call using threading public sub testsub() 'do me.a,me.b , aa(some index) end sub end class now in diff

r - How to specify the path in normalizePath, or get around this error associated with it? -

i'm learning r , have installed on office computer. don't have administrator right on computer (as have call installation). then install package. @ first doesn't work when typing, example: install.packages("thepackage") the error message this: error in normalizepath(path.expand(path), winslash, mustwork) : path[1]="\\company\5050\users\myusername\documents\r\win-library\3.3": access denied in addition: warning message: in normalizepath(path.expand(path), winslash, mustwork) : path[1]="\\company/5050/users/myusername/documents/r/win-library/3.3": access denied i homework , find potential solution "map network drive network folder". i'm not sure means, try this: install.packages("thepackage",lib="h:/documents/r/win-library/3.3") because looks have more "control" of h drive (it has username on it). , works: package ‘thepackage’ unpacked , md5 sums checked downloaded binary packag

json - Highcharts showing points instead of lines -

Image
*desired output** actual output the points don't become line. question how modify code achieve desired output? this code: function create() { var series = []; $.ajax({ type: "post", url: url, async: false, success: function (result) { var channels = object.keys(result.result.data); var size = channels.length; var name = result.result.labels[1]; (var = 0; < size; i++) { var data = result.result.data[i][1]; var time = result.result.data[i][0]; var test = []; test.push({ x:time, y:data }); series.push({ "name": name, "data": test }); } } }, false); return series; } here data returned url { "api": 1, "

ionic framework - Error: Please install Android target: "android-23" -

i trying build ionic mobile app command ionic build android , getting error.. error: please install android target: "android-23". hint: open sdk manager running: /home/al/downloads/android-sdk-linux/tools/android require: 1. "sdk platform" android-23 2. "android sdk platform-tools (latest) 3. "android sdk build-tools" (latest) i meet requirements in android sdk manager. put android_home path in ~/.bashrc file export android_home=/home/al/downloads/android-sdk-linux/ export path=${path}:$android_home/tools:$android_home/platform-tools i follow steps in this post , still getting same error. know missing? thanks this error saying have not downloaded android api 23 - marshmallow, , going target same api level in application. that's why application not going build. have 2 options solve error: change target version whatever have latest android api. (i.e. if have downloaded android api 22, target 22). other way is, go sdk manag

java - How to preserve LinkedHashMap ordering in JSONObject? -

i have linkedhashmap states. map<string, string> statemap = new linkedhashmap<string, string>(); // ... i'm creating jsonobject based on it. jsonobject json = new jsonobject(); json.putall(statemap); however, entries appear unordered. i'd preserve ordering of linkedhashmap in jsonobject . how can achieve this? unlike jsonobject , jsonarray ordered sequence of values. if want preserve order of map, can construct json object 2 keys: the first key can called data , hold statemap data : json.element('data', statemap) the second key can called keys , jsonarray object hold ordered list of map keys : jsonarray array = new jsonarray(); array.addall(statemap.keyset()) json.put('keys', array) for more information : jsonarray documentation jsonobject documentation

Open a hyperlink URI (www.google.com) in a web browser( IE or chrome) through code in C# WPF forms -

im working on project has hyperlinks in it. used datagridhyperlinkcolumn populate uri's in single column. whenever click on uri, gets opened in both browser , wpf window. prevent uri opening in web browser using hyperlink.requestnavigate(). but need uri opened in web browser , not in wpf window. have attached xaml , c# code below. <datagrid name="dgusers" autogeneratecolumns="false" canuseraddrows="false" borderthickness="0" canuserresizerows="false" gridlinesvisibility="none" headersvisibility="none" focusable="false" visibility="{binding dgvisibility}"> <datagrid.resources> <style targettype="hyperlink"> <eventsetter event="click" handler="dg_hyperlink_click"/> </style> </datagrid.resources> <datagrid.columns>