Posts

Showing posts from March, 2013

sql - Inner join order by performance issue in Android 2.3 -

i have used sql select query in android app works fine on newer versions of android i.e takes 30 40 seconds on samsung galaxy tab( android 4.0.3) retreive data sqlite database, on device older version of android 2.3 takes 18 minutes retreive data. if remove "order x_unitperson.unitseq" performance not decreases on android 2.3. how can increase performance on android 2.3 without removing order clause. my sql is: select person_id, commander, citizen, rank, given, surname, isor, (select group_concat(name_short, '\n') units inner join (select * x_unitperson person_id = people.person_id order x_unitperson.unitseq) xunits units.unit_id = xunits.unit_id) name_short, (select fname photos person_id = people.person_id) fname people order surname, given i not familiar sqlite optimiser, if correlated subquery rewritten join optimisers create same execution plan both que

InputDialog/MessageDialog with a textbox in C# XAML Windows store app -

i'm trying create messagedialog textbox allows user enter word didn't find how have do.can me? ps: red callisto can didn't find how. thanks.. you're correct callisto have control customdialog pretty need. there's example app callisto, xaml you're looking in mainpage.xaml .

visual studio 2010 - (boost) cannot open file 'boost_python-vc100-mt-gd-1_53.lib' -

so, downloaded boost_1_53_0, , ran bjam . after linking "libraries" , "includes" per preamble, ran visual c++ solution , following error link : fatal error lnk1104: cannot open file 'boost_python-vc100-mt-gd-1_53.lib' i read solutions executing bjam --build-type=complete --toolset=gcc stage , seems command prompt cannot recognize bjam , though added path system variables as, variable name: bjam variable value: d:\boost_1_53_0\ but still cannot bjam running in command prompt! thanks

implement SLComposeViewController into Cocos2d -

i can't seem slcomposeviewcontroller come button on cocos2d layer. if see stop working please tell. appreciated: n.b. viewcontroller uiviewcontroller -(void)sceneselect { nsstring *message = [nsstring stringwithformat:@"twitter message"]; nsstring *servicetype = [nsstring stringwithformat:@"slservicetypetwitter"]; if ([slcomposeviewcontroller isavailableforservicetype:servicetype]) { slcomposeviewcontroller *tweetcontroller = [slcomposeviewcontroller composeviewcontrollerforservicetype:servicetype]; [tweetcontroller setinitialtext:message]; tweetcontroller.completionhandler = ^(slcomposeviewcontrollerresult result){ if (result == slcomposeviewcontrollerresultdone){ //nslog call } else if (result == slcomposeviewcontrollerresultcancelled){ //nslog call } [viewcontroller dismissviewcontrolleranimated: yes completion: nil];

parsing - parse into database from javascript form -

i have webpage form processed javascript code. there form button javascript onclick() method. here webpage ( czech declensions ) on input have list of names in mysql database. need put single name form list form, click on button invoke onclick() method , on output want have name declension (field 5. vokativ in form) - insert database table. action in cycle each name list form database. please, suggestions how can done? i recommend ajax trick.. with jquery done pretty easy if understand right. it this: $.ajax({ url: "validate.php?info=something&otherinfo=somethingelse" }).done(function() { alert('done'); }); you informations doing this: var = $('input[name=something]').val(); then make php page handle informations. hope helps.

linux - Is "epoll" faster than "select" even when there is only one connection? -

i have tried in way:create server , client in same pc , , send packet client server.once server side receive packet , sends same packet client . looped 1000,000 times , total consumed time , take average . surprise, avg latency 'select' 33 micro secs while latency 'epoll' 10 micro secs. since set 1 connection , did not expect 'epoll' latency shorter . reasonable ? thanks.

java - jUnit comparing XML strings fails even though the XMLs are the same -

i writing series of junit tests ensure proxy servlet fetches xmls client page variety of sources. one of tests send request servlet fetch xml , compares local copy same (i think) i examined length of each xml quite interesting. local copy length = 1753 remote version length = 1796 i using asserttrue() asserttrue(remote.equals(local)); any ideas why there difference in length, there way in junit can compare xmls ensure expected , syntactically correct? any other suggestions welcome? on question of better ways compare xml's - have used xmlunit , feel works out well.

java - JSch to use Unix Remote Server Environment Variables -

i'm using jsch connect java remote unix server. next step run shell script (.sh) makes use of internal environment variables. on executing shell script directly terminal works fine, calling java program via jsch not recognize these variables. how work around this. less experienced on java. posting sample code- jsch jsch = new jsch(); session session = jsch.getsession("username", "server", 22); userinfo ui = new sftpuserinfo(); session.setuserinfo(ui); session.setpassword("mypass"); session.connect(); channelexec channelexec = (channelexec)session.openchannel("exec"); inputstream in = channelexec.getinputstream(); channelexec.setcommand("sh /filepath/myshellscript.sh"); channelexec.connect(); bufferedreader reader = new bufferedreader(new inputstreamreader(in)); string line; while ((line = reader.readline()) != null) { system.out.println(line); } ps:

Facebook "via appname" not clickable on profile feed -

Image
i have application uploads link , photos facebook. have linked app facebook page in app settings @ developer.facebook.com. there 2 scenarios. 1) when upload link text. "via < appname >" clickable both home , profile . [fb requestwithgraphpath:@"me/feed" andparams:[nsmutabledictionary dictionarywithobjectsandkeys: [[self.recipedetails objectforkey:@"source"] objectforkey:@"sourcerecipeurl"], @"link",fbtextview.text, @"message", nil] andhttpmethod:@"post" anddelegate:self]; 2) when upload photo text. "via < appname >" clickable home feed not profile feed. [fb requestwithgraphpath:@"me/photos" andparams:[nsmutabledictionary dictionarywithobjectsandkeys: imagedata,@"source",fbtextview.text, @"message", nil] andhttpmethod:@"post" anddelegate:self]; is actual scenario or missing something. please help. have tried checking out setting on

Android Listview row's ImageView OnClick delay -

similar this thread , i'm having delay in click response of view inside listview's row. also, click listener fired when view outside listview gained focus. my question is, there other way solve this, apart ditching listview altogether, suggested on link above? i had come same issue , solved of others. it seems used hash array save listview rows in order avoid inflate new view multiple times while implementing getview() method. however using hash array make listener's status mess cause problem described. so delete hash array , return row view in getview() method.

java - pass query string values in string array -

i getting problem while passing query string values in string array. statements following. words[0]=request.getparameter("word1"); words[1]=request.getparameter("word2"); the above statements gives me exception , giving value 0. please me in regard. thanks in advance. possible solutions/causes: make sure array initialized : string[] words = new string[2] . make sure have input element inside form submitted.

web applications - Web development for iPads - do you need a Mac -

i have project coming focused on making large amount of legacy code (classic asp , .net webforms) ipad compatible, , wondering whether or not need on mac seeing cannot date safari browsers on windows machine. code in question works in chrome, firefox , ie (6-10) wouldn't need tweaking make work in ipad. fyi have access ipad testing. have done research online , on top of experience recon can develop web standards , should work fine on ipad. basically want know if it's worth me getting mac this, or whether bit of waist hunch. you pretty need use xcode build app, mac software. yes, need mac.

php - jQuery validation form issue -

Image
i use following code in order know if username present in database. i'm using jquery validator, , configure script in way: $(document).ready(function(){ // validate // http://bassistance.de/jquery-plugins/jquery-plugin-validation/ // http://docs.jquery.com/plugins/validation/ // http://docs.jquery.com/plugins/validation/validate#toptions $('#profile').validate({ rules: { name: { minlength: 2, required: true }, username: { minlength: 2, required: true, remote: "../check-username.php" } }, highlight: function(element) { $(element).closest('.control-group').removeclass('success').addclass('error'); }, success: function(element) { element .text('ok!').addclass('valid') .closest('.c

excel - Automatic Calculation Turned Off by VBA Macro -

this more of curiousity urgency: have following code repeated several times in larger macro. finding if specify search method (by including "engine:=..") macro turns off automatic calculation (found in formulas>calculation options ) , switches manual. fixes optimsation @ single point, though below optimisation on loop optimises different values. cells linked each other not update because of problem renders optimisation useless. can run macro without specifying search method ideally able choose it. ideas? solverreset solverok setcell:="$k$21", maxminval:=1, valueof:="0", bychange:="$d$41:$h$41", engine:=2 solveradd cellref:="$k$25", relation:=2, formulatext:="1" solveradd cellref:="$d$41:$h$41", relation:=3, formulatext:="0" solveradd cellref:="$d$41:$h$41", relation:=3, formulatext:="$d$12:$h$12" solveradd cellref:="$d$41:$h$41", relation:=1, form

Service builder doesn't build services for new entities added Liferay -

i have service builder , there few entitties. when try add more entities service builder , try build services, services new entity not getting created. what should possibly problem , how tackle it? another problem facing newly created portlets not shown in control panel. earlier never had such problems. don't know has happned. tried restarting server,refreshing workspace no use. edited: console output [console output redirected file:d:\test\mis\.metadata\.plugins\com.liferay.ide.eclipse.sdk\sdk.log] buildfile: d:\mis_portal\liferay-plugins-sdk-6.1.1\portlets\misportal-portlet\build.xml build-service: [echo] loading jar:file:/d:/test_mis_portal/liferay-portal-6.1.1-ce-ga2/totestt-7.0.27/webapps/root/web-inf/lib/portal-impl.jar!/system.properties [echo] apr 25, 2013 10:34:16 com.liferay.portal.kernel.log.jdk14logimpl info [echo] info: global shared lib directory /d:/test_mis_portal/liferay-plugins-sdk-6.1.1/lib/ [echo] apr 25, 2013 10:34:16 com.lif

vector - Are bulk array operations faster than sequential operations? -

say given array, , function called replace : void replace(from, to, items[]) whose job replace array elements in range [from, to) elements in items . i'll assume maximum size of array known beforehand, can ensure array never overflow. my question is, if given list of replacements (e.g. elements of form (from, to, items) ), possible me obtain final resulting array faster time complexity performing each operation sequentially? in other words, there advantage knowing sequence of operations beforehand, or no better being given each operation 1 one (in terms of asymptotic time complexity)? note: seems question confusing; did not intend imply number of elements replacing given range same size of range! fewer or more, causing shifting, , point of question was ask if knowing them beforehand avoid work shifting in worst case. i think may not finding, using rope can shorten time-complexity. provides operation on string concat without "shift"ing actual a

How using permalinks tags ID in wordpress -

how using permalinks tags id in url wordpress example: wordpress.com/tag_name i : wordpress.com/tag_id not sure you're asking if change structure of permalinks, go wp-admin , go to: settings > permalinks you may want check out yoast's wordpress seo plugin gives more control on permalink structure.

bash - grep-ing a variable vs. a file - execution time -

made interesting observation - storing output of curl statement in text file , grep-ing strings. later changed code store output variable instead. turns out, change caused script run slower. counter intuitive me since thought i/o operations more expensive in-memory operations. here code: #!/bin/bash url="http://m.cnbc.com" while read line; ua=$line curl -s --location --user-agent "$ua" $url > raw.txt #raw=`curl --location --user-agent "$ua" $url` l=`grep -c -e "advertise us" raw.txt` #l=`echo $raw | grep -c -e "advertise us"` m=`grep -c -e "id='menu'><button>menu</button>" raw.txt` #m=`echo $raw | grep -c -e "id='menu'><button>menu</button>"` d=`grep -c -e "careers" raw.txt` #d=`echo $raw | grep -c -e "careers"` if [[ ( $l == 1 && $m == 0 ) && ( $d == 0) ]] ac="legacy" elif [[ ( $l == 0

javascript - Searching through JSON objects with input from HTML input -

i have json file using jquery. i know how search through items , items related html input. this tried: function search(form) { $(".products").empty(); $.getjson('products.json', function(data) { $(data.products).each(function(index, item) { if(form == item.name) { var input = document.getelementbyid('searchform'); $('<div/>', {'class':'productname'}).text(item.name).append( $('<div/>', {'class':'productdetails', text:'album: '+item.album}), $('<div/>', {'class':'productdetails'}).append($('<img>').attr({src:item.source,title:item.name,alt:item.name,class:'productimage'})), $('<div/>', {'class':'productdetails', text:'genre: '+

json - Javascript Convert String to Array of Objects -

i have nodejs app accepts a string (uploaded input !) have no control on input merely building rest service processes data. that string meant array of json objects can loop through extract each element ... i'm receiving following (as string): [ {name: 'jane', id: '005b0000000mga7aag'}, {name: 'tom', id: '005b0000000mga7aaf'} ] when try json.parse get syntaxerror: unexpected token n understandably so, because know invalid json whereas this next string valid json , passes http://jsonlint.com/ : [ {"name": "jack", "id": "005b0000000mga7aaa"}, {"name": "jill", "id": "005b0000000mga7aab"} ] my question is: how can accept first input , parse allow: parsed[0]['name'] == 'jane' >> true my first instinct string replace keys (e.g. name "name") , try parsing it. if else h

zend framework - how to create a Zend_Db_Table_Select through a string query php -

i have been taking look, if there way create zend_db_table_select or zend_db_select instance literal sql query. mean, i've got complex query , want through query create object of one. have been reading docs classes , didn't find anything. guess not possible. do know it? thank much. i think best bet write in model: public function customquery ($table, $id) { return $this ->getdefaultadapter() ->query("select * ? id = ?", array($table,$id) ) ->fetchall() ; } and 1 more link useful you

javascript - Resetting specific form in popup div -

i have page lists entries made user link each call function opens edit page in pop-up div. the edit page contains form update , reset buttons whenever select reset button return form initial state nothing happens. i've had online last couple of days try , more understanding of might causing it's javascript function called on clicking of reset button ignores document.getelementbyid(form).reset() command there no javascript error returned. here sample of code on parent.cfm <script language="javascript" src="functions.js" type="text/javascript"></script> <table border="0" cellspacing="5" cellpadding="0" width="850"> <form action="##" method="post" name="parentform" id="parentform"> <input type="hidden" name="formsubmitted" id="formsubmitted" value="1" /> <tr> <td>l

mysql - Where would tables that are not normalised be applicable? -

is ever best practise or recommended use table of following? id, uid, fieldname, fieldvalue 4, 12, gender, male 5, 12, age, 21-30 6, 12, location, 5 7, 13, gender, female 8, 13, age, 31-40 9, 13, location, 5 10, 14, gender, female 11, 14, age, 31-40 12, 14, location, 6 13, 15, gender, male 14, 15, age, 21-30 15, 15, location, 7 it not normalised , cannot specify data type of field. would following not better id, uid, gender, age, location 4, 12, male, 21-30, 5 5, 13, female, 31-40, 5 6, 14, female, 31-40, 6 7, 15, male, 21-30, 7 i want know if can ever justify having such table in database, know first method may easier add more fields (instead of altering database) , remove null values. however 1 cannot specify datatype , have convert string every time want use data. so there ever scenario first table considered best practice or solution? working on system uses method make lose sanity. complexity of queries re

wpf - change control template based on current theme -

unfortunately had override control template of 1 of tabcontrol s in application because needed slight modification on , feel couldn't done otherwise. <tabcontrol name="specialtabcontrol" template="{staticresource specialtabcontroltemplate} />". all looks fine until switch theme of os. tabcontrol looks totally rubbish because uses control template of wrong theme (the theme based control template on, extracted blend). so guess need find way provide 4 control templates (luna, aero, xp, classic) special tabcontrol need selected according current os theme. so how can provide , apply different custom control templates specialtabcontrol based on current theme, when user switches theme of os, specialtabcontrol switch control template have provided theme? please note have other tabcontrol s in application not have override control template , should have standard control template theme. i think need see themes in wpf application. assembly

c# - Error in MySQL syntax when adding object to objectcontext -

i seem have trouble adding objects tables have 'n n' relationship. tables defined follows: table a id (primary) ... ... ... table b id (primary) ... ... ... table c tablea_id (index) tableb_id (index) so table c links table , b, ids. using entity framework have object tablea containing entity collection of tableb entities. however when add existing object of type tableb tablea.tablebs entity collection property, receive exception: you have error in sql syntax; check manual corresponds mysql server version right syntax use near '(select\n tablec . tablea , \n ' @ line 1 it seems i'm trying normal / common thing, i've not been successful getting work. c# code: var database = new databaseentities(); var tableaobject = database.singleordefault(e => e.id == 1); var tablebobject = database.singleordefault(e => e.id == 1); tablea.tablebentities.add(tablebobject); database.savechanges(); apparently i'm

android - Issue when playing video in local and url path -

i play video in videoview when play sd card, shows correct width , height in full screen. when try play server, video width smaller , video re-sized. how can play video in original size , full screen? take @ documentation , implement onprepared method following code: //prepare video public void onprepared(mediaplayer mp) { progressbarwait.setvisibility(view.gone); //first size of video int videowidth = player.getvideowidth(); int videoheight = player.getvideoheight(); float videoproportion = (float) videowidth / (float) videoheight; //get size of screen int screenwidth = getwindowmanager().getdefaultdisplay().getwidth(); int screenheight = getwindowmanager().getdefaultdisplay().getheight(); float screenproportion = (float) screenwidth / (float) screenheight; //adjust layoutparams lp = surfaceviewframe.getlayoutparams(); if (videoproportion > screenproportion) { lp.width = screenwidth; lp

ide - Chrome JetBrains plugin wont be recognized by WebStorm 6.0 -

Image
i've tried solve long now. i've installed plugin chrome store plugin button in browser grayed out , says " not connected " on hover. when debug in ws popup: i've seen section on jb site there utterly poor, , doesn't mention problem plugin , ide not recognizing eachother. i've looked on other posts here similar problems, though revolved around liveediting, , haven't found there problem. can please give me sequence of steps perform check problem syncing between ide , chrome plugin? edit : the jb console empty when open it: right click jetbrains chrome extension select "options" set host: 127.0.0.1 set port: 63343 click "apply" you're ready go

php - split at the first space in a string -

i have string this: red yellow blue and want array : array ( [0] => red [1] => yellow blue ) how split @ first space in string ? code doesn't work <?php $str = "red yellow blue"; $preg = preg_split("/^\s+/", $str); print_r($preg); ?> please me. use explode limit: $array = explode(' ', $string, 2); just side note: 3rd argument of preg_split same 1 explode , write code well: $array = preg_split('#\s+#', $string, 2); references: php: explode php: preg_split

pom.xml - Including a jar in maven local repository -

i want include jar in local repository(google-api-java-client 1.6.0-beta). include need write in pom.xml, while try include , not getting included in local repository. below pom.xml of project: <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <!-- basics --> <groupid>com.google.trypredictionjava</groupid> <artifactid>gae-java</artifactid> <version>1.0-snapshot</version> <packaging>war</packaging> <name>try-prediction-java</name> <pluginrepositories> <pluginrepository> <id>maven-gae-plugin-repo</id> <name>maven-gae-plugin repository</name> <url>

java - how to fetch data from google app engine datastore in android -

i'm new google app engine , follow it's documentation @ https://developers.google.com/appengine/docs/ carefully.now i've stored data on google app engine store creating web application in eclipse example store first , last name of employee @ gae store like datastoreservice datastore = datastoreservicefactory.getdatastoreservice(); entity employee = new entity("employee"); employee.setproperty("firstname", "antonio"); employee.setproperty("lastname", "salieri"); date hiredate = new date(); employee.setproperty("hiredate", hiredate); employee.setproperty("attendedhrtraining", true); datastore.put(employee); and i've deployed project gae want stored data data store in android app. possible that. me appreciated. thanks! there different approaches problem. create kind of services, in json format , you'll able interact android app google app engine using http requests. better

Django's FileField (or ImageField) on Google App Engine -

gae doesn't allow read/write file system, django's filefield (or imagefield) using (via filesystemstorage class). i thinking implementing custom django storage, gae blobstore seems incompatible django requirements. specifically, gae blobstore assume direct upload client store, while django custom storage need implement _save(name, content) method. as far can see no 1 refer missing implementation. there custom storage projects out there (most notably: django-storages on bitbucket), implementations s3, windows azure, dozens of other backend, nothing google. what direction should take have filefield in model, hosted on google app engine? to clarify: - i'm using stocked, trunk, 1 uses google cloud sql django comes google sdk - i'm not using django nonrel. - i've followed django guide google documentation. blobstore support writing files feature. see writing file blobstore . therefore possible implement _save(name, content) blobstore now. another

how to run svm light in java eclipse? -

i have downloaded jni_svm-light-6.01-64bit version running svm in java. have tried searching online did not figure out steps run library using eclipse ide java. want know how provide input training file train model, , give test file corresponding results? step step instruction using eclipse ide helpful. another way run svmlight java code in eclipse using cleartk . allows standardized way provide data , results not svmlight, other models such crf.

php conditional operator not transient -

i having bit of trouble wrapping head around this, thought ask it.. i have code: $x="string"; var_dump($x==0); //says true var_dump($x==true); //says true var_dump(true==0); //says false what understand is: in 1, `string` gets converted number, becomes `0` condition true in 2, `string` value, condition true in 3, `true` not equal `0` condition false individually make sense, in sequence don't! have heard many people because conditional operator in php not transient . can explain means, , how make sense of this? why in world wouldn't make sense? never change value of x , statements dependent on original value of x "string". you assuming x changed 0 in first var_dump not. merely compared 0/false. statement perform variable change think happening: var_dump(($x = 0) == 0); or: var_dump(($x = false) == 0);

parsing - .NET method to parse String with Long type qualifier -

i string 3rd party sw long type qualifier, e.g. "1l". want parse int64, int64.tryparse not recognize int64. there .net method safely? want avoid parsing myself... thanks help! in simplest case, can this: string snum = "1l"; int pos = snum.indexof('l'); if (pos == snum.length-1) { snum = snum.substring(0, snum.length-1); } long num = int64.parse(snum);

ios - How to limit text length to fit width of dynamically created UITextField -

i have dynamically created uitextfields have different widths , font sizes. know how limit length of text in uitextfield , can fixed characters number. need dynamically limit characters number fit uitextfields . suppose every time new character typed should use cgsize , text length font size compare uitextfield width , limit characters number if exceeded uitextfield width. unfortunately not sure how start it. know code snippets me? you can start code: - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinrange:(nsrange)range replacementstring:(nsstring *)string { nsstring *text = textfield.text; text = [text stringbyreplacingcharactersinrange:range withstring:string]; cgsize textsize = [text sizewithfont:textfield.font]; return (textsize.width < textfield.bounds.size.width) ? yes : no; } after ios 7 changes sizewithfont sizewithattributes. here code changes: - (bool)textfield:(uitextfield *)textfield shouldchangecharactersinran

javascript - Responding to an HTML element to change background and text of a DIV using jQuery -

i have element returns value of either true or false when run $('#myid').val() . once true or false returned, want have particular div change background color green true or red false. if ($('#myid').val()) { code should return div text , green background } else { code should return div text , red background } you have convert string bool evaluate properly. have button in fiddle return value. jsfiddle html: <div id="mydiv"> <input id="myid" value="false"/> <input id="mybtn" type="button" value="submit"/> </div> jquery: $('#mybtn').on('click', function () { $('#mydiv').css('background', (($('#myid').val() == "true") ? 'green' : 'red')); });

java - Logic flow for android game -

hi i'm new android game development , i'd ask guys regarding correct logic flow android game of mine. here's game. it's pretty simple game user has choose correct color. game has 3 stages. in each stage, has 10 questions. in each question, has 30 seconds timer. question , choices, of course needs randomized. if user chooses correct color, proceed next question. if user chooses wrong color, he/she has 3 trials choose, if he/she reaches 3rd trial, game over , display try again button. here's piece of code tried: // created custom countdown timer c/o counter = new mycount(30000,1000); counter.start(); // call correct object getcorrectobject(); @override public void onclick(view v) { // todo auto-generated method stub switch(v.getid()){ case r.id.pause: if(mlastresourceid == r.drawable.pause){ pause.setimageresource(r.drawable.resume); mlastresourceid = r.drawable.resume; count