Posts

Showing posts from August, 2010

c++ - QDate::FromString() issue with QDate.year() always returning -4713 -

i trying add date qdate object. month , day placed qdate object correctly year reads -4713. here code: int main(int argv, char *argc[]) { // show arguments make sure correct qdebug() << "\n"; for( int = 0; < argv ; i++) { qdebug() << << ": " << argc[i] << "\n"; } // add yyyy-mm-dd date date qdate date = qdate::fromstring(argc[1],"yyyy-mm-dd"); // check see if date correct qdebug() << "year: " << date.year() << "\nmonth:" << date.month() << "\nday" << date.day(); return 0; } here use in terminal: ./birthday "1992-01-01" the output looks this: 0 : ./birthdays 1 : 1990-01-01 year: -4713 month: 1 day: 1 now no matter choose year returns -4713. know why? have been stuck on issue while , not understand going on here. maybe varies qt version qt version me string wasn't conv

structured programming - Calling Static Method of Class WITHOUT classname, PHP -

maybe it's foolish question, , want implement utils functions using oop in php, instead sp (strudtured programming), uses sp. an example: class { public static function x() { echo "using x method!"; } } according static oop, use x function need use: a::x(); but want use only: x(); how can it? thk function x() { return a::x(); } or can try do: function x() { return a::__function__(); }

osx - Mount Windows smb shares on a Mac using Python -

i create python script mounts windows smb share on mac copies data it. falling @ first hurdle, having problems mounting share. should easy can't work. have trawled internet , have few clues: mount -t smbfs //user@server/sharename share this doesn't work have seen solution uses os module mount command: import os os.system("mount -t smbfs //user@server/sharename share") but doesn't work either. i have read creating local mount point remote share mount to. true? , how go this? many insights all best john i think have figured out: import os directory = "/users/user.name/foldername" if not os.path.exists(directory): os.makedirs(directory) os.system("mount_smbfs //user.name:password@server/servershare ~/foldername") this check whether local folder called foldername exists , create if doesn't. mount smb share using defined username/password.

java - Write into a properties file from a maven project -

i want write properties file. read properties file. here path properties file in maven public void setproperty(string coll, string bez) throws urisyntaxexception { file file =null; properties properties = getproperties(); url url = thread.currentthread().getcontextclassloader().getresource("/jsfatwork/messages/test.properties"); url url2 = pageservicebean.class.getresource("/jsfatwork/messages/test.properties"); try { file = new file(url.touri().getpath()); properties.setproperty(bez, coll); system.out.println("ich habe einen wert gesetzt"); properties.store(new fileoutputstream(file), null); system.out.println("die datei wurde gespeichert"); } catch (ioexception ex) { logger.getlogger(pageservicebean.class.getname()).log(level.severe, null, ex); } } the console output is: ich habe einen wert ge

Heroku timeout with custom Buildpack -

i have custom heroku buildpack compiles cmake , opencv. problem is, opencv takes forever compile. i've tried precompiling opencv , pulling in during build; however, have not yet been successful in doing so. i came across compile_timeout=n env variable can set override 15 minute timeout, it's not working. know if env still supported? or if there approach besides precompiling? i ideally have flexibility of compiling on fly if update latest version of opencv (compilations cached on heroku i'm not waiting around full build on every deploy). i think best shot build binaries beforehand. however, heroku still doesn't have great support this. see these links suggestions: https://discussion.heroku.com/t/compiling-a-custom-binary-for-buildpack/224 https://discussion.heroku.com/t/opencv-and-statically-compiled-python/105

excel - VBA concatenated arrays comparison - error 1004 coming up -

i have these entries in rows 1 10 , columns d: a 10 10 b 20 b 20 c 30 c 30 d 40 d 40 e 50 e 50 f 60 f 60 g 70 h 80 90 j 100 with vba code (that paste below), wanting to, using vba arrays, build concatenated "virtual column" of , b , c , d. then, wanting create third array populated array gives me match result each array element using concatenation of , b compared same of c , d. (there's point this: it's prototype of more complex want build later on.) it works until 6th element in array, beyond gives me 1004 error (with element values after empty in watch window). can give me pointers why? here (probably inelegant) vba code: sub concatarray() dim count1 integer dim count2 integer count1 = application.counta(columns("a:a")) count2 = application.counta(columns("c:c")) dim column1() variant dim column2() variant dim virtcolumn3() variant dim column4() variant dim column5() variant

c# - DataGridColumn Change to ComboBox -

i have list usrdetails i'm using data source datagridview . 2 questions: how can change column type 3rd column in datagridview datagridtextboxcolumn datagridcomboboxcolumn ? once i've changed 3rd column combobox how populate list of strings? public class usrinfo { public string userid { get; set; } public string username { get; set; } public string group { get; set; } public string seclev { get; set; } public string isext { get; set; } public usrinfo(string userid, string username, string group, string seclev, string isext) { this.userid = userid; this.username = username; this.group = group; this.seclev = seclev; this.isext = isext; } } public static list<usrinfo> usrdetails = new list<usrinfo>(); private void form5_load(object sender, eventargs e) { var combocolumn = new datagridviewcomboboxcolumn(); datagridview1.datasource = null; datagridview1.data

How does this Python function returns number but also a dictionary? -

below assignment algorithm class learning nodes, paths, etc. code designed check if 1 node reachable another. code below works unclear why. g "graph" containing each node key values = nodes connects to. mark_component function below returns number of nodes given node. however in function check_connection designed return true if 2 nodes reachable, calls mark_component function , tests see if node in dictionary. what not check_connection starts empty dictionary "marked" , calls mark_component using dictionary. nodes added it. mark_component returns number how check_connection function able "read" in marked? far function concerned, thought marked still empty. guess assumed marked local variable containing dictionary apparently can passed function , changed. can please explain me? many thanks def mark_component(g, node, marked): marked[node] = true total_marked = 1 neighbor in g[node]: if neighbor not in marked:

HTML5 Player Framework - fallback to Silverlight in IE8 not working -

hi trying video play azure media services , using html5 player framework ( https://playerframework.codeplex.com/wikipage?title=html5%20player&referringtitle=documentation ) i have tested example on ie8 , correctly falls silverlight ( http://smf.cloudapp.net/html5/html/fallback.html ) however when try implement own not work correctly. see code snippet 1 below - plays html5 video in compatible browsers - in ie8 shows black screen white loading icon - if change code , force play in silverlight (see code snippet 2) play in silverlight in browsers - these leads me believe video encoded correctly on server however, notice when have fallback example fallback mp4 when show silverlight smooth url manifest file. not sure happening there. using dynamic packaging azure media services , have tried using both mp4 , mianifest thoughts , please code snippet 1 - not fallback <video id="myvideo" class="pf-video" width="480" height="320" c

jquery - Why does bloodhound.get() return undefined? -

i'm trying use code below typeahead.js v 0.10 // instantiate bloodhound suggestion engine var numbers = new bloodhound({ datumtokenizer: function(d) { return d; }, querytokenizer: bloodhound.tokenizers.whitespace, local: ["(a)labama","alaska","arizona","arkansas"] }); // initialize bloodhound suggestion engine numbers.initialize(); console.log(numbers.get('a')); in fact try solve question: https://github.com/bassjobsen/bootstrap-3-typeahead/issues/26 expected shown below should possible: $('.typeahead').typeahead( { items: 4, source:function(query){return numbers.get(query)} }); update the examples . use ttadapter() set source of typeahead. function can used set source property (which accept array of string or function) bootstrap-3-typeahead : // instantiate bloodhound suggestion engine var numbers = new bloodhound({ datumtokenizer: bloodhound.tokenizers.whitespace,//function(d) { return d; }, que

python - Handling HUGE numbers in numpy or pandas -

i doing competition provided data anonymized. quite few of columns have huge values. largest 40 digits long! used pd.read_csv columns have been converted objects result. my original plan scale data down since seen objects can't arithmetic on these. does have suggestion on how handle huge numbers in pandas or numpy? note i've tried converting value uint64 no luck. error "long big convert" you can use pandas converters call int or other custom converter function on string being imported: import pandas pd stringio import stringio txt='''\ line,big_num,text 1,1234567890123456789012345678901234567890,"that sure big number" 2,9999999999999999999999999999999999999999,"that bigger number" 3,1,"tiny" 4,-9999999999999999999999999999999999999999,"really negative" ''' df=pd.read_csv(stringio(txt), converters={'big_num':int}) print df prints: line

ruby on rails - Where to start with my web app? -

as learning exercise want create simple webapp - familiar html/css want delve more backend . my learning objectives app relatively simple: create app using ruby (as i'm learning @ moment) learn how store data database how display stored data have app available online - thinking either sinatra or ror? i've uploaded image of want app like , do. able make various input fields , buttons using html , style css don't know go there create database , link buttons etc. i'm not after completed code, rather should research , into. appreciate , :) looking @ desired app, , given it's learning purposes, i'd suggest pick sinatra + erb/haml + mysql/postgresql since it's lighter, extremely easy , quick learn. once comfortable it, you'll able move more complex framework ror. some resources start off: http://www.sinatrarb.com/intro.html http://testerstories.com/building-simple-web-apps-with-ruby-part-1/ http://samuelstern.wordpress.com/201

Extract column names in java from a dynamic sql query -

i want parse sql query , extract column names it. can't extract part between 'select' , 'from' because query can have alias. requirement now, later on type of query can come in, need dynamic method/ library return column names. you need use resultsetmetadata names of columns in result set returned after executing query. resultset rs = stmt.executequery(...); resultsetmetadata rsmd = rs.getmetadata(); int columncount = rsmd.getcolumncount() (int = 1; < columncount; i++) { system.out.println(rsmd.getcolumnname(i)); } note : index starts 1 , not 0

python - Chirp Running on Maemo -

i'm trying chirp run under maemo5 (a debian based mobile operating system). when running .chirpw or setup.py result nokia-n900:~/compile/chirp-0.3.1# ./chirpw chirp 0.3.1 on linux - maemo 5 %h (python 2.5.4) traceback (most recent call last): file "./chirpw", line 105, in <module> chirp import * file "/root/compile/chirp-0.3.1/chirp/icq7.py", line 50 class icq7radio(icf.icomclonemoderadio): ^ syntaxerror: invalid syntax i using chirp source found here: http://chirp.danplanet.com/download/0.3.1/chirp-0.3.1.tar.gz the idea able program radios linux powered phone, can't seem figure out why program getting held on icq7radio class. any help/pointers appreciated. that version quite old, have try latest daily build http://trac.chirp.danplanet.com/chirp_daily/latest/ you can download full hg repository with hg clone http://d-rats.com/hg/chirp.hg see http://chirp.danplanet.com/projects/chirp/wiki/developers

java - intent does not launch any activity -

in %mainactivity have protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); intent intent = new intent(mainactivity.this, loginsignupactivity.class); startactivity(intent); .... } in fact, intent wrapped authentication check debug deleted it, method doesn't launch loginsignupactivity . ? edit: here's entire oncreate method protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); intent intent = new intent(mainactivity.this, loginsignupactivity.class); startactivity(intent); setactionbarlistnavigation(); setupdrawer(); setupcontainer(); } mainactivity extends customactivity (which lods data asyncloader ) , last activity inherits fragmentactivity , has oncreate method

angularjs - Onclick Button Change AngularUI -

i'm trying make 6 buttons selectable. i'm having trouble adding more two. third button selecting other buttons , buttons deselecting when clicked twice. undesired. it's mess. can me sort out? here's code: <div ng-app="plunker"> <div ng-controller="mainctrl"> <button type="button" class="btn" ng-class="{'btn-primary':isuploadactive}" ng-click="toggleactive1()">upload</button> <button type="button" class="btn" ng-class="{'btn-primary':isdownloadactive}" ng-click="toggleactive2()">download</button> </div> </div> var app = angular.module('plunker', []); app.controller('mainctrl', function($scope) { $scope.button1active = false; $scope.button2active = false; $scope.button3active = false; $scope.button4ac

Calling javascript variables from a separate HTML/php file -

i have separate javascript file(buy.js) html file(pay.php) html file posts once form submitted. however, there javascript variables in pay.php outside scope of form need call in separate javascript file (buy.js). possible do? this snippet of javascript need access in html file (buy.js): var planterm = term; this javascript in html need separate javascript file access (pay.php): var term = 0; var price = 0; function updateprice(e) { price = parsefloat(select.value); if (price == select.options[1].value){ term = 12; } else if (price == select.options[2].value) { term = 1; } } here pastie of code. using php can (using include() function): include("file.php"); so, example goes, the js_include.php file : <html> <body> <script> var jsvar = "this external js var."; </script> </body> </html> the index.php <html> <body> <?php include(&quo

io - In Lua, how to print the console output into a file (piping) instead of using the standard output? -

i workin' torch7 , lua programming languages. need command redirects output of console file , instead of printing shell. example, in linux, when type: $ ls > dir.txt the system print output of command "ls" file dir.txt, instead of printing default output console. need similar command lua. know it? [edit] user suggests me operation called piping . so, question should be: "how make piping in lua?" [edit2] use # command do: $ torch 'my_program' # printed_output.txt have here -> http://www.lua.org/pil/21.1.html io.write seems looking for.

unity3d - How can I get the distance from point a to point b on a custom (relative) axis? -

Image
trying find distance point point b given custom axis. have pictures me better explain: i'm trying find distance red pink (or gray) on 2 custom axes. axis red green (axis rg) , axis red blue (axis rb). you're asking vector projection . given 2 vectors a , b , a projected onto b ? in case, a seems difference between red , pink, b you're calling custom axis. calculating projection involves dot product. lucky you, unity provides vector3.dot make easy. we can calculate projection scalar. "this much" in direction of b: float projscalar = vector3.dot(a, b.normalized); this gives length you're asking about. if needed, can convert result vector, casting length in direction of b: vector3 projvector = b.normalized * projscalar;

sent javascript variable to php and it prints out "Array" -

i sent javascript variable containing innerhtml "basic" php ajax , sent email variable , returned "array" opposed "basic". confused. html: <label class="plan-name">plan name: <b id="somii-plan">basic</b></label> javascript/ajax: var somiiplan = document.getelementbyid('somii-plan').innerhtml; var request = $.ajax({ type: "post", url: "somii-pay.php", datatype: "json", data: { "somiiplan" : somiiplan, "email" : email, } }); php: $somiiplan = ['somiiplan']; $email = $_post['email']; $email_to = "******"; $email_subject = "somii test charge"; $email_message = "your plan is: " . $somiiplan; $headers = 'from: '.$email."\r\n". 'reply-to: '.$email_to."\r\n" . 'x-mailer: php/' . phpversion(); @mail($email_to, $email_

php - In Wordpress (Twentyfourteen, specifically) how can I have featured posts also shown in my post stream? -

i've set wordpress using twentyfourteen. i've created child theme , started tweaking index page hoping achieve this, far haven't had luck. my end goal this: i featured posts show on homepage in normal post stream (as if didn't choose featured). right when choose featured, takes post out of stream of posts , sits exclusively in top featured section. i looked tweaking twentyfourteen_get_featured_posts() i'm not understanding why after gets featured post, seems flag it, or remove normal post flow. could put me on right track making work? thanks in advance so 2014 theme wordpress tricky. has method filter out featured posts home page , it's hooked in. the file in inc folder in twentyfourteen theme folder , named featured-content.php the function pre_get_posts . might want try commenting out block of code function , commenting out below line in same file: add_action( 'pre_get_posts', array( __class__, 'pre_get_posts' )

Mobile Friendly Navigation -

how create mobile friendly navigation bar? this code <ul class="nav nav-tabs"> <a href="http://www.startinpoint.com/"><img src="images/logo.jpg" class="logo span12 pull-left" height="45"></a> <li>&nbsp&nbsp&nbsp</li> <li><a href="adminhome.html"><span class="glyphicon glyphicon-home"></span></a></li> <li class="dropdown"> <a href="#" data-toggle="dropdown" class="dropdown-toggle">view <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="viewleavetransaction.html">leave transaction</a></li> <li><a href="viewleavesummary.html">leave summary</a>

javascript - jQuery: click() triggers twice with dynamic content -

i'm loading contents database on ajax div. then, clicking on of these content-pieces should reload new content. the ajax request initialized method in class call @ beginning: function request(tag1, tag2, tag3) { this.tag1 = tag1, this.tag2 = tag2, this.tag3 = tag3 } request.prototype = { ajaxcategoryrequest: function () { $.ajax({ type: "get", url: "request2.php", data: "tag1=" + this.tag1 + "&tag2=" + this.tag2 + "&tag3=" + this.tag3, success: function (data) { var jdata = $.parsejson(data); //frage ausgeben $("h1.question").html(jdata[0]); //tiles ausgeben (var = 1; < jdata.length; i++) { $("#tiles").append( '<div class="category" id="' + jdata[i].type + '" data-own

c# - LINQ look up list of objs in datable of different objs that share a common property -

i have list obj , list b obj b. both list share 1 property , want obj b of list b has in , pull them out. so, ex. list bunch of people list b bunch of names both list have personid now want people names in list b. thinking a: class names { public int id {get;set;} public string name {get;set;} } class people { public int id {get;set;} public string name {get;set;} } var newlist = new list<person>(); foreach(var n in names) { var person = people.firstordefault(p => p.name == n); if(person!=null) { newlist.add(person); } } } i wondering there more efficent way linq can because wont list everytime might database im calling , dont want call database thousands no reason. this bad example if think it. this codes : var newlist = new list<person>(); foreach(var n in names) { var person = people.firstordefault(p => p.name == n); if(person!=null) {

c# - Get value of non-existing variables by calling a method -

as strange might sound, want access not. here's example: int tempvar = myobject.myvar // myvar not exist; in reality want class run method, take non-existing variable parameter: object returningvariables(string variablename) { object desiredobject; // concrete object have stored somewhere in array inside class // going trough list contains names of variables, when finds // return return desiredobject; } i'll try explain in concrete example want achieve , why. i have class stores stats of object: name, level, speed, size, etc. supposed accessed trough method statdata getstat(string statname) ; stats created trough method void makestat() . problem began when stats created in class public variables , accessed other classed not trough getstat() method. now public variables changed, deleted or new ones added takes refactoring app working again. , looks bad when there mixed calls direct access public variable , method same thing. please note, know

c# - ComponentOne Studio for ASP.NET AJAX installation issue -

hi can me issue... i'm trying install componentone studio asp.net ajax halfway through pop out error: gac operation error unable add c:\promgram files (x86)\componentone\studio asp.net\bin\v4\designer\c1.web.ui.design.4.dll global assembly cache please advice me.. thank you~ the issue observed due lack of permissions write in gac. suggest run setup administrative privileges (right click , select 'run administrator'). thanks, richa

objective c - UITableView header view and searchBar dismissal issue. Constraint issue? -

i have uisearchbardisplaycontroller, text field, , button in header view of tableview. i've tried putting... self.searchbar.translatesautoresizingmaskintoconstraints = yes; in viewdidload. i've tried putting constraints, crashes when dismiss displaycontroller, either hitting cancel button or click on background. error... 2014-02-05 22:49:16.774 xxxx[3818:60b] *** assertion failure in -[uitableview layoutsublayersoflayer:], /sourcecache/uikit/uikit-2903.23/uiview.m:8540 2014-02-05 22:49:16.777 xxxx[3818:60b] *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'auto layout still required after executing -layoutsubviews. uitableview's implementation of -layoutsubviews needs call super.' *** first throw call stack: (0x2fd76e83 0x3a0d36c7 0x2fd76d55 0x3071f0af 0x324fb413 0x32181943 0x3217d167 0x32510231 0x32732d2f 0x327326b7 0x32532ab7 0x325329cf 0x32188413 0x3a5b80af 0x3a5ba9a9 0x2fd415b1 0x2fd3fe7d 0x2fcaa471 0x2f

html - How to change image size based on the resolution? -

i trying create image enlarge or shrink based on screen resolution. i using bootstrap , want change image size. problem image not big , not sure how enlarge image if user expend browser window. my html like: <div> <img class='col-md-12' src='img.png'/> </div> css img{ width:100%; } thanks help! this you- these jquery libraries resize images on responsive view http://responsiveimg.com/ http://responsejs.com/

c# - Input string was not in a correct format in SqlCommand -

here code used , popup exception @ 3rd command.commandtext assignment same way used in 2nd command.commandtext assignment, sqlcommand command = conn.createcommand(); conn.open(); //1st command.commandtext = query; sqldatareader reader = command.executereader(); arraylist almaingrid = new arraylist(); while (reader.read()) { supporttable table = new supporttable(); table.laysheetno = reader.getvalue(0).tostring(); table.plnlaystarttime = reader.getdatetime(1).tostring(); table.plnlayendtime = reader.getvalue(2).tostring(); table.laytableid = reader.getvalue(3).tostring();// reader.getvalue(3).tostring(); table.layteamid = reader.getvalue(4).tostring(); almaingrid.add(table); } reader.close(); foreach (supporttable table in almaingrid) { //2nd command.commandtext = string.format("select ctdesc cuttable ctid ={0}", int.parse(table.laytableid)); string tabledesc = (string)command.execut

regex - html tag attr regular expression in vs 2008 -

i ask regular expression question. want search following syntax in vs 2008: <table width="10%" class="test" style=""> </table> <table class="test" style="" width="10%"> </table> <table class="test" width="10%" style=""> </table> <table class="test" width="10%"></table> <table class="test"></table> <table></table> <div width="10%"></div> i search width= in above table text. the search regular expression table[^\w]+width="[^"]+" after search result <table width="10%" class="test" style=""> </table> <table class="test" style="" width="10%"> </table> <table class="test" width="10%" style=""> </table> <table clas

jquery - JavaScript Date() returns Invalid Date -

i working on website return time since date. when call new date() parameters user has inputted, returned "invalid date". here code using: http://jsfiddle.net/8vkbu/ (the css looks bit weird in small window) why returned "invalid date", , how can fix it? thanks, fjpackard. i update js fiddle please check.. your code should following... y = parseint($("#year").val()); m = parseint($("#month").val()) - 1; d = parseint($("#day").val()); h = parseint($("#hour").val()); instead of y = parseint($("#years").val()); m = parseint($("#months").val()) - 1; d = parseint($("#days").val()); h = parseint($("#hours").val()); because input id in html form singular form but in jquery use plural form such in html use 'year' , in jquery use 'years'

Are model queries through ReferenceProperty strongly consistent in app engine? -

if have submodel connected model through referenceproperty , query submodels through modelentity.submodels, query consistent? all queries can consistent when utilising entity group (ie parent key). if reference properties within same entity group consistent. in case haven't read it, have @ https://developers.google.com/appengine/docs/python/datastore/structuring_for_strong_consistency

java - How to play, stop and pause working on media player instance in android ? -

i want develop media player type of application has 2 button 1 play , pause , 1 stop. take 2 image buttons in layout file , reference in java file , code put here, when click on stop button audio getting stopped want replay audio file; cant play play button. my java code below public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.activity_aarti_fragment, container, false); btnplay=(imagebutton)v.findviewbyid(r.id.btnplay); btnstop=(imagebutton)v.findviewbyid(r.id.btnstop); seekbar=(seekbar)v.findviewbyid(r.id.seekbar); mp = mediaplayer.create(getactivity(), r.raw.arti); btnstop.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { mp.stop(); btnplay.setimageresource(r.drawable.ic_action_play); toast.maketext(getactivity(), "stop&quo

why GPS returning the same Latitude and Longitude when at travel in Android Device? -

in app, getting location in time interval using alarm manager. here code, in locationlistenstart.java (it's broadcastreceiver class):- intent intentp = new intent(context, locationreceiver.class); pendingintent = pendingintent.getbroadcast(context, 0, intentp, pendingintent.flag_one_shot); criteria = new criteria(); criteria.setaccuracy(criteria.accuracy_fine); provider = locationmanager.getbestprovider(criteria, true); if(provider != null) { locationmanager.requestsingleupdate(criteria, pendingintent); } in locationreceiver.java:- public class locationreceiver extends broadcastreceiver { string locationkey = ""; double mlatitude=0.0; double mlongitude=0.0; public void onreceive(context context, intent intent) { locationkey = locationmanager.key_location_changed; if (intent.hasextra(locationkey)) { mlatitude = location.getlatitude(); mlongitude = location.getlongitude(); } if(locationlistenstart.l

optimization - Does if (myBool == true) differ computational wise to if(myBool)? -

i read coding style suggestion comparing bools said write if (myboolvalue == true) { ... } if (myboolvalue == false) { ... } instead of writing if (myboolvalue) { ... } if (!myboolvalue) { ... } since increases readability of code though equivalent statements . aware not usual coding practice agree may increase readability in cases. my question if there difference between 2 in regards of optimization of code execution or if (a implemented) compiler translate them same thing? the productions not same in languages. for instance, may produce different results "non-boolean" values of "myboolvalue" in both javascript , c. // javascript [] == true // false [] ? true : false // true // c #define true 1 #define false 0 int x = -1; x == true // 0 (false) x ? true : false // true (1) to see specific compiler specific programming language (there both allowed , do), check generated assembly/machine/byte code. (anyway, i pref

javascript - focus visible input by using jquery focus event -

$(document).ready(function () { $(document).on('body', function () { var visibleinput = $("input[type=text]").filter(':visible'); visibleinput.focus(); }); }); it doesn't work way wonder why. no error in console. try this $(document).ready(function(){ $("input[type=text]").filter(':visible').focus(); });

javascript - How to make capture group "absorb" whitespace before/after it without capturing it? -

i have regex expression found here . try out strings below, problem i'm facing there's whitespace located @ beginning of each captured group after 1st one. need whitespace matched don't need them captured . regex expression: ^(\/[a-za-z0-9]+)?(\s~[a-za-z]+)?([\w\s'()-]+)?((?:\s~[a-za-z]+){0,2})?$ viewing @ link above makes simpler comprehend. these strings can paste test string area 1 one: /test ~example matches ~extra ~space has ~space ~matched /like wise /and ~this take @ match groups area , notice after 1st group, 1 preceding whitespace between groups captured. what want this: for 1st , 2nd capture group, want them detect succeeding space , absorb not capture it, 3rd capture group won't detect , capture space. 4th capture group, want detect preceding space , absorb not capture it. what mean absorb space gets "removed" in sense 3rd capture group won't realize it's there. how can this? thanks. this regex c

ios - Update Coredata Attributes without Duplication -

i have 3 textfields-name,age,phone number every time entering values on each fields stored on core data also want check repetition in db, is first want check there repetition in name if repetition, check age , phone number. if age same can not change. if difference in phone number, second number replace first phone number. i tried lot.. pls me my code is nsentitydescription *entitydescc=[nsentitydescription entityforname:@"name" inmanagedobjectcontext:self.managedobjectcontext]; nsfetchrequest *request=[[nsfetchrequest alloc]init]; [request setentity:entitydescc]; nspredicate *predicate=[nspredicate predicatewithformat:@"sname %@ ",self.nametextfield.text]; [request setpredicate:predicate]; nserror *error; nsarray *matchingdata=[self.managedobjectcontext executefetchrequest:request error:&error]; if (matchingdata.count<=0) { nsentitydescription *entitydesc=[nsentitydescription entityforname:@"name" inmanagedobjectcontext:self

java - How can I print out an arraylist and also How can I add errors checks to the arraylist? -

i have been trying solve problem ages , no luck didn't progress. please me out. have created arraylist, made getter class, have made method. can add stuff array list when print arraylist out prints out random text. below arraylist created. public static arraylist<getarraylist> arraylist = new arraylist<getarraylist>(); here method; private static void addtoarraylist(string a, double no1, int no2, int no3) { try { arraylist.add(new getarraylist(a, no1, no2, no3)); } catch (exception e) { e.printstacktrace(); } } here getter class public class getarraylist { private string name; private double seconds; private int speed1; private int speed2; public string getname() { return name; } public double getseconds() { return seconds; } public int getspeed1() { return speed1; } public int getspeed2() { return speed2; }

javascript - Validating from a form -

i've asked before, didn't use real code time will. need able validate, @ least, 1 of input boxes. if it's empty says it's empty , won't open mail.php. if it's not empty open mail.php , should submit it's content in php page can processed. here's got: <!doctype html> <html> <head> <link rel="stylesheet" href="inscripcion-style.css"> <title>inscripci&#243;n</title> <link rel="icon" href="logo.ico" type="image/x-icon"> <script> function validation() { var x = document.getelementbyid("equipo").value; if (document.getelementbyid("equipo").value == "" || document.getelementbyid("equipo").value == " ") { alert("vacio"); return false; } else { alert("no vacio");

statistics - How to break the ties by increasing weight in R data frame? -

i need sort in reverse alphabetical order eye color, breaking ties increasing weight , find out who's fourth male above! aggregate have sort function? mean break ties increasing weight in r? can please provide answer example? here's data frame: jalal age sex weight eye.color hair.color 1 23 f 93.8 blue black 2 21 m 180.8 amber gray 3 22 f 196.5 hazel gray 4 22 m 256.2 amber black 5 21 m 219.6 blue gray 6 16 f 152.1 blue gray 7 21 f 183.3 gray chestnut 8 18 m 179.1 brown blond 9 15 m 206.1 blue white 10 19 m 211.6 brown blond 11 20 f 209.4 blue white 12 21 m 194.0 brown auburn 13 22 f 204.1 green black 14 21 f 157.4 hazel red 15 15 f 238.0 green gray 16 20 f 154.8 gray gray 17 16 f 245.8 gray gray 18 23 m 198.2 gray

C++: Deleting the the fields of a struct that was declared on the stack -

if declare struct such one: struct mystruct { int* nums; }; mystruct ms; ms.nums = new int[4]; do need call delete ms.nums; before exiting program or member variable nums automatically deallocated because mystruct instance ms wasn't declared on heap? yes, have delete that.. struct's default destructor won't that. delete pointer variable holds address of object , object left alone forever. better deletion inside struct's destructor struct mystruct { int* nums; public : ~mystruct() { if(nums != null) delete nums; } };

php - mail not getting sent on server -

i have 2 websites on hosted on 1 web site can send mail using php script using other web site cannot mail using php script. don't know going wrong. replaced php.ini file. there other thing left doing or something. this code $to="abc@gmail.com"; $subject="test mail"; $body="test mail"; $headers = "mime-version: 1.0" . "\r\n"; $headers .= "content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers.='from: domain <def@gmail.com>' . "\r\n"; if(mail($to,$subject,$body,$header)) { echo "mailed"; } else { echo "not mailed"; } i tried directly embedding message mail function doesn't seems working. this code after embedding message if(mail("abc@gmail.com", "test subject", "test message", "from: def@gmail.com")) { echo "mailed"; } else { echo "error:

How to restrict user to enter only two digits for Integer Field in gxt/gwt -

i want restricted user not enter more 2 digits inetger field in gxt setting maxlength attribute of dom input text element possible, use things comes gxt: numberfield<integer> nf = new numberfield<integer>(new integerpropertyeditor()); nf.addvalidator(new maxnumbervalidator<integer>(99)); any number greater 99 marked error.

Robot frame work >> jquery >> Execute Javascript command -

i using robot frame work, have grid content using jquery. have used "execute javascript" command. not recognizing jquery commands document. or window. using selenium 2. have googled last 2 days found no relevant answers. please tell me if have give new libraries or download selenium1 library instead of selenium2. error: javascript | fail | webdriverexception: message: u"unknown error: object [object global] has no method 'getelementbyid'\n (session info: chrome=32.0.1700.107)\n (driver info: chromedriver=2.8.241075,platform=windows nt 6.1 sp1 x86_64)" instead of getelementbyid try using $('#elementid')

c# - Binding Window.Title to Application method -

i'm doing following in window.loaded event. there way same through xaml instead, using {binding} or something? this.title = application.resourceassembly.getname().name; i tried following , few variations of it, don't appear work: title="{binding source=application.resourceassembly, path=getname}" you can bind method. however, effort of implementing exaggerated in comparison binding property wraps method call. documentation , guide, how bind method, can found on msdn .

sql - SQLite Full Text Search Queries With Hyphens -

i have been using sqlite (3) small website. recently, have discovered sqlite's full text search (fts) capability , leveraged simple search feature. however, user inadvertently discovered hyphen ('-') in search string wrong thing. seems indicate token following should excluded. in fact, when change hyphen plus or space, work. my questions: 1) correct in analysis? read sqlite documentation regarding fts feature , found no discussion this. 2) how should mitigate this? manually replace hyphens before passing them sqlite? a small, concrete example of i'm seeing: sqlite> create virtual table fts_table using fts4 ...> ( content text ); sqlite> insert fts_table values ("title: f-1 race (game boy)"); sqlite> insert fts_table values ("title: f-zero (snes)"); sqlite> insert fts_table values ("title: f-15 strike eagle ii (genesis)"); sqlite> select * fts_table; title: f-1 race (game boy) title: f-zero (snes) title: f

javascript - What function gets put into EventLoop in NodeJs and JS -

Image
i've been reading nodejs articles in order understand async nature during found , liked node.js, doctor’s offices , fast food restaurants – understanding event-driven programming there thing called eventloop fifo based queue. when async function gets hit, gets put eventloop , continue executed on there. i little confused here. example said here : in actuality, async functions settimeout , setinterval pushed onto queue known event loop. and in same article: the event loop queue of callback functions. when async function executes, callback function pushed queue. javascript engine doesn't start processing event loop until code after async function has executed. but different image: let's @ following example: console.log("hello,"); settimeout(function(){console.log("world");},0); so understand different explanations, first 1 says function(){console.log("world");} part of settimeout() function, callback,