Posts

Showing posts from August, 2013

c++ - Iterating over a QList backwards -

if execute following code: qlist<int> l; qlist<int>::const_iterator li; l.append(1); l.append(2); l.append(3); l.append(4); li = l.constend(); while(li != l.constbegin()) { std::cout << *li << std::endl; --li; } i output: 17 4 3 2 i solved using qlistiterator<int> , don't why isn't working! thanks in advance ... try li = l.constend() - 1; i'm not sure if solves problem, far know, end iterators point 1 past end of container. i wanted address concern in comments. when this: li = l.constend(); while(li != l.constbegin()) { std::cout << *li << std::endl; --li; } you start off end of container, , loop never reaches constbegin . that's because when decrement, li becomes constbegin , while loop doesn't execute. (that's why 1 never outputted.) but if do: li = l.constbegin(); while(li != l.constend()) { std::cout << *li << std::endl; ++li; } the same thing happe

java - geoHash -ing for close points on each side of the equator -

i working on project (java using netbeans) @ point needs process map data. have got esri shape files whole uk , need create 1 dimensional index using geohash efficiency big factor in project. since need search distances going use morton ordering . problem geohash-ing close points on each side of equator can results in hash indices no common prefix in turn messes proximity searches in binary search tree. has body have neat way of doing this? have way adding offset points in uk solution not nicely scalable. know mongodb using geohash , still doing proximity searches, should away implemented.

sql - query for selecting count(*) and columns -

i have query fetches rows table , number of rows query gonna return: select tab.*, (select count(*) mytable mtb mtb.name = 'xyz' , mtb.type = 'tp') mytable tab tab.name = 'xyz' , tab.type = 'tp' now if see want number of rows main query returns other columns. need use query subquery in large query. want know if there better way write query. mean repeating query count separately. can please provide more optimized form you should use analytic function count() : select tab.*, count(*) on () totalcnt mytable tab tab.name = 'xyz' , tab.type = 'tp'

c++ - Step error in sqlite3_create_function_v2 -

i'm using sqlite3_create_function_v2 define ngram function. in case step used xfunc pointer, works charm, signature step , xfunc same. sqlite3_create_function_v2(this->connection, "ngram", 3, sqlite_any, null, sqliteextension::stepextendngram, null, null, null); when try use step step compiles when execute command ngram fails in prepare statement. sqlite3_create_function_v2(this->connection, "ngram", 3, sqlite_any, null, null, sqliteextension::stepextendngram, sqliteextension::finalextendngram, null); the sqliteextension code, test ngram not yet implemented void sqliteextension::stepextendngram(sqlite3_context *ctx, int narg, sqlite3_value ** val){ //3 params std::cout << "p1 " << sqlite3_value_text(val[0]) << " p2 " << sqlite3_value_text(val[1]) << std::endl; sqlite3_result_int(ctx, atoi((const char*) sqlite3_value_text(val[0]))); } void sqliteextension::finalextendngram(sqlit

ios - Floatting points issue -

Image
i have taken 2 uitextfields & 1 label result of float value inserted in textfields. code have done. here issue starts when takes textfields value in float, getting changed. - (ibaction)btncalculateamountselected:(id)sender { nslog(@"[_txtfield1.text floatvalue] is:--> %f ----- [_txtfield2.text floatvalue] is:--> %f",[_txtfield1.text floatvalue],[_txtfield2.text floatvalue]); float result = [_txtfield1.text floatvalue] - [_txtfield2.text floatvalue]; nslog(@"actual result is:--> %f",result); float truncatedfloat = truncf(result * 100) / 100.0; nslog(@"truncatedfloat is:--> %f",truncatedfloat); _lblresult.text = [nsstring stringwithformat:@"%f", truncatedfloat]; nslog(@"_lblresult.text is:--> %@",_lblresult.text); } output is:- [_txtfield1.text floatvalue] is:--> 1234.123413 ----- [_txtfield2.text floatvalue] is:--> 1234.111084 actual result is:--> 0.012329 truncatedfl

Wordpress Connect with facebook and other social media -

i running my wordpress powered website on free hosted platform , provider blocked php curl extension. want let visitors login facebook , other social platforms. tried wordpress plugins (e.g: nextend facebook connect, social connect etc.) but, plugins requires curl extension work. there alternatives activate facebook, twitter connect in wordpress website login? any or suggestion highly appreciated. i found this, might outdated, can check if works you http://martinsikora.com/facebook-php-api-without-curl-extension

c# - How to get child control? -

Image
i have tabcontrol contain 4 subtabs. each of tab contain picture box cotrol. i need picture box control of selected tab control. any idea how implement it? perhaps var picbox = tabcontrol1.selectedtab.controls.oftype<picturebox>().first();

multithreading - Java's ExecutorService performance -

i have main thread dispatches jobs thread pool. i'm using java's executor framework. from profiler (virtualvm) can see each thread's activity: can see main thread waiting lot (because executor's queue has upper limit) means executor's queue full of time. executor's threads not busy have thought. of them have waiting time of 75%. in virtualvm says waits on monitor. can explain why happenning? why executor threads wait while there still plenty of work available do? , how improve performance of executor? improve performance overall? more detail on executor's wait on monitor great. the job runs in workers computation, don't depends on else , don't communicate other thread (no synchronisation), except in end, put data in database, using own connection. parallel execution yield better results synchronous execution if: the work done independent each other (no or few , short critical sections) each single executed work takes enough tim

objective c - ios - property not found when using forwarded class -

i trying implement vuforiasdk in existing project , running problem: cannot access custom properties , methods of object subtype of uiview class. seems can use uiview properties , not own. here's of code: eaglview.h #import "ar_eaglview.h" #define kqcarmarkerscanned @"qcarmarkerscanned" @interface eaglview : ar_eaglview { } @property (nonatomic, retain) nsstring *myval; - (id)blablawithframe:(cgrect)frame; @end eaglview.mm #import "eaglview.h" #import "teapot.h" #import "texture.h" #import <qcar/renderer.h> #import <qcar/videobackgroundconfig.h> #import "qcarutils.h" ... @implementation eaglview - (id)blablawithframe:(cgrect)frame { nslog(@"bla bla enters.."); return [self initwithframe:frame]; } - (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; myval = @"initwithframe"; if (self) { .

python - Brew not installing the latest version -

i trying latest version of python on mac mountain lion. latest version 2.7.4, when run brew install python downloads 2.7.2. going on? brew install python ==> downloading http://www.python.org/ftp/python/2.7.2/python-2.7.2.tar.bz2 file downloaded in /users/pietro/library/caches/homebrew ==> patching patching file lib/whichdb.py hunk #1 succeeded @ 91 fuzz 1. ==> ./configure --prefix=/usr/local/cellar/python/2.7.2 --enable-shared ==> make ==> make install ==> downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.24.tar.gz file downloaded in /users/pietro/library/caches/homebrew ==> /usr/local/cellar/python/2.7.2/bin/python setup.py install ==> caveats "distutils.cfg" has been written to: /usr/local/cellar/python/2.7.2/lib/python2.7/distutils specifing install-scripts folder as: /usr/local/share/python if install python packages via "python setup.py install", eas

ios - How to update all records as quickly as possible? -

i need update records same value. , don't want iteration on objects since takes 2 seconds on 2000 objects. have users locally , receive users id's server. want set property 'requested' false except users return server- how done (which totally wrong!): iterating thru users (about 2000 of them) , correcting requested value. nsfetchrequest * allusers = [[nsfetchrequest alloc] init]; [allusers setentity:[nsentitydescription entityforname:@"user" inmanagedobjectcontext:context]]; nsarray *users = [context executefetchrequest:allusers error:&error]; nsarray *userids = [json objectforkey:@"users_ids"]; (user *user in users) { if ([userids containsobject:user.userid]) { user.requested = [nsnumber numberwithbool:yes]; } else { user.requested = [nsnumber numberwithbool:no]; } user.requested = [nsnumber numberwithbool:no]; } [context save:nil]; my idea how it: set requested=false every object sql-like 1 stateme

windows phone 7 - Does WP background transfers support re-uploading and how it actually works? -

i'm trying implement http handler handling file upload wp background transfers. i've tried this: var request = new backgroundtransferrequest(@"http://computername/test.ashx") { method = "post", transferpreferences = transferpreferences.none, uploadlocation = new uri(@"shared/transfers/testfile.txt", urikind.relativeorabsolute) }; in case phone sends range:0- . contentlength equals actual source file size. , request stream contains data... did not know how make sending data partially. and, can not find actual info how uploading works, headers uses , on. there no specification server! sadly, backgroundtransferrequests not support range upload or download. if don't need allow transfers when app not running, suggest writing own transfer code. can support range , can control number of concurrent transfers(and can around 2 transfer limit phone) , don&

embedded - Makefile for nrf51sdk -

i working on programming nrf51822 evaluation board( this one ). have been looking @ this site program , have gotten blinking program work. i want modify makefile provided on site mentioned, such when go along pretty have add list of files compile. below have been trying work, not makefiles. cc := /opt/arm-2012.09/bin/arm-none-eabi-gcc objcopy := /opt/arm-2012.09/bin/arm-none-eabi-objcopy nrf51_sdk := /opt/nrf51sdk nrf51_include := $(nrf51_sdk)/nordic/nrf51822/include nrf51_src := $(nrf51_sdk)/nordic/nrf51822/source cpu := cortex-m0 board := board_pca10001 objdir = . objdir += $(src)/templates/ includedirs = $(nrf51_include) includedirs += $(nrf51_include)/gcc define = board_pca10001 define += nrf51 cflags = -mcpu=$(cpu) cflags +=-mthumb cflags += $(patsubst %,-d%, $(define)) cflags += $(patsubst %,-i%, $(includedirs)) cflags += -c src = main.c src += $(nrf51_src)/templates/system_nrf51.c src += $(nrf51_src)/nrf_delay/nrf_d

HTML Form onclick calling javascript function and later calling the default form action -

i having asp page. in have form element action specified now in form have element calling js func on click of 1 button. it calling javascript function , later calling default form action. why so? how can execute function..? code: <form method="post" action="update.asp" id=form name=form1 > <td align=center width=10%><input id=button1 type=submit onclick="gs_test()" onmouseover="style.backgroundcolor='blue'" onmouseout="style.backgroundcolor='blue'" value=abc name=submit1 style="width: 80%; height: 20px;background:blue; color:white; font-family:serif; font-size=medium; border- color:black; border-width:1px" ></td> <script language="javascript"> function gs_test() { alert("gss"); } </script> ' change type="submit" type="button" . read <input> reference on mdn . and sake of all, cons

proxy - Web-based Jabber client does not work in closed environment -

i have installed , configured openfire 3.8.1 chat-server on window server 2008 r2 enterprise. using jsjac.js jabber-client library written in javascript. on openfire->server-setting->http-bind, have mentioned port no 5280, ssl port 7443 client connect server using http-bind request. on localhost , on server too, running if access web-based chat computer. when same web-based client accessed in closed environment (where proxy , firewall implemented), gives error. webbased jabber client not work. but @ same time , in same environment, web-based gmail chat working xmpp based chat application. please figure out , resolve issue. regards

sphero api - Autonomous behaviour via Orbbasic or streaming? -

the orbbasic language suggested way kids have hands on controlling sphero in interview . what limitations of orbbasic? achieves same 1ms granularity macros ? in range of time granularity equally acceptable stream data , excecute orbbasic? can stabilization of sphero motion programmed orbbasic? data streaming? you can read abilities of orbbasic in our online document here: https://github.com/orbotix/developerresources/tree/master/docs but in short, can run 9,000 lines of code/sec it's 9x density of macros more power. can use print statements send data bluetooth client have make sure don't exceed rational limits; orbbasic can generate data faster bluetooth can transmit devices. stabilization can turned on , off in orbbasic, , when on can generate own roll commands processed if came smartphone. just clear, data streaming automated way of retrieving sensor data sphero without having continually ask it. can use examine motion of sphero cannot "control&q

reporting services - How to manage odd record(s) in SSRS? -

Image
my ssrs report dataset generates 6 colums shown below. report grouped repname. portfolio column populated either , b. regular name , b odd name. whenever there b, change background color of particular cell red , move odd record(s) top when report runs. tips appreciated. repname appid dealername buyername amtfinc portfolio conditional formatting of cell background right-click portfolio field access properties open expression editor fill color: on fill tab enter expression evaluate value of portfolio field , set color appropriate. sorting you have 2 options sorting results, either in dataset or in table/matrix on report. test see works best situation. dataset sort assuming column name portfolio in database, add following dataset query: order portfolio desc; tablix sort right-click tablix in report design: set descending sort on portfolio field: keep in mind if want all rows portfolio value of b sort @ top of report, you'l

mongodb - Undefined Boost reference when compiling mongo-perf on CentOS 6.3 -

i'm attempting compile mongo-perf adapting instructions here centos 6.3. have followed these instructions on ubuntu successfully. i compiled mongodb, when running scons compile mongo-perf, errors undefined boost references. [davidv@mongodb-test1 mongo-perf]$ scons scons: reading sconscript files ... checking c library mongoclient... (cached) yes checking c library boost_thread-mt... (cached) yes checking c library boost_filesystem-mt... (cached) yes checking c library boost_program_options-mt... (cached) yes checking c library boost_system-mt... (cached) yes scons: done reading sconscript files. scons: building targets ... g++ -o benchmark -pthread -g benchmark.o -lmongo-cxx-driver -lmongoclient -lboost_thread-mt -lboost_filesystem-mt -lboost_program_options-mt -lboost_system-mt /usr/local/lib64/libmongoclient.a(dbclient_rs.o): in function `__static_initialization_and_destruction_0': /home/davidv/mongodb-src-r2.4.3/src/third_party/boost/boost/system/error_code.hpp:214

ios - If I use Apple Push Notification service for instant messaging will apple block my account? -

i want create ios chatting app using apns. if have 10,000 active , continuing chatting, apple block developer account ? there limitation regarding this? i discourage using apns backbone of "chatting app". if need fast chatting functionality should write own tcp-socket based server. if every-few-second syncing o.k. can away http-based server backend (but pull-syncing can hard on network traffic - tcp-socket still better choice). you use apns fallback - when app on device not responding (i.e. not connected server) can send initial message trough apns (to wake app & notify user there message waiting him). as user opens app should switch tcp-socket or http request based server communication. as question: no, apple (one can never know sure) not reject app because of using apns chatting. note (as others said allready): messages between 2 users "lost" if interact - see link roman barzyczak gave you.

Determining the operator from a string using javascript -

i need help. i need come javascript function check string entered textbox determine sql operator example: var field1 = document.getelementbyid('field1').value var field2 = document.getelementbyid('field2').value var field3 = document.getelementbyid('field3').value function validate(textbox) { var operator if ('%' first character placed before , after value) { operator = } else if ('%' first character placed before value) { operator = } else if ('%' last character placed after value) { operator = } else { operator equals "=" } //default alert(operator) } example of function in action: validate(field1) you can use regular expressions this. looks if string contains % , operator like . can this: var operator = "="; //if string starts % or ends % //the operator "like" if(/^%/.test(str) || /%$/.test(str)) { operator = "like"; }

asp classic - How do I update a files content using vbscript without updating it's modified date? -

a few large sites online incorrect doctypes (4.0 not 4.01). have written script update files content updates date modified file , want keep it's original date, possible in vbscript (with classic asp)? here code replace file contents: ' folder root here fileroot = "d:\myroothere\" ' use persits upload because need impersonation setting below set upload = server.createobject("persits.upload") ' set impersonation authorise file over-writing (this correct , working) upload.logonuser "localhost","myusername","mypassword" set dir = upload.directory(fileroot & "*.asp", sortby_type) each item in dir set objfso = createobject("scripting.filesystemobject") set objfile = objfso.opentextfile(fileroot & item.filename, forreading) strtext = objfile.readall objfile.close if instr(strtext,"html 4.0 transitional") strnewtext = replace(strtext,"html 4.0 transit

tsql - A tree structure in SQL Server that needs to be flattened in a very special way -

we have table looks : create table hierarchy (employeeid int not null, parentid int, orderlimit int) create table order (employeeid int not null, ordersize int) it's supposed tell approval range each employee on orders, , decided keep employee manager's id, in same record, because in case order exceeds person's limit, his/her manager (referred parentid ) should approve it. if exceeds upper level again, order should go higher level , on , on, until reaches level qualifies approve order. if parentid null 1 person, means highest level in management structure , don't know how many possible levels might have, , if highest level' to clarify consider this insert hierarchy values (1,10,0), (2,11,0), (3,12,0), (10,20,100), (11,21,300), (12,22,200), (20,30,1000), (21,31,2000), (22,31,3000), (30,40,10000), (31,40,15000), (40,null,null) we want create view returns this: employeeid approvalgoesto lowerlimit upperlimit ----------------------------

Ember.js in windows (8) store app requires MSApp.execUnsafeLocalFunction -

we evaluating ember.js use inside javascript windows (8) store application . application not of interrest itself. problems facing related restrictions apply when working dynamic content being injected dom. windows store app runs in "local" context, i.e. way how windows store applications typically built. in local context, html "browser host" of windows store application works in rather restricted mode. instance setting innerhtml, outerhtml or appending content holding script elements blocked if not explicitely encapuslated "proxy" function provide microsoft ( msapp.execunsafelocalfunction ). example: ember.view appendto not work out of box. in order work, function has encapsulate jquery call appendto msapp.execunsafelocalfunction proxy function. original: (in ember.view) appendto: function(target) { // schedule dom element created , appended given // element after bindings have synchronized. this._insertelementlater(function() {

Is there a NOT (window).scroll function in jQuery? -

i'm trying set function stops working when user scrolls, there oposite function below? $(window).scroll(function() { //while user not scrolling }); here's function want stop working when user scrolls have multiple instances of using data rows, problem i'm having when 1 tooltip starts loading , user scrolls on several more accident or chance, page jumps last 1 load. this function in on page load: var targets = $( '[rel~=tooltip]' ), target = false, tooltip = false, title = false; targets.bind( 'mouseenter', function() { target = $( ); tip = target.attr( 'title' ); tooltip = $( '<div id="tooltip"></div>' ); if( !tip || tip == '' ) return false; target.removeattr( 'title' ); tooltip.css( 'opacity', 0 ) .html( tip ) .appendto( 'body' ); var init_tooltip = function() { i

How to share a facebook page tab app, through google plus -

i have developed small page tab app run contests in facebook different clients. wanted add 3 icons (facebook, twitter, g+) share contest respectively. i implemented links facebook , twitter, google plus has not gone well. while urlencode that: https://www.facebook.com/nmctesting/app_472674929471446 g+, shares link cuts off last part of path , shared link finally: " https://www.facebook.com/nmctesting " the work around considered, share link in our domain , there, javascript redirect facebook page tab. although seemed clearer approach, g+ yields error of : "there problem saving post. try again." how can share link facebook page tab app using google plus? i have been going through share documentation of google - no luck , through other posts discuss sharing api of google plus, again no luck, because @ end of line, can share general-example link. thank guys in advance!

c# - How can I make the same code repeat until the player answers differently? -

so trying make text adventure game computer class. know basics of c# i'm missing because can't code right. want make man ask player question if answer no repeats question because have answer yes game continue. tried using loop didn't work well. anyways, code have: using system; using system.collections.generic; using system.linq; using system.text; namespace consoleapplication1 { class program { static void main(string[] args) { console.writeline("minecraft text adventure: part 1!"); console.writeline("\"hello traveller!\" says man. \"what's name?\""); string playername = console.readline(); console.writeline("\"hi " + playername + ", welcome minecraftia!\ni give tour of our little town there isn't left to\nsee since attack.\""); console.writeline("he looks @ stone sword in hand. \"could defeat zom

SQL Azure to SQL database -

most of posts out there discuss converting sql database azure. actually, want go other way. i have azure database , want convert sql including data. how do this? export sql database out use sql server 2012 , import using http://msdn.microsoft.com/en-us/library/windowsazure/hh335292.aspx - how export http://blogs.claritycon.com/blog/2012/06/easily-restore-sql-azure-database-to-local-sql-instance/ the above links should help.

c# - Possible to reference a property of an anonymous object? -

apologies if 'property' not right terminology here. not sure if it's field/member or not (interested know if pleaes comment on this). this.add(new deemacsclass() { first = "value", second = first }); assuming 'this' list<deemacsclass> , how can similar above? second = first being invalid. it not possible reference object being created, or other properties/methods/members of object, within collection initializer block.

javascript - Custom progressive audio streaming in browser -

say create own progressive streaming mechanicsm in javascript because i'm finding browser's built in streaming mechanism not fault-tollerant enough or implement own custom method on websocket. create buffer holds downloaded segments of continous media file (say arraybuffer or that). possible play file if it's not downloaded start-to-end? my idea web audio api has noteon() function preceisely timing start of each segment. don't know how gapeless be. introduces problem have know audio files can cut safely on server side next part can decoded without loss , gaps. e.g. mp3's bit reservoir stores audio data in neighbour audio frames in cbr mode makes things difficult. what creating scriptprocessornode feeds incoming buffers? biggest issue making sure segments convertible raw audio samples, otherwise write simple function in onaudioprocess event handler pulls in next available buffer chunk , copies node's output buffers. since pull-on-demand mechanis

android - Button Highlight - how to apply onTouch to 2 buttons -

Image
i have 2 buttons this: button b = new button(this); b.settext("button onw"); b.setid(1111); b.setbackgrounddrawable(r.drawable.button); b.setontouchlistener(listenerone); rootlayout.addview(b); button b1 = new button(this); b1.settext("button two"); b1.setbackgrounddrawable(r.drawable.button); b1.setontouchlistener(listenerone); relativelayout.layoutparams = new relativelayout.layoutparams(relativelayout.layoutparams.wrap_content, uiutils.convertdptopixels(activity .getresources().getdisplaymetrics(), 45)); i.addrule(relativelayout.below, b.getid()); rootlayout.addview(b1, i); now ontouch : ontouchlistener listenerone = new ontouchlistener() { @override public boolean ontouch(view view, motionevent event) { switch (event.getaction()) { case motionevent.action_down: view.getbackground().setcolorfilter(color.parsecolor

javascript - ExtJs exceptions immediately break all ExtJs components on a page -

if you've ever worked extjs, you've run nefarious "cannot read property 'dom' of null" exception. me, happens inside doinsert (the last of 14 stacks in outer trace) (extjs's code): doinsert: function(el, o, returnelement, pos, sibling, append) { //<my own comment>: hint: el === null (curiously not undefined?) el = el.dom || ext.getdom(el); var newnode; ... } this happens when attempt attach extjs component (tree, grid, button, whatever) dom element not yet in dom. element in memory, constructed part of ajax request, ready inserted on success. the problem when extjs throws, it fundamentally breaks every extjs component in page . grids, trees, menus, buttons mangled. event bindings click , hover either nothing or generate exceptions. i mitigate against first doing document.getelementbyid check, , if result undefined, defer 100 ms , try again. ugly, works. it's expensive do. pages more complex, that's more , more doc

css - Change elements position when browser changes size -

i have 2 <label> in right corner of div located in center of browser width/height 200px/200px. when change browser size labels disappears in right side of browser. how can make labels moves right side when browser size changes? try make: .my_label{ position:absolute; right: 20px; } but right property right browser window, not div. i need labels move when disappears browser. thank you. as george stated, make parent position:relative have child element's position absolute in relation containing element (instead of window). if want tweak css based on browser size / res, read on css media queries: https://developer.mozilla.org/en-us/docs/css/media_queries

javascript - Run a function constantly -

i'm using excellent inview plugin check if element visible in viewport, using setinterval, function runs once , when element visible, not otherwise (should run else statement). var checkviewport = setinterval(function() { $('#colorbox').on('inview', function(event, visible) { if (visible) { console.log('yes'); } else { console.log('no'); } }); }, 5000); bind event once, , check separate variable. try this: var isvisible = false; $('#colorbox').on('inview', function(event, visible) { isvisible = visible; }); var checkviewport = setinterval(function() { if (isvisible) { console.log('yes'); } else { console.log('no'); } }, 5000); you can structure differently make sure isvisible isn't global variable , can accessed setinterval still well.

msysgit's cygwin tools failing on Windows 8 -

in msysgit installation directory there's bunch of cygwin tools (sh, ssh, wc, ...) git use. when install msysgit (1.7.11.msysgit.1) on fresh win8 vm state first time run of cygwin tools following error: 0 [main] 0 init_cheap: virtualalloc pointer null, win32 error 487 allocationbase 0x0, baseaddress 0x68560000, regionsize 0x3a0000, state 0x10000 d:\program files (x86)\git\bin\sh.exe: *** couldn't reserve space cygwin's heap, win32 error 0 the next time work , happens once each of tools. any ideas on why happens, how it's fixed specific tool after single run of , how fix in first place?

android - FragmentStatePagerAdapter / Update Action Bar Title -

i have host activity viewpager+fragmentstatepageradapter let me swipe through set of fragments (different instances of same itemfragment class) , data populating each fragment fetched network. now, while swipe want update action bar title property coming current fragment use onpagechangelistener/onpageselected work: ... @override public void onpageselected(int position) { myfragment currentfragment = (myfragment) getsupportfragmentmanager().findfragmentbyid(r.id.view_pager); getsupportactionbar().settitle(currentfragment.propertyiwanttouseastitle); } ... i have couple of doubts here: am retrieving real current fragment? fragmentstatepageadapter not set tag each fragment don't know other way current fragment rather using viewgroup container when onpageselected invoked, added fragment still fetching data need set action bar title causing npe. what's best place keep logic of updating action bar title in scenario described above? ps. have tried mixed appr

ios5 - iPod Touch iOS 5 Animation Stuttering -

i have uiview acts badge in app, upon pressing button, badge supposed blink existence , nice squash , stretch animation. animation works on iphone 4, iphone 4s, , iphone 5 8gb ipod touch (4th generation) ios 5.1.1 has bad stuttering effect. the popwithduration: method causes stuttering while resetcount method, causes view explode in size. wondering if knows fixes or workarounds. here relevant methods, class subclass of uiview. - (void)popwithduration:(cgfloat)duration { if(self.cananimatelikednumber) { if(self.waitingtoreset){ [self resetcount]; return; } else self.cananimatelikednumber = false; cgaffinetransform stretchtransform = cgaffinetransformmakescale(1.5,1.5); cgaffinetransform squashtransform = cgaffinetransformmakescale(1.0,1.0); [uiview animatewithduration:duration delay:0.0f options:uiviewanimationoptionlayoutsubviews animations:^{ [self setalpha:1.0f];

Call function in javascript file from html onclick event -

this has been driving me crazy- can't figure out why wont work! i have 2 files: mypage.html , mycode.gs in google scripts. have deployed html file web app, , want onclick event submit button trigger emailtech function mycode.gs file won't work! when run function straight file, works fine. i've done few hours of research , tried add <script type="text/javascript" src="mycode.gs"></script> causes error when refresh web app. have tried calling function in onclick event onclick= "google.script.run.emailtech()" , onclick= "emailtech()" neither work. have tried loading emailtech function script tag in header, didn't work either! missing? please help! mypage.html file: <script type="text/javascript"></script> <body> <input type="submit" onclick="emailtech();" value="submit" /> </body> mycode.gs file: function doget() {

trouble with classes in python -

i getting error reads , no matter unable rid of code. traceback (most recent call last): file "c:\users\ian\desktop\blackjack.py", line 226, in <module> main() file "c:\users\ian\desktop\blackjack.py", line 225, in main blackjack.playgame() file "c:\users\ian\desktop\blackjack.py", line 145, in playgame self.firstround() file "c:\users\ian\desktop\blackjack.py", line 83, in firstround a=self.dealer.hand.append(deckofcards.deal(deckofcards.shuffledeck)) attributeerror: type object 'deckofcards' has no attribute 'shuffledeck' the following actual code have written ( have changed great deal in order move error along can no longer figure out going on) want skim on , tell me obvious mistakes, sure there many, , apologize our professor doesn't teach use how things , expects know how. from random import* class card(object): def __init__(self,suit,number): self.suit=suit se

Perl - search a word and print rest of line into variables -

i have easy question. how can make perl read file, search specific word, , if finds match, want print rest of line individual variables. the ascii file (called "region_list" wish search contains has 3 lines: hawaii 40 5 -140 -180 samoa -5 -25 -165 165 pacific 70 -65 290 110 here's code have far, doesn't seem working: #!/usr/bin/perl -w # # required libraries use date::calc qw(:all); use date::manip; use math::trig; use warnings; use time::local; use posix 'strftime'; use lib '/usr/bin'; use cwd qw(); @region = ("hawaii", "samoa", "pacific"); open $listreg1, "$bin_dir/region_list" or die "could not open: $!"; ($reg2,$max_lat, $min_lat, $max_lon, $min_lon) = split(" ",$listreg1); if ($region eq $reg2) { print "lucreg $region $reg2 $max_lat, $min_lat, $max_lon, $min_lon \n"; } close $listreg1; with perl 5.10 or higher, can use smart

scala - Typesafe Swing events—"The outer reference in this type test cannot be checked at run time" -

i implementing swing component , want overcome #### untypedness of reactor . thought work: trait foo[a] extends scala.swing.publisher { final case class bar(parent: vector[a], children: a*) extends scala.swing.event.event } trait test { val foo: foo[int] foo.reactions += { case foo.bar(parent, children) => { println(parent.sum - children) } } } unfortunately gives me 2 compiler warnings: the outer reference in type test cannot checked @ run time. final case class bar(parent: vector[a], children: a*) extends scala.swing.event.event ^ outer reference in type test cannot checked @ run time. case foo.bar(parent, children) => { ^ should ignore these warnings? can suppress them? should change design? in scala, inner classes "path-dependent". i'll use code example. if have 2 foo[int] s, called foo , bar , foo.bar different type bar.bar . note differs java's idea of inner classes,

PHP MySQL - Import CSV Using LOAD DATA INFILE - Determine file path? -

i need connecting dots on this. there's plenty of snippets floating around haven't found end end tutorial. for simple custom cms i'm building want option end user admins upload csv of other users. phpmyadmin or other "direct" access db not option environment. i'm trying build file upload form inserts data in appropriate table. i found this tutorial on building upload form - working fine (although i'd add additional validation/security). , based on these several posts here ( like one ) think using load data infile makes more sense trying loop , parse fgetcsv or (but feel free disagree). here's current code - it's not working , assume it's file path - how should format it? _uploads directory in same place processor file. $target_path = "_uploads/"; $target_path = $target_path . basename( $_files['uploadedfile']['name']); if(move_uploaded_file($_files['uploadedfile']['tmp_name'], $ta

javascript - jQuery function issues -

i have adapted someones example (from previous stack overflow question asked) want, doesn't seem working. if helps here link question the function isn't working: $(window).scroll(function(){ if ($('.orange').isonscreen() === 'true'); { $('.box').css('background', 'red'); } }); here jsfiddle when orange square comes screen, rest of squares should change red, , when orange square not on screen, red squares need turn blue again. there few problems in syntax, this, though unoptimized, should work $(window).scroll(function(){ //isonscreen returns boolean, loose comparison if ($('.orange').isonscreen()){ $('.box').css('background', 'red'); } else { //you need revert when isonscreen returns false $('.box').css('background', 'blue'); } });

c++ - USB Programming with Qt -

is there anyway can usb programming in qt? using qt creator 2.6 based on qt version 5.0.0 , latest qt creator works microsoft visual studio 2010 compiler. i have toy called " dreamcheeky thunder missile launcher " , need program usb based device. i have tried libusb messed everything. renamed device port , had undo using usbdview software. guess installed incorrectly. followed these instructions . instructions 64 bit, got 32 bit , since instructions seems not have big difference (instead download file) followed it. downloaded - libusb-win32-bin-1.2.6.0.zip whatever api recommend doesn't matter, libusb, please kind enough tell me how install properly. my os windows 7 ultimate 32 bit. there's instruction libusb here: http://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/ libusb : libusb libusb-win32 (windows port - use on windows!) if stay on windows can use winusb : winusb api example installation for

ios - iPad Modal "Log In" View -

Image
i've never developed ipad before (just iphone) , there views see on ipad cannot on iphone. specifically, i'm trying create modal 'login/register' type view , i'd mimic , feel of log in view in zillow ipad app. in zillow when press 'log in' (or settings matter), background darkens , window appears in middle of screen modally flip animation it's horizontal axis. here given view containing buttons, text fields, toggle switches, etc. is there cocoa class type of view on ipad? can have regular uiviewcontroller not take entire screen , display 'on top' of root view controller? edit: discovered in view controller attributes inspector, under simulated metrics size, there form sheet option looks similar going for. these display on-top of root views? you present view modally, or in storyboard, modal segue. in inspector segue, can change presentation default "form sheet". if you're doing modal presentation in code, can s

javascript - Writing a for loop to create divs -

what trying write loop create number of divs. number of divs depends on information have in database. example there 15 checkboxes, need loop create div each checkbox user clicked. i'm not worried mysql side of things right now, i'm focusing on loop. so have main div 800px wide. let's user clicks 8 checkboxes, want figure out how write loop create 2 rows of 4 divs, each 200px wide. 4 divs on each row. doesn't matter in div right need know how tackle this. any ideas lead me in right direction? here code: $(document).ready(function(){ for(i = 0; < (the number of checkboxes clicked); i++) { $('body').append('<div id="div'+ +'" />'); } }); then div have same css code width 200px blah blah blah... i guess need checkboxes clicked database , make div each checkbox. why not use css this? <input type="hidden" id="checkboxcount" value="[# of checkboxes checked]" /

html - jquery tab in fluid layout -

i'm facing problem don't manage solve myself... that's why need ;-) my problem when add jquery tab in fluid part of fixed-left-list/fluid-detail layout. top of tab totally destroyed. i found when clear float of detail div, tab normal. that's not want do... :-( here code: http://jsfiddle.net/mr63q/ what advice on problem ? many in advance! cedric. already discussed: css layout: 2 column fixed-fluid (again) .ui-helper-clearfix { clear: none; overflow: hidden; }

css - Why does this selector not work -

given following markup <div class="fixed"> <div class="clmn2"> </div> <div class="clmn2"> </div> </div> and information given on mdn by interpretation selector should work. *:not(.fixed) [class*="clmn"] unfortunately not, does. div:not(.fixed) [class*="clmn"] any ideas why? * update * if check linked fiddle column in rows not marked class fixed should floated. *:not(.fixed) foo matches a foo element descendant of element not member of fixed class this different to: a foo element not descendant of element member of fixed class if had: <a class="fixed"> <b> <foo></foo> </b> </a> then foo element descendant of b element not member of fixed class. (it also descendant of a element is member of class, doesn't matter because *:not(.fixed) happily match b element instead.)

android - Syncing multiple providers with one SyncAdapter -

i want sync com.android.contacts , com.android.calendar 1 syncadapter. possible? if yes, how have edit following lines? <sync-adapter xmlns:android="http://schemas.android.com/apk/res/android" android:contentauthority="com.android.contacts" android:accounttype="com.package.account" android:supportsuploading="false" android:uservisible="true" /> appearently not: "each syncadapter spins syncthread bound authority defined in sync-adapter.xml, , multiple authorities cannot defined in xml file..." (kianatennyson) how use 1 syncadapter-class multiple authorities?

java - Tomcat 7 exception when cookie contain umlaut characters -

i'm developer , face exception below when cookie contain umlaut characters (ä,ö,ü), tried many solutions , configurations without result. i use tomcat7 any solution please feb 21, 2013 6:29:16 org.apache.coyote.http11.abstracthttp11processor process severe: error processing request java.lang.illegalargumentexception: control character in cookie value or attribute. @ org.apache.tomcat.util.http.cookiesupport.ishttpseparator(cookiesupport.java:193) @ org.apache.tomcat.util.http.cookies.gettokenendposition(cookies.java:488) @ org.apache.tomcat.util.http.cookies.processcookieheader(cookies.java:291) @ org.apache.tomcat.util.http.cookies.processcookies(cookies.java:168) @ org.apache.tomcat.util.http.cookies.getcookiecount(cookies.java:106) @ org.apache.catalina.connector.coyoteadapter.parsesessioncookiesid(coyoteadapter.java:919) @ org.apache.catalina.connector.coyoteadapter.postparserequest(coyoteadapter.java:688) @ org.apache.catalina.connecto