Posts

Showing posts from May, 2015

parse.com - Parse "key cannot be nil" error on [PFObject saveInBackground] (Cocoa) -

i'm trying out parse sdk in existing mac os x application. followed setup steps in parse quickstart guide, including adding import parse library appdelegate .m file , calling: [parse setapplicationid:kparseapplicationid clientkey:kparseclientkey]; in applicationdidfinishlaunching method. 2 constants use defined in constants file imported. towards end guide says: "then copy , paste code app, example in viewdidload method (or inside method gets called when run app)" so imported parse header file main view controller .m file , copied , pasted code viewdidload method: pfobject *testobject = [pfobject objectwithclassname:@"testobject"]; testobject[@"foo"] = @"bar"; [testobject saveinbackground]; when runs, hit exception message "setobjectforkey: key cannot nil" on last line. not on previous line i'm setting object key. furthermore, if stop on previous line , po testobject, testobject.allkeys, or testobject[@"foo...

java - how to identify a button in a group of loop generated buttons? -

i have group of loop generated buttons made code this.panelcuerpo.setlayout(new gridlayout(4,5)); for(int = 1; i<=20; i++){ final jtogglebutton b = new jtogglebutton(new imageicon("/images/available.png")); panelcuerpo.add(b); b.seticon(new javax.swing.imageicon(getclass().getresource("/images/available1.png"))); b.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent evt){ if(b.isselected()){ b.seticon(new javax.swing.imageicon(getclass().getresource("/images/busy1.png"))); cantidadboletas++; }else{ b.seticon(new javax.swing.imageicon(getclass().getresource("/images/available1.png"))); cantidadboletas--; } system.out.println(cantidadboletas); ...

Php Variable not working in UPLOAD script -

i have following script: <?php $userid = $_get['user']; // list of permitted file extensions $allowed = array('png', 'jpg', 'gif','zip'); if(isset($_files['upl']) && $_files['upl']['error'] == 0){ $extension = pathinfo($_files['upl']['name'], pathinfo_extension); if(!in_array(strtolower($extension), $allowed)){ echo '{"status":"error"}'; exit; } if(move_uploaded_file($_files['upl']['tmp_name'], '../../'.$userid.'/assets/'.$_files['upl']['name'])){ echo '{"status":"success"}'; echo ' '.$userid; exit; } } echo '{"status":"error"}'; echo ' '.$userid; exit; ?> the problem in line: if(move_uploaded_file($_files['upl']['tmp_name'], '../../'.$useri...

c++ - Linking External Libraries in Android Studio (gradle) -

i using android studio. added header files in jni folder , added libraries in jnilibs folder , added path in build.gradle file. sourcesets.main { jni.srcdir 'src/main/jni' jnilibs.srcdir 'src/main/jnilibs' } but getting undefined reference error . searched on net , solutions block automatic ndk-build call , edit android.mk file , running ndk-build call terminal. want link external libraries in build.gradle file. secondly getting undefined reference 'std::ios_base::init::init()' error. linked library ldlibs "stdc++" but still getting error. using cross compiled libraries , header files , think need link libraries provided cross compiler. did ldlibs "/home/xx/xx/xx/xx/arm-linux-androideabi/lib/stdc++" but still getting error. solution it? to declare stl in build.gradle , use: stl "gnustl_static" ldlibs reserved other libs. extract build.gradle : defaultconfig { ndk { module...

io - java.nio.charset.MalformedInputException: Input length = 1 -

i have (stripped html tags code example) function builds html table out of csv, runtime error everytime try run , don't know why. google says maybe encoding wrong have no idea how change that. my csv encoded in ansi , contains characters ä, Ä, Ü, Ö have no control on encoding or if change in future. the error occurs here: caused by: java.io.uncheckedioexception: java.nio.charset.malformedinputexception: input length = 1 @ java.io.bufferedreader$1.hasnext(unknown source) @ java.util.iterator.foreachremaining(unknown source) @ java.util.spliterators$iteratorspliterator.foreachremaining(unknown source) @ java.util.stream.referencepipeline$head.foreach(unknown source) @ testgui.csv2html.start(csv2html.java:121) line 121 is lines.foreach(line -> { sourcecode: protected void start() throws exception { path path = paths.get(inputfile); fileoutputstream fos = new fileoutputstream(outputfile, true); printstream ps = new printstream(fos); boolean...

SQL Null statement not working MS Access -

so i'm not sure going on here in database have table has 1000 records , 36 of them have [workername] empty. trying run sql select unassigned, empty [workername] records assign nothing populates when put code in query design , view mode. genuinely have no idea why not working. strsql = "select intakeid, caseid, [program], [language] intake workername null" set rs = db.openrecordset(strsql, dbopendynaset) try code..here first replace null value '' using nz , if not null trim value make sure there no space , check equal '' means empty..hope help "select intakeid, caseid, [program], [language] intake ltrim(rtrim(nz(workername, ''))) = ''"

Python Pandas matching closet index from another Dataframe -

df.index = 10,100,1000 df2.index = 1,2,11,50,101,500,1001 sample i need match closet index df2 compare df these conditions df2.index have > df.index only 1 closet value for example output df | df2 10 | 11 100 | 101 1000 | 1001 now can for-loop , it's extremely slow and used new_df2 keep index instead of df2 new_df2 = pd.dataframe(columns = ["value"]) col in df.index: col2 in df2.index: if(col2 > col): new_df2.loc[col2] = df2.loc[col2] break else: df2 = df2[1:] #delete first row index speed how avoid for-loop in case thank. not sure how robust is, can sort df2 it's index decreasing, , use asof find recent index label matching each key in df 's index: df2.sort_index(ascending=false, inplace=true) df['closest_df2'] = df.index.map(lambda x: df2.index.asof(x)) df out[19]: closest_df2 10 1 11 100 2 101 1000 3 ...

R cumulative sum based upon other columns -

i have data.frame below. data sorted column txt , column val. summ column sum of value in val colummn , summ column value earlier row provided current row , earlier row have same value in txt column...how in r? txt=c(rep("a",4),rep("b",5),rep("c",3)) val=c(1,2,3,4,1,2,3,4,5,1,2,3) summ=c(1,3,6,10,1,3,6,10,15,1,3,6) dd=data.frame(txt,val,summ) > dd txt val summ 1 1 1 2 2 3 3 3 6 4 4 10 5 b 1 1 6 b 2 3 7 b 3 6 8 b 4 10 9 b 5 15 10 c 1 1 11 c 2 3 12 c 3 6 if "most earlier" (which in english more written "earliest") mean nearest , implied expected output, you're talking cumulative sum. can apply cumsum() separately each group of txt ave() : dd <- data.frame(txt=c(rep("a",4),rep("b",5),rep("c",3)), val=c(1,2,3,4,1,2,3,4,5,1,2,3) ); dd$summ <- ave(dd$val,dd$txt,fun=cumsum); dd; ## txt va...

filtering - How do I apply a digital filter in MATLAB? -

i have following time series: jan feb mar apr may jun jul aug sep oct nov dec 1948 24.786 24.767 25.117 25.514 26.565 27.374 27.778 28.022 27.827 27.308 26.545 25.620 1949 25.191 24.962 25.038 25.591 26.325 27.044 27.719 28.059 28.077 27.541 26.501 25.568 1950 24.713 24.461 24.682 25.122 26.157 26.965 27.688 28.072 28.089 27.429 26.318 25.194 1951 24.423 24.114 24.335 25.153 26.399 27.474 28.143 28.547 28.441 27.854 26.904 25.842 1952 25.025 24.812 25.317 25.734 26.660 27.615 28.069 28.468 28.384 27.738 26.640 25.402 1953 24.619 24.614 25.048 25.917 26.870 27.485 28.021 28.363 28.311 27.687 26.768 25.829 1954 25.176 24.804 25.089 25.768 26.579 27.222 27.684 28.053 27.971 27.164 26.141 25.162 1955 24.553 24.340 24.679 25.266 26.182 26.959 27.649 28.108 28.053 27.453 26.594 25.483 1956 24.492 24.361 24.791 25.446 26.295 26.867 27.505 27.946 27.889 27.420 26.347 25.504 1957 24.928 24.811 25.110 25.690 26.677 27.566 28.221 28.486 28.459 27.793 26...

Getting R6034 error when starting Eclipse for Java EE Developers -

Image
i use windows 7 64-bit, java 8. i'm getting following error: and following screen left behind after process manually terminated: i believe started happening right after installed plugin jboss tools - xulrunner.site - ­ update site supposed 64-bit support wildfly 8 . when tried configure new project glassfish 4 got same error. if default workspace not configured any app server, not error. i tried starting eclipse - clean parameter did not @ all. what reasonable troubleshooting path here? update 1 i able uninstall xulrunner stuff eclipse didn't rid of r6034 . update 2 below last section .metadata.log . not sure if it's related original problem: !entry org.eclipse.osgi 2 0 2015-06-02 19:15:14.137 !message while loading class "org.eclipse.jdt.ui.preferenceconstants", thread "thread[main,6,main]" timed out waiting (5000ms) thread "thread[worker-1,5,main]" finish starting bundle "org.eclipse.jdt.ui_3.10.0.v...

parameters - RoboCopy - Files starting with a dash result in error -

we in process of migrating files 1 share another. have built tool in user can select directories and/or individual files copied destination share. tool generates individual robocopy command each of files or directories in collection results selection made user. we having problems if individual file copied starts dash, instance: robocopy c:\temp c:\temp2 -a.txt robocopy bails out with: error : invalid parameter #3 : "-a.txt" tried usual suspects (quotes around filename etc.), far nothing seems work. idea how around this, without resorting renaming file prior copying? this appears bug in robocopy; has other known similar ones: https://support.microsoft.com/en-us/kb/2646454 here's possible workaround: robocopy c:\temp c:\temp2 *-a.txt /xf *?-a.txt *-a.txt still match "-a.txt", matches "x-a.txt", "xx-a.txt", etc. the /xf file exclusion knocks out "x-a.txt", "xx-a.txt", , other file characters (sp...

Bash string variable won't pass value -

if last pipe removed, seems value pass , things work until connection no longer active. value goes empty or null double quote still there. sed command can strip pipe won't let value afterwards passed. i'm stuck. iwgetid wlan0 | grep 'essid:' | cut -c 18-24 | wtf=$(echo "$1" [[ -z "$1" ]] && echo -e "wi-fi not connected!" || echo -e "connected" anything on right-hand side of pipeline run in subshell, meaning assignments done there aren't visible anywhere else in shell. also, $1 unclear here -- values wtf aren't getting positional arguments you're doing. fixing that: wtf=$(iwgetid wlan0 | grep 'essid:' | cut -c 18-24 | sed -e 's/^"//' -e 's/"$//') [[ -z "$wtf" ]] && echo -e "wi-fi not connected!" || echo -e "connected" [[ ! -z "$wtf" ]] && echo -e "connected" || echo -e "wi-fi not conne...

polymorphism - Scheme define-macro and/or define-syntax -

i want create overloaded scheme macro simple form of polymorphism. is, macro smart enough expand differently when given params of different types, (look-up key container) "right" thing different kinds of containers. (define-macro (look-up key container) (cond ((table? container) `(table-ref ,key ,container)) ((pair? container) `(assoc ,container ,key)) etc. (else `(error "unknown type look-up)))) ideas? i think chris right in not job macros. simple procedure might you're looking for: (define (lookup key container) (cond ((type1? container) (type1-lookup key container)) . ; repeat whichever types.. . ((typen? container) (typen-lookup key container)) (else 'undefined-lookup))) ; or default value or ... or maybe need find out you're dealing once can build build more dedicated procedure on fly. make-lookup procedure might ...

redirect - Ispconfig nginx redirecting to https -

i've deployed centos server ispconfig , nginx. also able configure nginx, manually (by editing /etc/nginx/sites-available/mysite.com.vhost), redirect http requests https: server { listen 80; server_name mysite.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; .. } as edited file manually, every time change setting ispconfig, vhost file gets overwritten , lose redirection's trick. do know way config redirection above using ispconfig panel instead editing nginx file manually ? thanks in avance. on more recent versions of ispconfig, can select website use ssl (and means https, , optionally, spdy or http/2), additional checkbox redirect http requests permanently https, , ispconfig automatically generate vhosts files correctly. for sake of completude, ispconfig adds: server { listen *:80; listen *:443 ssl; ssl_protocols tlsv1 tlsv1.1 tlsv1.2; ssl_certificate /...

javascript - changing the color ov two div's -

i working script mouseover menu item , change background color , change color of div @ timing of 2000. can help? in advance. $(document).ready(function() { $(".block-menu").mouseover(function() { $(this).css({'background-color' : '#97d8e6'}).mouseout(function(){ $(this).css({'background-color' : '#43bdcb'}); }); $(".sections1").css({'background-color' : '#97d8e6'}).mouseout(function(){ $(this).css({'background-color' : '#43bdcb'}); }); }); }); to (2000ms) .animate() background of element you'll either need jquery ui or dynamically toggle classes (using jquery) uses css3 transition - in order apply fancy fade background transition: $(document).ready(function() { $(".block-menu").hover(function() { $(this).toggleclass("jqhover"); // $(".sections1").toggleclass(...

javascript - css html bootsrap layout issue -

i trying build page 2 full height columns. left column menu. right section hold form. trying make responsive page using bootstrap. have written following code, when resize window, form content overflows left menu. tried using bootstrap grid, ended using own css. still won't work. i created jsfiddle here: https://jsfiddle.net/snehilw/8zrkcyyx/ my current layout looks this: <div class="containerr"> <div class="roww"> <!-- left navigation menu --> <div class="coll-md-2 no-float"> <div class="nav-side-menu"> <div class="brand"> &nbsp</div> <i class="fa fa-bars fa-2x toggle-btn" data-toggle="collapse" data-target="#menu-content"></i> <div class="menu-list"> <ul id="menu-content" class="menu-content collapse out"> ...

sql server - Clarification on SQL PIVOT -

can tell me missing in second pivot example. returns null http://sqlfiddle.com/#!3/2b405/2 this literal answer: there no car, truck or bicycle in vehicle_parameters table. nothing missing in statement, result of null correct. here other samples of pivot may want up: https://technet.microsoft.com/en-us/library/ms177410%28v=sql.105%29.aspx think explain dealing nulls well.

How to display two dynamic names within one url using laravel -

the following code: {{url('/'.$subjecttype->name)}} is name 'garden' wrapped in url. gives me localhost/garden garden dynamic name. routes setup so: route::get('/{subject}/', array( 'as' => 'subject', 'uses' => 'subjectcontroller@getsubject')); the question how setup 2 dynamic names within 1 route? example localhost/garden/12 so want route this route::get('/{subject}/{id}/', array( 'as' => 'subjectid', 'uses' => 'subjectcontroller@getsubjectid')); but more importantly in view? have of garden header wrapped in url looks this: 'gardening tips beginners' {{$subjecttype->title}} below poor attempt @ want hope picture. {{url('/$subjecttype->name/$subjecttype->id/'.$subjecttype->title)}} thanks for route: route::get( '/{subject}/{id}/', array( 'as' => 'subjectid', ...

c - How to allocate the 2d array of pointers using arguments of main function -

write c program take 2 integers arguments. program should allocate 2d array of characters dynamically, read data, print them, , free array. array dimensions of array taken main arguments. problem in code run , input correct output isn't correct run time error output int main (int y,char *x[]){ int i,j,v,b; v=atoi(x[1]); b=atoi(x[2]); char*m[v]; for(i=0;i<v;i++) m[i]=(char*)malloc(b*sizeof(char)); for(i=0;i<v;i++) for(j=0;j<b;j++) scanf("%s",&m[i][j]); for(i=0;i<v;i++){ for(j=0;j<b;j++) printf("%s",m[i][j]); } return 0; } #include <stdio.h> #include <stdlib.h> #include <string.h> int main (int y,char *x[]){ int i,j,v,b; v=atoi(x[1]); b=atoi(x[2]); char *m[v][b];//allocate 2d array of pointers on stack for(i=0;i<v;i++){ for(j=0;j<b;j++){ char buff[128]; scanf(...

logging - PHP: Log into an "global array" -

i've got question. i'm running little php-cli-script calls functions helper-class. like this: test.php $testhelper = new testhelper(); $test = $testhelper->method1(); if($test) $testhelper->method2(); helper.php class testhelper { public static function method1() { ... addlogfunction("this test-log-entry"); } public static function method2() { ... addlogfunction("this test-log-entry"); } ... } both methods defined in helper.php. now write information, generated running both methods, "global log". log should contain information both called methods. in case "global log" should contain "this test-log-entry" , "this test-log-entry" after running both methods successively. how solve that? add log messages array, , hope there way output later. because if script crashes, array lost, , log won't useful debugging. command line scripts write stderr errors, usable...

python - How to turn CSV file into list of rows? -

i have csv file saved windows comma separated values f = open('file.csv') csv_f = csv.reader(f) row in lines: print row returns company,city,state ciena corporation,linthicum,maryland inspirage llc,gilbert,arizona facebook,menlo park,ca i trying make list column column f = open('file.csv') csv_f = csv.reader(f) row in f: print row[2] f.close() and receiving 3rd letter: m , e , s , c . writing in python on mac as proper way dealing csv files can use csv module : >>> import csv >>> open('f_name.csv', 'rb') csvfile: ... spamreader = csv.reader(csvfile, delimiter=',') ... row in spamreader: ... print baseurl + ' '.join(row) this give rows list. , if want of them in list : >>> import csv >>> open('f_name.csv', 'rb') csvfile: ... spamreader = csv.reader(csvfile, delimiter=',') ... print list(spamreader) note spa...

sql - Oracle Random Number Generator Stored Procedure without using DBMS_RANDOM -

i don't have access dbms_random package, create own stored procedure generate random numbers in oracle. know how might that? thanks in advance! edit: trying generate random row each state. code: select z.* ( select a.*, row_number() on (partition a.state order ( select to_char(systimestamp,'ff') dual)) row_id state_table ) z z.row_id=1; it gives me same rows everytime run it, want give me different rows everytime run it. please? if want select random rows table can use sample clause select * mytable sample(4); this gives randomly selected 4% of rows.

Font rendering fine on Mac, messed up on Windows -

Image
i ran problem font rendering on windows. i'm used little difference in rendering between mac , windows, made mouth fall open. tested site thoroughly on mac , i'm positive looks fine in chrome, firefox , safari. it looks on mac browsers: on windows, looks messed in browser (i tested chrome, firefox , ie): i know mac has iowan old style installed default, tried forcing mac browsers use webfont generated using fontsquirrel, doesn't reproduce problem on mac. both browsers seem load same font (namely woff version) correctly. have idea be? i can't post link website because don't have enough reputation, please @ screenshots url.. thanks guys! after more research found out original (ttf) font worked fine on windows, had fontsquirrel caused problems. tried out 8 different types of settings on fontsquirrel , kept having same issues. after while decided try different generator , came across fontie: https://fontie.flowyapps.com/home this solved ...

Visual studio C# oracle database -

Image
i have problem 1 possible solution. have created school oracle database on school's vpn. in sql oracle developer have configuration: i found different solutions connecting oracle visual studio, not of them run. of errors thrown tns listener. don't know, if correct, on view connect type basic. all tutorials found, using tns. tns possible problem? sorry, maybe bad question), possible configure visual studio connecting oracle database configuration? i not use connection string now, because want connect database server explorer. here view available data sources , providers. and in tnsnames.ora have this: (test = (description = (address = (protocol = tcp)(host = fei-sql1.upceucebny.cz)(port = 1521)) (connect_data = (server = dedicated) (service_name = ee11) ) ) thanks , time.

asp.net mvc - Why can't I allow '*' characters in webapi routes safely? (or, if it can, how?) -

i'm wanting use webapi 2 inside mvc5 project (angularjs, not should make difference) create following types of routes api/animals/cats => return cats api/animals/dogs => return dogs api/animals/* => return animals (e.g. cats+dogs) background: did started following; from visual studio 2013, new empty mvc application in controller folder, right click add new controller, select webapi 2 controller (apologies if looks information, here in case different project types result in different illegal character checking. ) i want able have users pass in '*' character indicate wildcard, indicating all animals. allow this, using webapi, registered following test route; config.routes.maphttproute( name: routenames.animals, routetemplate: "api/animals/{animal}", defaults: new { id = routeparameter.optional, controller = "animalsapi" } ); when test this...

c++ - Best way to handle multiple sockets in Qt server application? -

i'm making simple client server program school project in qt, i've run problems on how handle multiple new connections server. code have new connections far pretty basic: void loginserver::newconnection() { logsock = server->nextpendingconnection(); if(!logsock->waitforconnected(500)) { qdebug() << "connection failed"; }else { qdebug() << "it worked!"; connect(logsock, signal(readyread()),this, slot(readdata())); } } one method saw on internet pushing new connections data structure such vector, , handling them 1 container. 1 issue have if connect different sockets same slot reading data, there elegant way tell socket sent signal? another way considered doing when readyread() emitted, search through list of sockets see had bytesavailable, seems overly simplistic solution me. plus, if 2 sockets sent data @ same time program might identify wrong socket. another option considered overriding re...

java - What I have to put as the uri of my HttpGet method? -

i'm doing api rest application in android , i'm trying get , post , put , delete methods application in android. i saw objective have use httpget(string uri) method i'm not secure uri have put. saw info here: http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/httpget.html#httpget(java.net.uri) have put uri of folder in api.php file it's allocate? api.php it's file in have get, put, post , delete method. have put uri set on methods (get/post/put/delete) make reference information retrieve me? i searched on internet couldn't find helps me. thanks in advance! the uri in case url (often used interchangeably uri) of rest webservice endpoint (e.g. http://someserver/restservice/users ). the constructor httpget(string uri) accepts string parameter, can stick url in there surrounded double quotes: httpget httpget = new httpget("http://someserver/restservice/users");

android - Files do not download completely or get corrupted -

i have android app downloads files tomcat7 running on redhat linux server needed. server under control , authorized users can download. files database information , can quite large, as 4.8mb. however, tiny files fail download fully. these files have downloaded fine in past, started fail download completely. don't know if problem on server or client side yet. server bandwidth usage ~10%. i looking guidance on how determine if it's server problem, or problem in android app. have searched hours trying find may related without success. i don't know if it's related, securecopy (scp) stalls frequency on server.

html - How can I make transition property work in IE by using calc properties? -

element1 { height: calc(100% - 50px); -webkit-transition: .5s; -moz-transition: .5s; -ms-transition: .5s; -o-transition: .5s; transition: .5s; } element1:hover { height: calc(100% - 200px); } when replace calc in height property px or % , transition works fine, calc , goes 1 height without transition. in other browsers works fine, problem in ie adding code , jsfiddle example similar real situation. div{ position: fixed; right: 0; width: 250px; height: calc(100% - 200px); background: #1c8080; top: 158px; color: #fff; text-align: center; padding-top: 40px; font-size: 18px; border: 1px solid #000; -webkit-transition: .3s; -moz-transition: .3s; transition: .3s; } div:hover{ height: calc(100% - 100px); top: 58px; } .bottom{ position: absolute; bottom: 15px; width: 100%; font-size: 26px; } <div> <p>height's ...

python - IN condition in Where clause on Peewee -

i accomplish sql 'in' condition clause in python's peewee orm. order.select().where(order.statusid in statuses) is possible? i using postgres in case there compatibility issues proposed solution. looking @ documentation found out there specific query operations in lookup: .in_(value) so guess how work: order.select().where(order.statusid.in_(statuses))

download - php sendfile appends filesize to file -

i have code serve requested files in php. it's testing code, input not validated. (by way, how correctly sanitize kind of input...) $upload_dir = "/media/usb/dir"; $filename = $_get['filename']; $mimetype = $_get['mime']; $path = $upload_dir . $filename; header('content-description: file transfer'); header("content-type: ".$mimetype ); header('content-disposition: attachment; filename="'.$filename.'"'); header('expires: 0'); header('cache-control: must-revalidate'); header('pragma: public'); header('content-length: ' . filesize($path)); header("x-sendfile: \"$path\""); echo readfile($path); but size of file in bytes appended each file. example simple txt this: myfile will become this: myfile6 how rid of behaviour? i'm getting textfile this: download.php?mime=text/plain&filename=my-file.txt readfile() returns size of file. ...

visual studio 2012 - How to set a socket option in C++ using setsockopt -

still, having troubles code. if (argc > 0) { int route (argc);//[argc+1] ((char*) route)[0] = 1; ((char*) route)[1] = 2;//131 ((char*) route)[2] = 3 + argc * 4; ((char*) route)[3] = 4; (int = 0; < argc; i++) { route = inet_addr(argv[i]); } if (setsockopt(_socket.native_handle(), ipproto_ip, ip_options, route, (argc + 1) * 4) < 0) { perror("can't set socket option"); } } here's part of it, keep getting error c2664: cannot convert parameter 4 'int' 'const char *' microsoft's implementation of setsockopt() has const char* fourth option. posix usually has const void* . has pointing buffer contains values. last argument size in bytes of buffer. so this: setsockopt( _socket.native_handle(), ipproto_ip, ip_options, reinterpret_cast<char*>(&route), sizeof(int)); i don't know enough sockets tell whether you're passing makes sense. here's documentation on msdn ip_options.

encapsulation, accessor C# vs Java -

a quick question encapsulation , accessor in c# vs java . code in c# equivalent 1 in java below? c# : class myclass{ public string var1 {get; private set;} public int var2 {get; private set;} public myclass(string astring, int anint){ this.var1= astring; this.var2=anint; } } java //java class myclass{ private string var1; private int var2; public myclass(string astring, int anint){ this.var1= astring; this.var2=anint; } public string getvar1(){ return this.var1; } public void setvar1(int anint){ this.var1 = anint; } public int getvar2(){ return this.var2; } public void setvar2(string astring){ this.var2 = astring; } } i'm coming java world, not sure accessor shortening in c# . no, in c# code you've got private setters - in java code they're public. the c# equivalent java code be: public string var1 { get; s...

excel - Type Mismatch error -

i have below code giving me run time error 13, type mismatch on line "if ws1.cells(i,13)="yes" then" column (column m) contains either blank cells, or "yes". i've tried redefining "i" string, , didn't change anything. goal every row "yes" in column m, entire row copied on second sheet named "output". error appreciated, open other ideas may suit goal. thanks! sub sadface() dim ws1 worksheet: set ws1 = thisworkbook.sheets("trades") dim ws2 worksheet: set ws2 = thisworkbook.sheets("output") = 2 ws1.range("m65536").end(xlup).row if ws1.cells(i, 13) = "yes" ws1.rows(i).copy ws2.rows(ws2.cells(ws2.rows.count, 2).end(xlup).row + 1) end if next end sub it sounds if have manually removed errors external data. if bringing data workbook operation repeated on regular basis, may wish automate it. sub happyface() dim long dim ws1 worksheet: set ws1 ...

c# - Binding to items in ItemsControl -

i have problem binding. xaml structure in wpf looks this: <itemscontrol itemssource="{binding cachelist}" > <itemscontrol.itemtemplate> <datatemplate> <stackpanel> <textblock text="{binding type}"/> </stackpanel> </datatemplate> </itemscontrol.itemtemplate> <i:interaction.triggers> <i:eventtrigger eventname="mousedown"> <i:invokecommandaction command="{binding loadfromcache}" commandparameter="-- bind clicked item --"/> </i:eventtrigger> </i:interaction.triggers> </itemscontrol> and moment works fine. when click on items in itemscontrol notice in modelview class. don't know particular item clicked. i tried bind "this" object by: <i:invokecommandaction command="{binding loadcache}" commandparameter="{binding}...

Boost ASIO, how to obtain the time after wait()? in c++ -

so let's have simple main method : int main() { int altitude = 10;//in feet int altitude_rate = 3; //in feet/sec int new_altitude; boost::asio::io_service io; boost::asio::deadline_timer t(io, boost::posix_time::seconds(5)); t.wait(); new_altitude = altitude + (altitude_rate * 5(seconds)); //i want take time asked wait(5 sec in case) , use //calculate new altitude. std::cout << "new altitude: " << new_altitude << std::endl; return 0; } is there function can allow me take time out , use int ? deadline_timer uses expiry time internally , add delay want (5 seconds) current time @ construction. expires_from_now() return remaining time before expires (which can negative if fired). therefore, cannot delay gave. you can either remember time @ constructed timer , use expires_at() figure out initial delay...

CSS not properly affecting HTML -

i'm working on site , having hard time getting css affect html way expect. here page i'm working on: www.lindseybakermedia.com/design/shop-local-weekly/ . part giving me problems list of deals. first of all, i've added padding each div, text seems expanding out of respective divs reason. second, i've used :last-child keep bottom border off last div, doesn't seem working either. i've been using firebug figure out what's going on, have no idea. appreciated. html: <section id="homedealslist"> <div id="dealscontent"> <div id="expirationheader"> <!-- expiration date generated automatically --> <p>these deals expire on <span id="expiration">06/03/15</span>.</p> </div> <!-- 1 div generated content every deal --> <div class="deal"> <a href="businessprofile.php?recordid=27" titl...

c++ - mpz_powm with gmp why it returns 1? -

i have following code , problem result 1. 3 numbers generated algorithm should have small probability result of 1 (look @ n - 256 bits long). int main() { mpz_t a, b, c, result; mpz_init(a); mpz_init(b); mpz_init(c); mpz_init(result); mpz_init_set_str(a, "f1231212317f905af25ca06aa2234b2ff1231212317f905af25ca06aa2234b30", 16); mpz_init_set_str(b, "94ae1752817e4c42124c0aee0682fbdb08963cdf94434e42fa7f813d888c02", 16); mpz_init_set_str(c, "4a570ba940bf26210926057703417df32874c857872d4cae532af37a8bcd959", 16); printf("\n\n%s", mpz_get_str(null, 10, a)); printf("\n\n%s", mpz_get_str(null, 10, b)); printf("\n\n%s", mpz_get_str(null, 10, c)); mpz_powm(result, a, b, c); // result = (a ^ b) % n - why 1 ?!?! printf("\n\n%s", mpz_get_str(null, 10, result)); printf("\n done"); return 0; }

accessing data from sqlite database in Android Studio -

i trying data sqlite database shows error-"java.lang.illegalstateexception:attempt re-open closed object :sqlitequery : select *from mycatlog" . please me. thank you myhelper.class public class myhelper extends sqliteopenhelper { static final string database_name="mydatabase"; static final int database_version=1; static final string table_name="mycatalog"; static final string uid="id"; static final string utitle="title"; static final string uprice="price"; static final string udescp="descp"; static final string create_table="create table "+ table_name"("+uid+"varchar(25) primary key,"+utitle+ "varchar(255),"+uprice+"varchar(255),"+udescp+" varchar(255));"; private static final string drop_table="drop table" +table_name+"if exists"; private context context; public myhelper(context context) { super(context,database_name,null,da...

How does Ruby Test:Unit locate test classes in a deep nested folder? -

how ruby test:unit locate test classes in deep nested folder? java developer , understand how junit , testng can scan folders defined filter locate tests. i wondering if can explain me how ruby can locate test classes similar method, preferrably using kind of filename filter?? say, example, have directory structure so; how ruby test::unit test runner locate tests ending letter 'b'?? project -main -tests -group1 -test1a.rb -test1b.rb -group2 -test2a.rb -test2b.rb -group3 -test3a.rb -test3b.rb -group4 -test4a.rb -test4b.rb links documentation helpful. ok, think figured out, unless else comes better answer, seems rake tool has capability .

javascript - Extracting a property several levels deep from JSON -

Image
code: ienumerator radar() { radarurl = "https://maps.googleapis.com/maps/api/geocode/json?latlng="+ "43.761223" + "," + "11.280470" + "&key=" + apikey; www googleresp = new www(radarurl); yield return googleresp; googlerespstr = googleresp.text; jsonnode jsonreturn = json.parse(googleresp.text); string results = jsonreturn["results"]["formatted_address"].value; debug.log(jsonreturn["results"]["formatted_address"].value); textdebug.text = jsonreturn; debug.log(jsonreturn); } output json: { "results" : [ { "address_components" : [ { "long_name" : "45-47", "short_name" : "45-47", "types" : [ "street_number" ] }, { "long_name" : "via bartolomeo s...