Posts

Showing posts from April, 2013

php - Best way to receive variables from database -

i have custom wordpress table following contents: account_info id | account_id | wp_title | wp_url 1 | 12345 | website | website.com what best (or fastest) way results? option 1: global $wpdb; $sql = "select id, wp_title. wp_name account_info"; $results = $wpdb->get_results($sql); if(!empty($results)) { foreach($results $r) { $id = $r->id; $wp_title = $r->wp_title; $wp_name = $r->wp_name; } } option 2: $id = $wpdb->get_var("select id account_info"); $wp_title = $wpdb->get_var("select wp_title account_info"); $wp_name = $wpdb->get_var("select wp_name account_info"); when talking "best" , "fastest" - these aren't things need take consideration. readibility key future developers looking @ code. option 1 shows that, if result set isn't empty, loop around them , set variables. option 2 framework specific , , isn't b

android - Cannot save previous data on a table with values -

public void move_to_another_fragment() { fragment fragment = new itemfragment(); fragmentmanager fragmentmanager = getfragmentmanager(); getactivity().getactionbar().settitle("items"); fragmentmanager.begintransaction() .replace(r.id.frame_container, fragment).addtobackstack(null) .commit(); } i used above code move fragment b fragment a.in fragment have table data when come frgment , move frgmant b need show table previous value.can explain how start fragment b previous data you can save data of fragment before changing fragment b. , in createview function of fragment b. use data saved fragment generate view of fragment b. as activity same across both fragments, can store data in class variable of activity. hope helps.

c# - Add image to Crystal Report using return path from database -

i have crystal report. need add logo image report using path return stored procedure. this thread might old can someone. 1) if path static (means everytime not going changed based on condition), drag , oled object on report , in format object option of same (oled object), specify path of image. 2) can assign path parameter value if need change value database. assign path of database parameter , parameter bind path object.

Mongodb : How to find documents in which fields match an ObjectId or a string? -

i have documents in collection in mongodb : {_id : objectid('533af69b923967ac1801e113'), fkey : '533aeb09ebef89282c6cc478', ... } {_id : objectid('5343bd1e2305566008434afc'), fkey : objectid('5343bd1e2305566008434afc'), ...} } as can see field fkey can set string or objectid . i documents match '533aeb09ebef89282c6cc478' or objectid('5343bd1e2305566008434afc'). but if run : db.mycollection.find({fkey : '533aeb09ebef89282c6cc478'}) i first document of collection. is there way configure mongodb in order documents match request without checking type ? thanks help. pierre there 2 options here. you use mongo's $or operator : db.mycollection.find({ $or: [ { fkey: '533aeb09ebef89282c6cc478' }, { fkey: objectid( '533aeb09ebef89282c6cc478' ) } ] }) the $or operator performs logical or operation on array of 2 or more <expressions> , selects documents sa

java - XML serializer error -

i getting following error when prepare document , return. please find code below public static document requestparammissing (string params, string codeexception, string message, string apimethod, exception e, subscriberid, string udid, stringbuilder listparams, string requestid, string apiurl){ document doc = null; string errorcodenumber = ''; documentbuilderfactory docfactory = documentbuilderfactory.newinstance(); documentbuilder docbuilder = docfactory.newdocumentbuilder(); doc = docbuilder.newdocument(); element rootelement = doc.createelement("error"); doc.appendchild(rootelement); element errorcode = doc.createelement("code"); element errormessage = doc.createelement("message"); if(codeexception.equals('requestexception')){ errorcodenumber = '1000'; errorcode.appendchild(doc.createtextnode('1000')); errormessage.appendchild(doc.createtext

html - Level 2 submenu always visible -

i have spent whole day looking through various examples , still can't figure out way of setting 2 level submenu invisible. got template of net , trying customise it. here navigation bit css file (i know looks ugly ): ) #navigation { height: 35px; line-height: 35px; float: right; position: relative; z-index: 20; } #navigation ul { list-style: none; list-style-position: outside; font-size: 13px; text-shadow: rgba(255,255,255,0.5) 0px 1px 1px; } #navigation ul li { float: left; position: relative; padding-right: 2px; background: url(images/navigation-border.png) no-repeat right 0; } #navigation ul > li.last { background: transparent; width: auto; float: left; padding-right: 0; } #navigation ul > li.last { border-radius: 0px 5px 5px 0px; -moz-border-radius: 0px 5px 5px 0px; -webkit-border-radius: 0px 5px 5px 0px; -o-border-radius: 0px 5px 5px 0px; border-right: 1px solid #d7e1e8 !important; } #navigation ul > li.first { border-radius: 5px 0px 0px 5px ; -moz-border-radi

Multiple fadeIn/fadeOut effects in one audio file with ffmpeg -

i have problem add several fade effects 1 audio file. when try use command this: ffmpeg -y -i /home/user/video/test/sound.mp3 -af "afade=t=in:ss=0:d=3,afade=t=out:st=7:d=3,afade=t=in:st=10:d=3,afade=t=out:st=17:d=3,afade=t=in:st=20:d=3,afade=t=out:st=27:d=3" /tmp/test.mp3 then output audio file has fadein , fadeout applied once. next effects don't applied. there possible way apply several fade effects same audio file? also, difference between ss , st parameter in command? take here: ffmpeg volume filters volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame complete command: ffmpeg -i movie.wav -filter volume='if(lt(t,10),1,max(1-(t-10)/5,0))':eval=frame modified-movie.wav

c# - Passing action and controller values from view to another partialview -

i have multiple index views different grid in each of these views, of them uses same popup control. dont want make partial view foreach index view have. put popup partial view in shared folder. but have html.beginform('action','controller') in popup partialview, , these values different in each grid. how can pass these view of grid partial view of popup? the grid view: //code resumed @html.devexpress().gridview( settings => { settings.name = "testmastergrid"; settings.column.add("id"); settings.column.add("name"); settings.column.add("email"); //command column wich calls popup control } the popup partialview: //code resumed using (html.beginform("actionineedtogetfromthegridview", "controllerineedtogetfromthegridview", formmethod.post)) { html.devexpress().textbox( textboxsettings => { text

Concat two ByteBuffers in Java -

how can concat 2 bytebuffers 1 bytebuffer? the following doesn't work: bytebuffer bb = bytebuffer.allocate(100); bytebuffer bb2 = bytebuffer.allocate(200); bb.allocate(200).put(bb2); system.out.println(bb.array().length); the length of bb still 100 . something bb = bytebuffer.allocate(300).put(bb).put(bb2); should job: create buffer large enough hold contents of both buffers, , use relative put-methods fill first , second buffer. (the put method returns instance method called on, way)

c++ - how to return index of element in vector -

given vector vector<classx *> myvec; how return index i of 1 of elements in following function; size_t nearestelement(classy const& p){ size_t i(0); double d = distance(myvec[i]->position(), p); (auto const& element : myvec){ if(distance(element->position(), p) < d){ = ???; // index of current element } return i; } } where position() function defined in classx , distance not std::distance function, function defined self. change range based regular for, or add indexing variable current for: int index = 0; (auto const& element : myvec){ if(distance(element->position(), p) < d){ = index; // index of current element } index++ ...

spring - Swagger endpoint not accessible -

i have spring mvc project uses gradle build project. i used steps described here in project. the build.gradle file has following entry swagger: compile (libraries.swagger){ exclude group:'org.slf4j', module:'slf4j-log4j12' exclude group:'org.slf4j', module:'slf4j-api' exclude group:'junit', module:'junit' } the configuration swagger done in project build.gradle below: swagger: "com.knappsack:swagger4spring-web:0.3.3" my controller documetation end point is: import com.knappsack.swagger4springweb.controller.apidocumentationcontroller; import com.wordnik.swagger.model.apiinfo; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; /** * example of how might extend apidocumentationcontroller in order set * own requestmapping (instead of default "/api") among other po

eclipse - LibGdx getUserData() method -> PC CPU 100% -

okay haven't seen that. i'm doing game in libgdx. i've set up, contact listener on world object have 4 methods in class ( begin contact, end contact, presolve, postsolve) @override public void begincontact(contact contact) { fixture f1 = contact.getfixtureb(); float fl = (float) f1.getbody().getuserdata(); // more code goes here } if run game, cpu increase around 8%. if run second time go around 20%, third time around 30% , 100% ( closed instances of game ). game not running cpu stay @ 100%. can fix closing , reopening eclipse. i went step step in code , if comment line float fl = (float) f1.getbody().getuserdata(); everything works okay. if run 10 instances of game @ same time, cpu won't go above 30%. any ideas? my computer specs: intel pentium quadcore q6600 2.4ghz, 4gb ram... it's not possible process keep running, after you've terminated it. it might close w

android - How to get attributeset value as "@color/desktop_purple" -

i have 2 apks, such packagea, packageb; meanwhile create custom-view named homesuite here xml layout: <linearlayout style="@style/page_linearlayout" android:layout_margintop="@dimen/hometopfragment_layout_margintop" android:layout_weight="16" > <com.my.example.view.homesuite android:background="@color/desktop_purple" android:layout_marginright="2dp" android:layout_weight="1" /> <com.my.example.view.homesuite android:background="@color/desktop_grey" android:layout_marginright="2dp" android:layout_weight="1" /> <com.my.example.view.homesuite android:background="@color/desktop_light_green" android:layout_weight="1" /> </linearlayout> here constructor: public homesuite(context context, attributeset attrs, int defstyle) { super(context, attrs, defst

ssrs 2008 - sql reporting services how-to: mask a parameter -

i have requirement allow users pull report customers using customer's credit card number parameter. security want mask field, common on many e-commerce sites. i'm pretty sure not out-of-the-box capability of reporting services. i'm hoping can accomplished adding vb report. not sure though. anyone have idea how can done in reporting services? as far know there no masked input parameters in ssrs 2008. i'm not sure if custom code way go. haven't wold how you're delivering reports, custom app or website reportviewer may best bet solution. in addition reportviewer control, can place own (masked input) controls user input parameter , send value in code behind. an important note though, think how deal credit card numbers. ask questions this one (top comment: "if have ask question, shouldn't storing credit card numbers. outsource if @ possible ") on our sister site security.stackexchange.com if you're unsure. in case, know ssrs i

load balancing - Windows NLB not balanced -

i set nlb cluster given 2 servers (ws 2008 r2). each server has 1 nic card set static ip address. assigned cluster internet name (mycluster), , assigned static ip address. third box acting client sending tcp data (over wcf) cluster's ip configured (static ip). observing nlb cluster nlb manager @ 1 of nodes - both nodes green, started. however, able see traffic coming in 1 of nlb servers. when suspend it, see traffic going other nlb server, , on. expecting traffic split equally between them. can't figure out missed, tips please? if need more detailed information please ask, not sure how detail put in here. thanks/. by default, port rule created filtering mode of multiple host use single affinity. in other words, multiple requests same client directed same host. see traffic going both hosts try accessing cluster multiple clients. set affinity "none", can lead other problems. there's information on affinity parameter , how use in nlb file.

java - How to handle a static final field initializer that throws checked exception -

i facing use case declare static final field initializer statement declared throw checked exception. typically, it'd this: public static final objectname object_name = new objectname("foo:type=bar"); the issue have here objectname constructor may throw various checked exceptions, don't care (because i'd know name valid, , it's allright if miserably crashes in case it's not). java compiler won't let me ignore (as it's checked exception), , prefer not resort to: public static final objectname object_name; static{ try{ object_name = new objectname("foo:type=bar"); }catch(final exception ex){ throw new runtimeexception("failed create objectname instance in static block.",ex); } } because static blocks really, difficult read. have suggestion on how handle case in nice, clean way? if don't static blocks (some people don't) alternative use static method. iirc, josh bloch reco

ios - Bounds vs Frame when making a custom view and initializing it -

i'm having difficulties understanding difference, , when use what. i know textbook definitions. have searched lot regarding topic. answers here on helpful extent, feel still don't understand properly. let's have acustomview.m, , when place ui elements within view, use bounds, makes sense because it's in it's own coordinate system, but, when initialize view using initwithframe: in view-controller, should use self.view.frame or self.view.bounds ? both work, different results. i want understand this, appreciated. the bounds of uiview rectangle, expressed location (x,y) , size (width,height) relative own coordinate system (0,0). the frame of uiview rectangle, expressed location (x,y) , size (width,height) relative superview contained within. so difference question of representation.

c# - Yield return request never returns -

currently i'm having problem courotine. yield return never goes anywhere.. doesn't want return in webplayer build. in editor works fine, no problems yielding @ all. ienumerator i'm starting. public ienumerator createchannel(string channelname) { string urlrequest = "http://hiddenforsecuritypurposes.com/game/addchannel.aspx?channelname=" + channelname; www request = new www(urlrequest); yield return request; //it never reaches here.. runs ienumerator, yield return never returns itself. print("it got yielded"); } again, quick note. work out in editor, not in webplayer, i'm exporting game to. is webplayer , domain trying reach on same url/server? if not, need put crossdomain.xml root of server trying reach. in case http://hiddenforsecuritypurposes.com/crossdomain.xml

assembly - Difference between memory and register -

i saw assembly code like, mov [eax], ebx the above line, mentioned [eax] memory , ebx register. so, here difference between [eax] , ebx . happen in above instruction. in syntax, brackets around register means memory location used (as source or destination, according instruction) starting address specified @ register (eax in case). example, if eax contained 1344 before instruction, value ebx copied logical memory addresses 1344-1347 (because 4 byte copying). i hope enough untangle them in mind:) , please notice more complex cases possible (e.g. mov [eax+ecx],ebx forms destination address sum of 2 register values).

CouchDB not Working on Android Emulator -

i making android app uses couchdb database storage.i able run app on real device,but when run app on emulator force closes error messages as:- 04-23 10:37:12.810: d/dalvikvm(319): vfy: dead code 0x0005-0036 in lcom/couchbase/lite/storage/sqlitestorageenginefactory;.createstorageengine ()lcom/couchbase/lite/storage/sqlitestorageengine; 04-23 10:37:12.820: d/androidruntime(319): shutting down vm 04-23 10:37:12.820: w/dalvikvm(319): threadid=1: thread exiting uncaught exception (gro up=0x4001d800) 04-23 10:37:12.840: e/androidruntime(319): fatal exception: main 04-23 10:37:12.840: e/androidruntime(319): java.lang.noclassdeffounderror: java.util.serviceloader 0 4-23 10:37:12.840: e/androidruntime(319): @ com.couchbase.lite.storage.sqlitestorageenginefactory.createstorageengine(sqlitestorageenginefactory.java:25) 04-23 10:37:12.840: e/androidruntime(319): @ com.couchbase.lite.database.open(database.java:813) 04-23 10:37:12.840: e/androidruntime(

c# - Converting a string with commas to double and int are different. Why? -

i migrating old mfc gui c#. i building form-based gui when i've got unexpected exception converting string integer type. assumed work same converting string double. string str = "1,000"; double dthou = convert.todouble(str); // ok int ithou = convert.toint32(str); // raises exception conversion double gives correct value: 1000.0. int conversion, able solution : convert.toint32() string commas . but curious if there reason behind this. or, missing something? i able find similar, not duplicate question : number parsing weirdness [edit] after learning culture issue. i in kind of culture-shock because until now, in korea, both floating point number , integer numbers expressed "," thousands group , "." decimal point (at least in real world, in korea, mean, think... ). guess have accept current settings of ms visual studio , carry on. [edit2] after sleeping on issue. i think it's more of inconsistent handling of formatted st

how to delay PHP script until Mysql insert query is committed -

in website developing users have sign or register. when users submits form registration user should logged automatically username... now, insert data mysql database followed retrieving same data database select statement problem select statement executed faster insert (or something) , results in fatal error... want php script retrieving data wait until insertion committed... how can ? first check whether query has been executed or not. $result = mysql_query('select * 1=1'); if (!$result) { die('invalid query: ' . mysql_error()); }

eclipse - java.lang.NoClassDefFoundError: com/sun/tools/javac/Main -

i have app deployed on heroku. imported , runned locally. please me error. can't figure out , solve this. error when run app. in heroku don't have error. java.lang.noclassdeffounderror: com/sun/tools/javac/main @ net.integrio.db.factory.compiled.compiler.compile(compiler.java:14) @ net.integrio.db.factory.compiled.implementationclassbuilder.buildclassfor( implementationclassbuilder.java:56) @ net.integrio.db.factory.compiled.implementationcache.getcompiledfactory( implementationcache.java:28) @ net.integrio.db.factory.compiled.compiledfactorysupport.<init>(compiledfactorysupport.java:92) @ net.integrio.db.factory.compiled.compiledfactorysupport.<init>(compiledfactorysupport.java:84) @ net.integrio.db.factory.compiled.compiledfactorysupport.<init>(compiledfactorysupport.java:68) @ com.getworkers.messages.incoming.incomingmessagesfactory.<init>(incomingmessagesfactory.java:13) @ com.getworkers.utils.cron.incomingmessag

xorg - How to change _NET_WM_NAME (X Library) -

i try use http://xkbind.sourceforge.net/ (useful displaying keyboard state in window title) on mint maya (based on ubuntu 12.04) but xkbind change wm_name property here xkbind.c code fragment if(xgetwindowattributes(dpy, window, &wa)) { xselectinput(dpy, window, wa.your_event_mask&~propertychangemask); xsync(dpy, false); xsetwmname(dpy, window, p_tp); xselectinput(dpy, window, wa.your_event_mask); } what function should used change _net_wm_name property too? example xkbind gvim xprop output wm_name(string) = "lat::[no name] - gvim" _net_wm_name(utf8_string) = "[no name] - gvim" straightforward call of xchangeproperty() should trick: xchangeproperty( display, win, xinternatom(display, "_net_wm_name", false), xinternatom(display, "utf8_string", false), 8, propmodereplace, (unsigned char *) utf8_buffer, count);

.net - How can I create an Excel sheet view for user input in C#? -

i wanted create view same excel sheet of rows , columns in user can give inputs , should grow dynamically cell should filled program internally , should read only. making windows form application using c#. there way in c#? there several tools aid in doing task. telerik , infragistics 2 of them. http://www.telerik.com/ http://blogs.telerik.com/aspnet-ajax/posts/13-07-30/create-excel-asp-net-grid http://www.infragistics.com/products/windows-forms/infragistics-excel/ this article may useful too. http://support.microsoft.com/default.aspx?scid=kb;en-us;304662

java - Dozer unable to map Collection<Interface> member -

i have object contains collection: public class wrapper { private collection<base> bases = new linkedlist<base>(); public collection<base> getbases() {return bases;} public void setbases(final collection<base> bases) {this.bases = bases;} } the implementations of interface quite simple: public class baseone implements base { } public class basetwo implements base { } when run simple test: @test public void testcopyother() { final wrapper wrapper = new wrapper(); wrapper.getbases().add(new baseone()); final wrapper copy = dozer.map(wrapper, wrapper.class); } i exception: org.dozer.mappingexception: java.lang.nosuchmethodexception: com.usamp.biddingtool.model.service.impl.base.<init>() @ org.dozer.util.mappingutils.throwmappingexception(mappingutils.java:82) @ org.dozer.factory.constructionstrategies$byconstructor.newinstance(constructionstrategies.java:261) @ org.dozer.factory.constructionstrategies$b

php - Exploding string to array, then searching array for multiple results -

background users on website can give profile 'keywords', each separated ', '. example: green apples, bananas, red apples, pears this stored in database string. i have livesearch page users can search users keyword. on search, page suggests keywords user types. example, user may type: apples and page suggest green apples , red apples . method when input sent keywordsearch.php , page searches following: $search_string_w = '%'.$search_string.'%'; $stmt = $dbh->prepare('select `keywords` `users` `keywords` ?'); $stmt->execute(array($search_string_w)); while($results = $stmt->fetch(pdo::fetch_assoc)) { $result_array[] = $results; } this gets row of user has keyword. however, want display each individual keyword search suggestions, if keyword appears multiple times. if (isset($result_array)) { foreach ($result_array $result) { $keyw = explode(', ', $result['keywords']); $keyk

r - Knitr kable() output not displayed correctly when there are parenthesis in column title -

i have linear model, want print coefficient table in knitr chunk inside r markdown file. produce html file r markdown file. > model <- lm(speed ~ dist, cars) this coefficient table is not displayed correctly when place in {r results='asis'} knitr chunk. table displayed plain text in html page. > kable(xtable(model)) | | estimate| std. error| t value| pr(>|t|)| |:-----------|---------:|----------:|--------:|--------:| |(intercept) | 8.2839056| 0.8743845| 9.473985| 0| |dist | 0.1655676| 0.0174945| 9.463990| 0| this coefficient table is displayed correctly when place in {r results='asis'} knitr chunk. table displayed html table in html page. > kable(data.frame(xtable(model))) | | estimate| std..error| t.value| pr...t..| |:-----------|---------:|----------:|--------:|--------:| |(intercept) | 8.2839056| 0.8743845| 9.473985| 0| |dist | 0.1655676| 0.0174945| 9.463990| 0|

java - Foreach loop can cause thread concurrency? -

i've heard shouldn't use foreach loop can avoid because can cause thread concurrency, mean thread concurrency, , true ? so when should use for-each loop? any time can . beautifies code. unfortunately, cannot use everywhere. consider, example, the expurgate method . program needs access iterator in order remove current element. the for-each loop hides iterator, cannot call remove . therefore, for-each loop not usable filtering. it not usable loops need replace elements in list or array traverse it . finally, it not usable loops must iterate on multiple collections in parallel . these shortcomings known designers, made conscious decision go clean, simple construct cover great majority of cases. emphasis mine. unless clear mean exactly, indicate you're wrong.

php - FFMPEG 2 Channel AIF files = fail -

i wonder if has solution aif files "2 channels", not compile in ffmpeg. if take same aif file , open in editor , recompile stereo (l r), works expected. my ffmpeg command , console output: $ ffmpeg -i input.aif -ar 44100 -ab 128k -acodec libmp3lame -ac 2 -y output.mp3 ffmpeg version 2.0.1 copyright (c) 2000-2013 ffmpeg developers built on mar 2 2014 19:58:58 gcc 4.6 (ubuntu/linaro 4.6.3-1ubuntu5) configuration: --enable-gpl --enable-version3 --enable-shared --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid libavutil 52. 38.100 / 52. 38.100 libavcodec 55. 18.102 / 55. 18.102 libavformat 55. 12.100 / 55. 12.100 libavdevice 55. 3.100 / 55. 3.100 libavfilter 3. 79.101 / 3. 79.101 libswscale 2. 3.100 / 2. 3.100 libswresample 0. 17.102 / 0. 17.102 libpostproc

ios - Copy UImages from photo library to another directory -

i want copy picture photo library directory in app, every thing works fine attached code here when try copy lot of images app crashes think because attached code done single thread each image needs thread, if there many pictures copy app crashes. need same code here not in thread means app should blocked until image copied directory , if 1 have idea appreciated. loop saving each image. for (int = 0; i< countt ;i++) { nsurl *referenceurl = [self.tosavearray objectatindex:i]; alassetslibrary *assetlibrary=[[alassetslibrary alloc] init]; [assetlibrary assetforurl:referenceurl resultblock:^(alasset *asset) { alassetrepresentation *rep = [asset defaultrepresentation]; byte *buffer = (byte*)malloc(rep.size); nsuinteger buffered = [rep getbytes:buffer fromoffset:0.0 length:rep.size error:nil]; nsdata *data = [nsdata datawithbytesnocopy:buffer length:buffered freewhendone:yes];//this nsdata may want n

Bower hangs after checkout step of Install command. -

i'm github enterprise user , i'm using bower point internal repository manage dependencies. i have set repo , included bower.json file in root directory. looks this: { "name": "axis", "main": "axis.js", "version": "0.0.0", "authors": [ "nick randall" ], "description": "chart axis", "keywords": [ "d3", "d3.chart", "axis" ], "license": "mit", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ], "dependencies": { "d3": "~3.4.6", "d3.chart": "~0.2.0", "lodash": "~2.4.1" } } i'm trying install repo above dependency in new project using "bower install org/axis" , process hangs aft

json - Javascript :: generate new variable in a closure and use it through an object instance -

h! have fetch json data remote file , grab values variables accessibles instance of object created "v". with code "undefined" (i'm trying minimize as possible antipatterns) var func = function (url) { this.url = url; }; func.prototype.fetch = function () { // fetching json content var res = new xmlhttprequest(); res.open('get', this.url, true); res.onreadystatechange = function () { if (res.readystate == 4) { if (res.status == 200) { // object want access outside var obj = json.parse(res.responsetext); this.ip = obj.ip; } } res.send(null); }; }; var v = new func("http://ip.jsontest.com/?callback=showmyip"); v.fetch(); //now "undefined" console.log("ip " + v.ip); i hope i've been clear. me please? thanks in advance. the problem res.open asynchronous call. not data immedia

google spreadsheet - If column includes a certain value, turn top cell red -

i want function can check 1 column value , if @ least 1 value found top cell should become red. intent visualize function of top cell in said column: if cell in column "a" = "x" cellbgcolor = red else cellbgcolor=white i don't mind doing in 2 steps, i.e. if value found type "x" in cell , use conditional formatting paint cell. please try: =match("x",a:a,0) with applies to range: a1.

java - How should I access class members in beforeExecute and afterExecute hooks in ThreadPoolExecutor? -

i extending threadpoolexecutor class. inside want set member value in beforeexecute (thread t, runnable r) , afterexecute (runnable r, throwable t). not sure how so. can me that? presumably, want access instance field of runnable instances. access them need downcast runnable actual class of runnable class, , access fields via downcast reference. or better still, make fields private , access them via getter / setter calls on reference. this awkward if runnable anonymous inner class. in case, may need turn named class: either nested, inner or top level. on other hand, if talking static fields or methods of runnable implementation class, can use them ... provided access modifiers allow this.

ios - What's the difference between CLBeacon and CBcentralManager -

i want detects beacon/ibeacon devices near iphone's proximity. not sure class should use should use clbeacon , clbeaconregion , start monitoring region or should use cbcentralmanager , scanforperipheralswithservices which api suited best use case ? i have tried find online it's not documented anywhere although ibeacons use bluetooth low energy (ble), not treated ble peripheral in ios. handled via corelocation framework, classes need cllocationmanager , clregion , clbeacon . refer core location programming guide cbcentralmanager ble peripherals such heart rate monitors, fitness trackers (or else can think of want exchange data peripheral)

c# - Input string was not in a correct format in my gridview -

here, have attendance table having attributes such status - bit, studid - bigint (foreign key), attendanceid - int =>primary key , identity(true) and student table having studid - bigint =>primary key, studfirstname - varchar(50), studlastname - varchar(50) to displayed in gridview. here code : using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; public partial class class_content_addattendancesss : system.web.ui.page { dataclassesdatacontext db = new dataclassesdatacontext(); protected void page_load(object sender, eventargs e) { var cn = p in db.attendances (p.branchid == convert.toint32(dropdownlist1.selectedvalue)) && (p.semesterid == convert.toint32(dropdownlist2.selectedvalue)) select new { p.attendanceid, p.status, p.studid, p.studen

c# - Looping Storyboard Animation Without Trigger -

this code: <drawingbrush viewport="0,0,16,16" viewportunits="absolute" stretch="none" tilemode="tile" x:key="dbcheckerboard"> <drawingbrush.drawing> <drawinggroup> <geometrydrawing brush="black"> <geometrydrawing.geometry> <geometrygroup> <rectanglegeometry rect="0,0,8,8"/> <rectanglegeometry rect="8,8,8,8"/> </geometrygroup> </geometrydrawing.geometry> </geometrydrawing> </drawinggroup> </drawingbrush.drawing> </drawingbrush> <style x:key="scrollingcheckerboardbackground" targettype="control"> <setter property="background" value="{staticresource dbcheckerboard}" /> <style.triggers>

vb.net - Inherit from base UserControl -

i have several user controls have similar functionality, thinking moving these methods baseusercontrol class , , make user controls inherit it. however, when so, compliler warning: base class baseusercontrol specified class usercontrol1 cannot different base class system.windows.forms.usercontrol of 1 of other partial types i know i'm getting warning because when create baseusercontrol , autogenerated code in designer adds inheritance system.windows.forms.usercontrol . so, 1. how can inherit `usercontrol` in `vb.net`? 2.is possible? if not, how avoid code repetition in case? thanks!

phpStorm loses permissions during sftp deployment -

i use phpstorm on mac using deployment function sftp. today noticed, file permissions lost when that. of local files have execution bit set, not set on remote server. in deployment options have disabled "override default permissions" , did not have enabled ever before. what do? googled world not find hooks deployment process of phpstorm. automatically triggering deployment on save instance. found solution rsync , phing ( http://www.ibresources.com/technical/programming/rsync-with-phpstorm ), solution, have press key, not want ( lazy bitch, know ;-) ). if there no solution upload manually rsync, keeps permissions , rely on rest of deployment features of phpstorm. "upload"-function useless then. does face same problem? it? cheers, thomas i realize old thread. however; to preserve rwx permissions of files on upload can defined in phpstorm settings | build, execution, deployment | deployment | options . you need activate check box "overri

c# - Resharper ContractAnnotation for null-check not eliminating NRE warning -

i'm having problem extension method, annotated contractannotation tell r# null-ness of object doesn't result in nre warning going away. here's how projects laid out: project1: jetbrainsextensions has r# annotations class defines contractannotation project2: mybaselibrary references project1 , has extension method this: [contractannotation("null => true; notnull => false")] public static bool isnull(this object aobject) { return referenceequals(null, aobject); } project3: mybusinesslogic using mybaselibrary project , wants this: if (myvariable.isnull()) return; myvariable.dostuff(); the line: myvariable.dostuff(); warning there's possible null reference exception. i've followed advice listed in many/all of related stackoverflow posts regarding how annotation should written. i've tried: [contractannotation("aobject:null => true; aobject:notnull => false")] and [contractannotation("aobject:null

asp.net mvc - MVC Parameterized Element -

i have partial view want display different type of html element based on property of model. solution i've come is: @if (model.element == "span") { <span> stuff </span> } else if (model.element == "p") { <p> stuff </p> } else { <div> somestuff </div> } this not extensible. i'd write like: <@model.element> stuff </@model.element> but doesn't seem allowed. there way this. (i appreciate goes against grain of mvc model , therefore controller specifying html. actually, element type comes parent view, think okay.) many in advance. @html.raw("<" + model.element + ">") stuff @html.raw("</" + model.element + ">") is simple possible. though use tagbuilder : @{ tagbuilder tb = new tagbuilder(model.element); tb.innerhtml = "some stuff"; @html.raw(tb.tostring()) }

How to count the number of options in select using jquery -

i want compare number of items in 2 select elements(html). tried using length property(with jquery) says both select element have number of option =1. populating both select elements dynamically. do? var $options=$("#test_select"); $options.empty(); $.each(t_test_list,function(index,value){ $options.append($("<option>").text(value).attr("value",value)); }); var numdate=$("#date_select").length; var numtest=$("#test_select").length; alert(numdate); alert(numtest); if(numdate!=numtest) { alert("the number of dates not match test cases!!!"); } try this: change: var numdate=$("#date_select").length; var numtest=$("#test_select").length; to: var numdate=$("#date_select").children('option').length; var numtest=$("#test_select").children('option').length; you need options length children of select not sele

passing objects in jquery click event -

i have wrong , not working. i'm trying call 1 shared function alert data passed called 2 different click events |i underfined in alert. why underfined? var myf = function(){ alert('a click ' + this.model + ' ' + this.year); // meant alert properties of object passed alert(this.id); // meant alert id of click called }; var mycar = new object(); mycar.make = "ford"; mycar.model = "mustang"; mycar.year = 1969; var mycar2 = mycar; mycar2.make = "vw"; mycar2.model = "golf"; mycar2.year = 2000; $('.feature1').click(mycar,myf); $('.feature2').click(mycar2,myf); to access data in event handler, must use event.data : var myf = function(e){ alert('a click ' + e.data.model + ' ' + e.data.year); alert(this.id); }; moreover, property contains id called id , not id . , have typo mycar2 = mycar instead of mycar2 = mycar . demo

cocoa - How do I create a reusable class-level property construct in Objective-C? -

i'd have class-level properties, , found solution https://stackoverflow.com/a/15811719/157384 @interface model + (int) value; + (void) setvalue:(int)val; @end @implementation model static int value; + (int) value { @synchronized(self) { return value; } } + (void) setvalue:(int)val { @synchronized(self) { value = val; } } @end and you're able call through property accessors, so: model.value = 1 model.value // => 1 fantastic! now, want make chunk of code reusable, in form of macro or meta-programming, takes property name , type. how can write it? with example above, value , (int) (and model ) should dynamic. update thanks @rich have this: // common.h #define class_property_interface(type, method, cmethod) \ + (type) method; \ + (void) set##cmethod:(type)val; \ #define class_property_implementation(type, method, cmethod) \ static type _##method; \ + (type) method \ { @synchronized(self) { return _##method; } } \ + (void) set##cmethod:(type)val \ { @syn

java - Text boxes squished in Swing layout -

i have frame opens when click file>new user, text fields squished together. i'm trying have them stacked vertically use new gridlayout(3, 2) layoutmanager . however, stuff new window way @ bottom. import java.awt.*; import javax.swing.*; import java.awt.event.*; public class app extends jframe implements actionlistener { private final int width = 300; private final int height = 550; private int control = 0; string[] username = new string[10]; string[] pass = new string[10]; private string tempname; private string temppass; container con = getcontentpane(); jpanel panel = new jpanel(); private jtextfield name = new jtextfield(); private jpasswordfield password = new jpasswordfield(); jmenubar mainbar = new jmenubar(); jmenu menu1 = new jmenu("file"); jmenu menu2 = new jmenu("edit"); jmenuitem newuser = new jmenuitem("new user"); jbutton but1 = new jbutton("log in");

objective c - Is there a way to detect if a user completed a purchase on another website through a UIWebView in an IOS app? -

for example, forward user product page on jcpenney.com in uiwebview, , user add jcpenney.com , go through if he/she purchasing product online. is there way me know whether or not user completed purchase? i thinking along lines of parsing html pages user visits, , 1 might contain "order complete" string or along manner. thanks! if know how final page is, can analyze in of delegates methods of webview. example implemeting in class delegate of webview: - (void)webviewdidfinishload:(uiwebview *)webview{ nsstring *mytext = [webview stringbyevaluatingjavascriptfromstring:@"document.documentelement.textcontent"]; if ([mytext rangeofstring:@"order complete"].location != nsnotfound) { //your logic stuff } }

Browser Compatibility Issues With Java -

java compatibility i have been having trouble making custom browser using default class provided oracle custom browser. 1 thing noticed browser cannot run java applets without sort of variation of java browser plugins. how normal browsers receive information web server run java program externally? there way somehow point browser toward jre run app on normal browser. need somewhere start. firefox apparently references sort of mime format under npjp2.dll native found in jre directory. much. oracle example you can provide user standard html download page in order him download jnlp file standard file start java web start app (applet). if user's system has java installed, must recognize .jnlp file , assosiate java app. it's step, user manually download file instead of running automatically on web browser, because of recent security loopholes on java web implementations, browsers don't trust java anymore, therefore blocking. if insist on setting web start app in

Xively & CurrentCost -

not sure if possible anymore or not. have been playing around xively , trying make connection currentcost energy monitor xively servers/interface. does xively still support feature or need find service? documentation laid out life of me can't seem figure out how connect device service. has done this? jeremy

javascript - Chosen JS does not send POST data -

i'm using chosen js plugin in order make select boxes cooler , prettier; however, something's not quite right when sending data via post php. note, i'm using codeigniter. this html: <select id="myselect" name="multiple[]" multiple="multiple"> <option value="1">something</option> <option value="2">something</option> <option value="3">something</option> <option value="4">something</option> </select> this js: $('#myselect').chosen({ max_selected_options: 4, place_holder_text_multiple: "pick poison(s)" }); finally, codeigniter model in catch data sent form , insert database. // want them introduced in column of database together, // separated commas. $string = implode(",", $this->input->post('multiple')); however, gets first value introduced user. like, if him/her

java - Strategy for cross field validation in Vaadin -

field validation works easy enough in vaadin, can't use check relations between fields (e.g. joining date must before leaving date), annoying. added standard class level validation using jsr 303 can this. works fine. but can perform cross field validation after have commited fields. means bean contains field changes, , in case of validation issue need possibility "go back" valid state before field commits (or force somehow "reload" of bean), else i'm stuck changes, e.g. if user decides cancel edit action. of course save field contents before, , reset state manually, given vaadin same in case of simple field validation i'd reuse mechanism. looking @ vaadin code, i'm not confident can figure out do, , right. please give me hints how deal problem without reinventing wheel. you can add commit handler fieldgroup . allows check before/after commitment: binder.addcommithandler(new commithandler() { @override public void preco