Posts

Showing posts from June, 2012

python - blocking recv() returns empty line instead of actual data -

i'm working on python client supposed converse c programmed server. answers few recognised commands "ok" (the server part works when test netcat client). python client gets ok 1 out of 4 times (and empty lines rest of time). don't why socket set blocking figure receive don't know what. here have. "info" object few strings stored in it, before loop works , bit simplified readability : i'm supposed receive welcome message send team name of connected player receive position. try: s = socket.socket(socket.af_inet, socket.sock_stream) except socket.error, msg: print 'failed create socket. error code: ' + str(msg[0]) + ' , error message : ' + msg[1] sys.exit(); try: remote_ip = socket.gethostbyname(info.host) except socket.gaierror: print "hostname not resolved. exiting" sys.exit() s.setblocking(1) s.settimeout(60) s.connect((remote_ip, info.port)) data = s.recv(1024) print data team = info.team

linux - perl's Devel::ebug how to -

first apologize if misunderstood whole concept of devel::ebug , how should used. want experiment devel::ebug perl module. here found example: what perl equivalent of bash -xv took following code , modified little bit. according official documentation devel::ebug cpan program method selects program load, thing i've changed. #!/usr/bin/perl use strict; use warnings; use devel::ebug; use data::dumper; $ebug = devel::ebug->new; # $ebug->program(shift); # old value: $ebug->program($argv[0]); # new value: $ebug->load; until ($ebug->finished) { print "+++ file:", $ebug->filename, " line: ", $ebug->line, "\n"; $pad = $ebug->pad; $var (sort keys %$pad) { if (ref $pad->{$var}) { $line (split /\n/, data::dumper->dump([$pad->{$var}], [$var])) { print "++ $line\n"; } } else { print "++ $var = $pad->{$var}\n";

rssi - Interpreting the value I receive from the ATDB command for Xbee S2 -

i realize might stupidest question has ever been asked here, i'm stuck. trying rssi value of xbee router send atbd coordinator. value returned in hexadecimal cannot, life of me, see how hexadecimal value interprets dbm value. actually command isn't atbd, atdb , means: " received signal strength. command reports received signal strength of last received rf data packet. db command indicates signal strength of last hop. not provide accurate quality measurement multihop link. db can set 0 clear it. db command value measured in -dbm. for example if db returns 0x50, rssi of last packet received -80dbm . of 2x6x firmware, db command value updated when aps acknowledgment received." (retired xbee zb user manual p.131). as can see example above, need to: read hexadecimal (example: 0x50) read decimal (example: 0x50 = 80 in decimal) multiply -1: (-1)*80 = -80 dbm the atbd command used change serial interface data rate (baud rate).

c++ - std::conditional compile-time branch evaluation -

compiling this: template < class t, class y, class ...args > struct issame { static constexpr bool value = std::conditional< sizeof...( args ), typename std::conditional< std::is_same< t, y >::value, issame< y, args... >, // error! std::false_type >::type, std::is_same< t, y > >::type::value; }; int main() { qdebug() << issame< double, int >::value; return exit_success; } gives me compiler error: error: wrong number of template arguments (1, should 2 or more) the issue issame< double, int > has empty args parameter pack, issame< y, args... > becomes issame< y > not match signature. but question is: why branch being evaluated @ all? sizeof...( args ) fal

dos - Passing exclamation marks as parameters in batch subroutine call -

thanks community have learned how escape exlamation marks immediate use in batch delayedexpansion block. (use 2 escape carets not one, awesome) but can't seem find or figure out how pass contents of variable containing exclamation mark parameter batch subroutine. example: @echo off setlocal enabledelayedexpansion set variable=hello^^! echo "!variable!" call :subroutine "!variable:^^!=^^!!" pause exit :subroutine echo "%~1" exit/b output: "hello!" "hello" press key continue . . . i want second "hello" include exclamation mark. have tried various permutations of substring replacement on line 5 no avail. help you need different way variable replacing, , more carets. @echo off setlocal enabledelayedexpansion set variable=hello^^! echo "!variable!" call :subroutine %variable:!=^^^^^^^^^^!% exit /b :subroutine echo %~1 exit /b or quotes: call :subroutine "%variable:!=^^^!%"

python - Some advice on the style of different ways to limit line length to comply with PEP8 -

i updating code comply pep8 maximum line length. i have 2 questions on people think better style. first init of class (or function definition matter). people split arguments of function definition if line long this: def __init__(self, title, url, teaser, parsedate, updatedate, redis, id=none): or considered better split thát part second line otherwise long this: def __init__(self, title, url, teaser, parsedate, updatedate, redis, id=none): and secondly: in long if statements, don't find splitting of conditions add mucht clarity of code this: if self.redis.exists('article:%s' % self.url)\ , self.redis.hexists('article:%s' % self.url, 'id'): self.id = self.redis.hget('article:%s' % self.url, 'id') else: self.id = self.redis.incr('articleid') if written below, line definatily long,

java - Sending JSON request to hipchat -

i making hipchat room work have send json request of: post /v1/rooms/message?format=json&auth_token=token http/1.1 host: api.hipchat.com content-type: application/x-www-form-urlencoded content-length: 138 room_id=10&from=alerts&message=a+new+user+signed+up so far have this: public static void send(string send){ url url = null; httpurlconnection conn = null; try{ url = new url("http://api.hipchat.com"); conn = (httpurlconnection)url.openconnection(); conn.setrequestmethod("post"); conn.setrequestproperty("content-type", "application/x-www-form-urlencoded"); conn.setrequestproperty("content-length", "138"); conn.setusecaches (false); conn.setdoinput(true); conn.setdooutput(true); dataoutputstream wr = new dataoutputstream( conn.getoutputstream ()); wr.writebytes (send); wr.flush (); wr.close (); input

database - Android: allow signup with Facebook and store more information -

i'm working on android app , want allow users register using facebook, gmail etc. question not how that, because there many posts regarding including tutorials written facebook , google themselves. i want achieve similar stackoverflow log in - users allowed login using gmail instance, while site (or app) keeps own data each user (namely, profile). i'm not quite sure how achieve in android, since facebook , google sdk's allow app access user's facebook name, email (and public information), don't think allow me add more data user app needs own purposes. what thinking of doing manage db of own store additional data (for instance, using parse.com), , use common field services key (was thinking email, since facebook, gmail & twitter use - recommend this?) are there other (better) ways achieve want? perhaps google offers don't know? how safe (though should mention app shouldn't gather personal information). as always, appreciated. thank you.

python - pandas vectorized string replace by index -

trying change first 2 characters in pandas column string. def shift(x): x=list(x) x[0] = '1' x[1] = '9' print x #this prints correct result list ##str(x) return ''.join(x) ## works mc_data['timeshift'] = mc_data['realtime'].map(lambda x: shift(x) ) output nonetype i tried, str.slice_replace.map(lambda x: '19') . how do this? instead of replacing first 2 characters, build new strings: >>> df = pd.dataframe({"a": ['abcd']*4}) >>> df 0 abcd 1 abcd 2 abcd 3 abcd >>> df["a"] = "19" + df["a"].str[2:] >>> df 0 19cd 1 19cd 2 19cd 3 19cd

jQuery Mobile change CSS on 'pageshow' -

i'm trying change css everytime page load/show. how can that? it works when first loading, after page changing css original format , not change @ all it's simple code jquery('#cc11').css({'height': 300}); i included on pageshow/pageinit/pagecreate , works, after changing page , going (sliding) css not update, not change, if call jquery function on button, not change @ all i don't know i'm missing, how can make css change after changing pages?

Login using PHP and MySQL not work -

i create login form using php , mysql. process if user login there database show username on page. database: id | username | email | password --------------------------------------------------------------------------------- 1 | x | x@y.c | 642653d3f6d0a83db108b692de395f9cb8948651 2 | y | y@y.c | 642653d3f6d0a83db108b692de395f9cb8948651 3 | z | z@y.c | 642653d3f6d0a83db108b692de395f9cb8948651 4 | w | w@y.c | 642653d3f6d0a83db108b692de395f9cb8948651 and code is: <?php define('include_check',true); require 'db.php'; session_name('fllogin'); session_set_cookie_params(2*7*24*60*60); session_start(); if($_session['id'] && !isset($_cookie['flremember']) && !$_session['rememberme']) { $_session = array(); session_destroy(); } if(isset($_get['logoff'])) { $_session = array(); session_destroy(); header("location: i

How Dynamics CRM 2013 Localization process work? -

i want know how dynamics crm 2013 localize strings; after investigation, found localize entity labels such displayname in localizedlables table labels in menus , buttons , controls; there table called displaystringbase doesn't contain localizations; dynamics crm use resource files or not? want know detailed process of localization in dynamics crm 2013. dynamics crm has supported way localize strings, need export them excel file , import back. here tutorial: http://www.zero2ten.com/blog/crm-2011-online-localization-custom-translations/ the tutorial crm 2011 process same crm 2013. can export translation of entire solution, not single entity.

bash - Variables from file -

a text file has following structure: paa pee pii poo puu baa bee bii boo buu gaa gee gii goo guu maa mee mii moo muu reading line line in script done while read line; action done < file i'd need parameters 3 , 4 of each line variables action. if manual input, $3 , $4 trick. assume awk tool, can't wrap head around syntax. halp? read fine. pass multiple variables , split on $ifs many fields. while read -r 1 2 3 4 five; action "$three" "$four" done <file i added -r option because want. default behavior legacy oddity of limited use.

html - How to add a class to an element created with javascript -

with code create <select> element: $('ul.category-list').each(function () { var list = $(this), select = $(document.createelement('select')).insertbefore($(this).hide()).change(function () { window.location.href = $(this).val(); }); $('>li a', this).each(function () { var option = $(document.createelement('option')) .appendto(select) .val(this.href) .html($(this).html()); if ($(this).attr('class') === 'selected') { option.attr('selected', 'selected'); } }); list.remove(); }); how give <select> element id or class can control css? html <div class="an-element"></div> css .your-class { color: orange; } javascript, (using jquery library's write-less do-more methods , syntax) $(".an-element").append("<div class='you

In Excel VBA, How to add automatic value in range -

i have list of jobs in sheet1 , 5 employee names in sheet2 . when run macro should automatically find out count of jobs , should divide jobs equally employees , should paste employees jobs. here code below dim x integer dim y integer range(selection, selection.end(xldown)).select x = selection.rows.count y = application.roundup(x / 5, 0) here, how give y value in range? ok try this: sub test() dim jrng range, nrng range dim long, x long, y long j long: j = 1 sheet1 '~~> change suit '~~> change range address suit set jrng = .range("a1", .range("a" & .rows.count).end(xlup))'~~> contains jobs set nrng = .range("c1", .range("c" & .rows.count).end(xlup))'~~> contains names y = jrng.rows.count'~~> number of jobs '~~> number of jobs per name x = application.worksheetfunction.roundup(jrng.rows.count / nrng.rows.count, 0)

performance - How do I choose grid and block dimensions for CUDA kernels? -

this question how determine cuda grid, block , thread sizes. additional question 1 posted here: https://stackoverflow.com/a/5643838/1292251 following link, answer talonmies contains code-snippet (see below). don't understand comment "value chosen tuning , hardware constraints". i haven't found explanation or clarification explains in cuda documentation. in summary, question how determine optimal blocksize (=number of threads) given following code: const int n = 128 * 1024; int blocksize = 512; // value chosen tuning , hardware constraints int nblocks = n / nthreads; // value determine block size , total work madd<<<nblocks,blocksize>>>madd(a,b,c,n); btw, started question link above because partly answers first question. if not proper way ask questions on stack overflow, please excuse or advise me. there 2 parts answer (i wrote it). 1 part easy quantify, other more empirical. hardware constraints: this easy quantify part. a

cordova - phonegap build config.xml not working -

newish phonegap , trying make sense of existing cordova/phonegap project. bit im stuck @ existing config.xml of project below: i have no idea how works not standard config.xml. appreciated. when build project plugins not included, namely softkeyboard plugin. default config.xml appears used instead. <?xml version="1.0" encoding="utf-8"?> <cordova> <!-- access elements control android whitelist. domains assumed blocked unless set otherwise --> <access origin="http://127.0.0.1*"/> <!-- allow local pages --> <access origin="*" subdomains="true" /> <log level="debug"/> <preference name="usebrowserhistory" value="true" /> <preference name="exit-on-suspend" value="true" /> <preference name="disallowoverscroll" value="true" /> <preference name="loadurltimeoutvalue" value="60000" />

matlab - How to set up a level 2 s function with no direct feedthrough? -

i have simulink model being compiled executable through embedded coder (rtw) , have sfunction know has no connection between input , output turn off direct feedthrough on input port. in fact make 2 sfunctions replace it, 1 input, 1 output, complication external system addressing two-way communication in single function call. we use legacy code tool compile of our sfunctions, have read , verified forces inputs direct feedthrough whether or not (with no explanation of why.) have had sfunction builder block, makes no reference direct feedthrough on inputs. have looked @ msfuntmpl_basic.m template builder script seems limited inputs , outputs primitive data types (via datatypeid.) your question asks integrating c code s-function, you're looking @ msfuntmpl_basic.m m-code template. should looking @ c template: sfuntmpl_basic.c . within it, @ line 75, uses macro sssetinputportdirectfeedthrough set feedthrough characteristics of each port, way it. since legacy code

android - Manage fragment life cycle with navigation drawer -

i have architectural issue in application . have used 1 activity navigation drawer , several fragments .now , suppose have 2 fragments , b . navigation structure somewhat: a a1 a2 b b1 b2 where a1,a2 of type fragment , b1,b2 of type b fragment. difference between same type of fragments eg. a1,a2 of data . my first approach : whenever user click on a1,a2,b1,b2 . create new instance of type , replace fragment. fragment fragment =a.newinstance(); private void replacefragment(fragment fragment) { fragmentmanager fragmentmanager = getsupportfragmentmanager(); fragmentmanager.begintransaction() .replace(r.id.content_frame, fragment).commit(); mdrawerlayout.closedrawer(rldrawer); } note : not want add them stack. later on realize approach inefficient every time crate new instance on fragment if of same type . said before difference in data .so, move next approach second approach : now activity has data

ios - Is it Possible to Dismiss MFMailComposeViewController Without User Interaction? -

i able dismiss mfmailcomposeviewcontroller in didfinishwithresult delegate method. however, have scenario dismiss composer without user interaction, selecting cancel or sending mail. i have looked in apple docs , unable find entirely useful. have tried calling dismissviewcontrolleranimated seems working when inside didfinishwithresult delegate method. there anyway force delegate method or dismiss composer alternatively? assuming presenting mail controller uiviewcontroller , may dismiss programmatically calling uiviewcontroller method: dismissviewcontrolleranimated:completion: see apple reference: dismissviewcontrolleranimated:completion: you did mention: i have tried calling dismissviewcontrolleranimated seems working when inside didfinishwithresult delegate method what experiencing may indicative of different problem able outside of mailcomposecontroller:didfinishwithresult:error: delegate method. example: -(void)showmail { mfmailcompo

xamarin.android permgen space error -

i creating android app in xamarin 3. app runs gives error when try view .axml designer. error: "the layout not loaded: permgen space" i know java.lang.outofmemory error not quite sure how solve in xamarin project. using visual studio xamarin plugin. how go away? understand increasing size might solution, not sure how - examples on web in java eclipse. take time help. i restarted visual studio , error gone now.

php - How to validate a form in codeigniter -

i using code igniter 2.1.0 ad trying validate form(though form found homepage of website), have followed documentation on not seem work expected.each time include library page re arranges itself. please 1 tell me wrong.beow portion of page trying vaidate. <?php echo validation_errors(); ?> <form id="signup" action="" method="get"> <label> username:<input type="text" name="username" value="" size="31"/> </label> <br> <label> email:<input type="text" name="email" values="" size="31"/> </label> <br> <label> password:<input name="password" type="password" value="" size="31"/> </label> <br> <label> confirm password:<input name="passcon" type="password"

c# - How to fix this lambda expression? -

i have function sorting multiple user selected columns: public override void sort(sortfields sortfields) { if (sortfields == null || sortfields.count() == 0) return; var res = filtereditems.orderby(o => o[sortfields[0].name], sortfields[0].ascending ? comparer : comparerdesc); (int x = 1; x < sortfields.count(); x++) res = res.thenby(o => o[sortfields[x].name], sortfields[x].ascending ? comparer : comparerdesc); filtereditems = new bindinglist<t>(res.tolist()); if (listchanged != null) listchanged(this, new listchangedeventargs(listchangedtype.reset, null)); } the problem, of course, when res.tolist() called x has been incremented 1 greater highest index in list , throws error. know go ahead , tolist() after each sort defeats purpose , isn't guaranteed sort correctly linq providers. i'm sure there's simple solution this... want tell me is? :) it looks may getting tripped closure on variable x . that

rfc2616 - HTTP 1.1 TE header -

while reading rfc2616, came across te , transfer encoding headers chunked encoding. have following question on these: if http server rejects request because of presence of te header, rfc compliant? if http client sends request te header , list of t-codings , q values , once such q value 1, mandatory http server send response data encoding, eg: te: deflat;q=0.5 gzip;q=1 (does mandate server compress entity data in gzip , send or can server ignore , send data in normal way?). if http server not support reception of chunked data (i aware goes against rfc, intended), right error response code sent client client next time not send put request in chunked fashion. thanks in advance valuable inputs , answers. in rfc 7230 says, the "te" header field in request indicates transfer codings, besides chunked, client willing accept in response, and whether or not client willing accept trailer fields in a chunked transfer coding. this infers te declara

android - How to make all uploaded YouTube videos as private -

in application have upload videos in youtube using android mobile application,but want make uploaded videos private if there possible. set privacy status of video private while uploading video using youtube data api v3 . code - videostatus status = new videostatus(); status.setprivacystatus("private"); for more information visit youtube data api v3

NEO4J shortestPath taking into account a particular relationship pattern -

i have graph have chains of nodes have relationship [:links_to] , can shortestpath function work. for of users level of detail fine. i have set of users there need richer set of information on relationship. given properties on relationships supposed represent strengths or scores relationship have created specific nodes hold descriptive metadata. this means have pattern says (start)-[:participates]-(middle)-[:references]->(end) there can number of nodes between start , end points in chain. i struggling shortestpath function return results more detailed chain. there way using cypher? you have kept metadata information on relationships. for needs, should work: match p = shortestpath((start)-[:participates|:references*]->(end)) return nodes(p)

javascript - How do I detect a particular child on stage with createjs -

how check if there particular child on stage , how check particular child or b in createjs? var = new createjs.bitmap('images.a'); var b = new createjs.text('hello','bold 12px arial'); a.settransform(100,100); b.settransform(100,150); stage.addchild(a,b); stage.update(); when create child element, give name child can child @ later stage using getchildbyname('childname') method. var = new createjs.bitmap('images.a'); var b = new createjs.text('hello','bold 12px arial'); a.settransform(100,100); b.settransform(100,150); a.name = "somenamea"; b.name = "somenameb"; stage.addchild(a,b); stage.update(); stage.getchildbyname("somenamea"); this assuming child added in module, , want child scope of variable no longer available. otherwise, can use variable identify child.

java - Null Pointer Exception preparing Audio Player -

i preparing small audio player, , showing list of audio songs device, whenever tap on of song play, everytime getting error. full logcat : 06-10 15:52:28.440: w/dalvikvm(3732): threadid=1: thread exiting uncaught exception (group=0x41e0d2a0) 06-10 15:52:28.450: e/androidruntime(3732): fatal exception: main 06-10 15:52:28.450: e/androidruntime(3732): java.lang.illegalstateexception: not execute method of activity 06-10 15:52:28.450: e/androidruntime(3732): @ android.view.view$1.onclick(view.java:3699) 06-10 15:52:28.450: e/androidruntime(3732): @ android.view.view.performclick(view.java:4223) 06-10 15:52:28.450: e/androidruntime(3732): @ android.view.view$performclick.run(view.java:17275) 06-10 15:52:28.450: e/androidruntime(3732): @ android.os.handler.handlecallback(handler.java:615) 06-10 15:52:28.450: e/androidruntime(3732): @ android.os.handler.dispatchmessage(handler.java:92) 06-10 15:52:28.450: e/androidruntime(3732): @ android.os.looper.loop(looper

accelerometer - Android detect phone lifting action -

i want perform activity when user lifts phone flat surface. method using right detect shake motion using phone's accelerometer using following code: sensorman = (sensormanager) getsystemservice(sensor_service); accelerometer = sensorman.getdefaultsensor(sensor.type_accelerometer); sensorman.registerlistener(this, accelerometer, sensormanager.sensor_status_accuracy_high); public void onsensorchanged(sensorevent event) { if (event.sensor.gettype() == sensor.type_accelerometer) { mgravity = event.values.clone(); // shake detection float x = mgravity[0]; float y = mgravity[1]; float z = mgravity[2]; maccellast = maccelcurrent; maccelcurrent = floatmath.sqrt(x * x + y * y + z * z); float delta = maccelcurrent - maccellast; maccel = maccel * 0.9f + delta; if (maccel > 0.9) { //perform tasks. } } the issu

Access properties via subscripting in Swift -

i have custom class in swift , i'd use subscripting access properties, possible? what want this: class user { var name: string var title: string subscript(key: string) -> string { // here return // return property matches key… } init(name: string, title: string) { self.name = name self.title = title } } myuser = user(name: "bob", title: "superboss") myuser["name"] // "bob" update: reason why i'm looking i'm using grmustache render html templates. i'd able pass model object grmustache renderer… grmustache fetches values keyed subscripting objectforkeyedsubscript: method , key-value coding valueforkey: method. compliant object can provide values templates. https://github.com/groue/grmustache/blob/master/guides/view_model.md#viewmodel-objects (grmustache author here) until swift-oriented mustache library out, suggest having classes inheri

java - Synchronized blocks don't work when using member of unrelated class as lock object? -

pretty resources i've found on synchronized blocks use this or member of class lock object. i'm interested in finding out why can't synchronized blocks work when lock object (static) member of class. here's code illustrate problem: public class test { public static void main(string[] args) { thread thread1 = new firstthread(); thread thread2 = new secondthread(); thread1.start(); thread2.start(); } } class firstthread extends thread { @override public void run() { synchronized (lock.lock) { system.out.println("first thread entered block"); try { lock.lock.wait(); } catch (interruptedexception e) { e.printstacktrace(); } } system.out.println("first thread exited block"); } } class secondthread extends thread { @override public void run() { try { thre

python - Unbaking mojibake -

when have incorrectly decoded characters, how can identify candidates original string? Ä×èÈÄÄî▒è¤ô_üiâaâjâüâpâxüj_10òb.png i know fact image filename should have been japanese characters. various guesses @ urllib quoting/unquoting, encode , decode iso8859-1, utf8, haven't been able unmunge , original filename. is corruption reversible? you use chardet (install pip): import chardet your_str = "Ä×èÈÄÄî▒è¤ô_üiâaâjâüâpâxüj_10òb" detected_encoding = chardet.detect(your_str)["encoding"] try: correct_str = your_str.decode(detected_encoding) except unicodedecodeerror: print("could not estimate encoding") result: 時間試験観点(アニメパス)_10秒 (no idea if correct or not) for python 3 (source file encoded utf8): import chardet import codecs falsely_decoded_str = "Ä×èÈÄÄî¦è¤ô_üiâaâjâüâpâxüj_10òb" try: encoded_str = falsely_decoded_str.encode("cp850") except unicodeencodeerror: print("could not encode f

Is there any way to fill form in without form tag in html using firefox in autoit? -

i trying fill web form script fill web forms having <form> </form> . site not have in html. there way fill in firefox using autoit? however, _ff_autologin($uname,$pwd,$url) fail in such case. using _ffsetvalue($uname,$formuid,"id") _ffsetvalue($pwd,$formpid,"id") even not filling requirement. can 1 suggest me going wrong. using latest version of mozilla along mozrepl-addon. use _ffsetvaluebyid set value of element based on id.

android - EmojiconEditText Not work <requestFocus /> -

i'm trying en underlined in edittext, can not extends emojis why. i have tried many things, not work. xml com.rockerhieu.emojicon.emojiconedittext . <requestfocus /> /> you can try this.such <com.rockerhieu.emojicon.emojiconedittext android:id="@+id/editemojicon" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="ie32d emojicon" emojicon:emojiconsize="28sp" > <requestfocus /> <com.rockerhieu.emojicon.emojiconedittext />

c++ - Save data in database after tableView data changed -

i showing data sqlite database in qstandarditemmodel in tableview user can edit it. want save these changes database now, once user presses "save" or tries exit unsaved changes (to give promt, in such case). what best way this? thinking of running update queries. there way run queries on rows have been modified user? you can use qsqltablemodel show table contents in qtableview : qsqltablemodel * model = new qsqltablemodel(this,db); model->seteditstrategy(qsqltablemodel::onmanualsubmit); model->settable( "sometable" ); model->select(); ui->tableview->setmodel( model ); for saving or cancelling changes can begin tranaction , commit or rollback @ end. starting transaction : model->database().transaction(); code save button: if(model->submitall()) model->database().commit(); else model->database().rollback(); code cancel button: model->revertall(); model->database().rollback();

sql - PHP query / mdb encoding issue question mark using odbc query -

i have problem getting data mdb database. have table persons name , surname in spanish have tildes 'agustí' , 'ñ'. making query shows this: alexis agust� sans i don´t have idea encoding think solution encoding utf-8. right?. i add here code of query, it´s simple: // connection ok, don´t worry $cidl=odbc_connect($dsnl, $usuariol, $clavel, sql_cur_use_odbc); $queryl = "select * personas val=1"; $resultl = odbc_exec($cidl, $queryl); while(odbc_fetch_row($resultl)) { $nombre=odbc_result($resultl, 'nombre'); $apellidos=odbc_result($resultl, 'apellido'); $nombrecompleto=$nombre.' '.$apellidos; echo $nombrecompleto; } how can surname('apellido') without question mark? thanks.

css - Multi column HTML list that goes from top to bottom -

inline html list displayed in browser item1 item2 item3 item4 item5 ... can achieve using html , css item1 item6 item11 item2 item7 ... item3 item8 item4 item9 item5 item10 use columns property: ul { list-style: none; columns:100px 3; -webkit-columns:100px 3; /* safari , chrome */ -moz-columns:100px 3; /* firefox */ } here's demo if don't care order, more compatible way use percents li widths: li { display: inline-block; min-width: 25%; margin-right: 5%; } demo code here

c++ - Finding shortest circuit in a graph that visits X nodes at least once -

Image
even though i'm still beginner, love solving graph related problems (shortest path, searches, etc). faced problem : given non-directed, weighted (no negative values) graph n nodes , e edges (a maximum of 1 edge between 2 nodes, edge can placed between 2 different nodes) , list of x nodes must visit, find shortest path starts node 0, visits x nodes , returns node 0. there's @ least 1 path connecting 2 nodes. limits 1 <= n <= 40 000 / 1 <= x <= 15 / 1 <= e <= 50 000 here's example : the red node ( 0 ) should start , finish of path. must visit blue nodes (1,2,3,4) , return. shortest path here : 0 -> 3 -> 4 -> 3 -> 2 -> 1 -> 0 total cost of 30 i thought using dijkstra find shortest path between x (blue) nodes , greedy picking closest unvisited x (blue) node, doesn't work (comes 32 instead of 30 on paper). later noticed finding shortest path between pairs of x nodes take o(x*n^2) time big nodes. the thing fi

TFS Folder creation and update permissions set to readonly -

over last several months myself , on development team have run across new issue. when tfs creates folder or 'get latest' , overwrites of files in folder structure, changes folder permissions 'read-only'. causes issue, inconvenience really, when go build project tell our access folders denied. if open folder , un-check 'read-only' able proceed build and/or publish of solution. we have checked our networking department, not network setting , not occurring anywhere outside of tfs. occuring when tfs creates folder. is else having issue? i've been pouring on settings off , on, trying determine if can change setting. not want folder read-only when generated or updated. this design inconvenience not. in tfs 2012 (with vs2012) microsoft introduced local workspaces not put readonly. you can go settings of workspace , change server local time. you making common mistake in have files change during build under source control. if remove files

c# - Recursive insert-method for a linked list -

i'm learning c# , i've made recursive insert-method linked list: public static int recursiveinsert(ref int value, ref mylinkedlist list) { if (list == null) return new mylinkedlist(value, null); else { list.next = recursiveinsert(ref int value, ref list.next); return list; } } how can modify method make recursive call this: recursiveinsert(value, ref list.next) instead of: list.next = recursiveinsert(ref int value, ref list.next); since never mutating parameters passing reference, can not pass them reference @ all. need recognize mylinkedlist being reference type (it should absolutely reference type) means you're not passing value of object itself, you're passing reference it, can mutate reference without passing reference reference.) remove uses of ref (and fix return type correct) , you're done: public static mylinkedlist recursiveinsert(int value, mylinkedlist list) { if (list == null) r

Use array to search for CASE values Excel VBA -

i'm trying create array list of variable values within 1 cell. for example: cell b3 contains values: 1a, 2b, 3a, 4a, 5c. i want convert data that: myarray=("1a", "2b", "3a", "4a", "5c") i.e. myarray(1) = "1a" myarray(2) = "2b" myarray(3) = "3a" myarray(4) = "4a" myarray(5) = "5c" then want use values of array perform case search compile running total testing. my code far: 'create subroutine copy , total data worksheet 1 worksheet 2 private sub vts() 'establish variable case search dim valr string 'establish counter array dim myarray(1 170) myarray(1) = worksheets(2).range("a7").value myarray(2) = worksheets(2).range("a10").value 'dim valves() string 'dim thisvalue string valr = worksheets(1).range("b4").value 'valr = split(valvestring, ";") 'valves = valr 'for v = 1 ubound(valves)

Deserializing protobuf from C++ and reserializing in C# gives different output -

i have file protobuf message in in byte format, when read file , deserialize protobuf works fine (i can read objects fields , correct), however, when reserialize , save file, bytes different original (causing compatibility issues). more specifically, after string , before bool theres bytes '18 00' added. i tried playing around dataformat options protobuf-net exact same result original, no avail. does know of options in protobuf-net in regards saving string or bool explain 2 bytes? also, ulong being saved differently in bytes aswell. i don't have control on original file, know it's compiled/serialized c++ my goal recreate exact same file (bytewise) serializing in c#, identical file serialized c++. this comes down how properties handled. default, protogen -i:my.proto -o:my.cs generates simple properties, of form: private bool _some_value = default(bool); [global::protobuf.protomember(3, isrequired = false, name=@"some_value", d

c# - LINQ - Cannot implicitly convert type with custom data model list property -

despite dozens of browser tabs open various linq threads, still cannot seem particular linq query work correctly. i'm working in asp.net mvc 5 web application , exact error message is: cannot implicitly convert type 'system.collections.generic.list<string>' 'system.collections.generic.list<turboapp.models.submodel>' in controller, i'm trying build custom data model can hand off view. curve ball need group data in such way can have list of part/engine details, multiple "submodels" of vehicle part fit. query looks this: var parts = _db.vwfullpartdata .where(d => d.vehiclemakeid == make && d.vehiclemodelid == model && d.vehicleyearid == year) .take(20) .groupby(d => new { d.pn, d.description, d.cyl, d.liter, d.fuel }) .select(x => new turbodetailslistviewmodel { pn = x.key.pn, description = x.key.description, cyl = x.key.cyl, liter = x.key.liter, fuel = x.key.fuel, submode

Java remote mysql database error? -

hi i'm trying develop application remote database on site. try close firewall , ping mysite's ip address , receive packets normally. , still receive problem: com.mysql.jdbc.exceptions.jdbc4.communicationsexception: communications link failure last packet sent server 0 milliseconds ago. driver has not received packets server. @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(unknown source) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(unknown source) @ java.lang.reflect.constructor.newinstance(unknown source) @ com.mysql.jdbc.util.handlenewinstance(util.java:411) @ com.mysql.jdbc.sqlerror.createcommunicationsexception(sqlerror.java:1116) @ com.mysql.jdbc.mysqlio.<init>(mysqlio.java:344) @ com.mysql.jdbc.connectionimpl.coreconnect(connectionimpl.java:2332) @ com.mysql.jdbc.connectionimpl.connectonetryonly(connectionimpl.java:2369) @ com.mysql.jdbc.connectionimpl.createnewio(c

c - Array is treated as constant pointer,so we cannot change the pointer value but individually element of an array can be changed why? -

array treated constant pointer,so cannot change pointer value,i unable figure out lets suppose- a[5]="hello"; a="hai"; // know not possible why if below a[0]='a' possible? a[0]='a' ;//this possible because store in stack memory. now coming pointer char *a="hello"; a="hai"; //i know possible because string store in code section read memory why changed? a[0]='a' //not possible because store in stack , string store in code section if above a="hai" possible why a[0]='a' not possible? i new here , have been blocked 2 times please apart demoralizing making vote down please me understand concept assume following declarations: char arr[6] = "hello"; char *ap = "hello"; here's 1 possible memory map showing outcome of declarations (all addresses made out of thin air , don't represent real-world architecture): item address 0x

reactjs - React – the right way to pass form element state to sibling/parent elements? -

suppose have react class p, renders 2 child classes, c1 , c2. c1 contains input field. i'll refer input field foo. my goal let c2 react changes in foo. i've come 2 solutions, neither of them feels quite right. first solution: assign p state, state.input . create onchange function in p, takes in event , sets state.input . pass onchange c1 props , , let c1 bind this.props.onchange onchange of foo. this works. whenever value of foo changes, triggers setstate in p, p have input pass c2. but doesn't feel quite right same reason: i'm setting state of parent element child element. seems betray design principle of react: single-direction data flow. is how i'm supposed it, or there more react-natural solution? second solution: just put foo in p. but design principle should follow when structure app—putting form elements in render of highest-level class? like in example, if have large rendering of c1, don't want put whole render o

maven - Android Integration Test Uses Old APK -

i've created beautiful android project using maven , the android-release archetype . have simple problem: integration tests don't use newest version of library under test. when run eclipse, maven , m2e seem use obsolete version (at least app opened on device split second looks way). first thought might eclipse's stupid caching, maven should able use correct version. deleted bin , target folders , entries in maven repositories, build pulls old version out of thin air. and found not library under test obsolete, there test executed via maven , m2e deleted time ago. i know question pretty vague, i'm not sure source of problem. can give me pointer happening? evidently these @ least 2 separate problems. fixed eclipse portion adding library dependency in android properties of project. since it's problem android-maven-plugin i'll post relevant parts of pom.xml of integration test project in hopes starting same archetype had same problem , knows how fix it