Posts

Showing posts from March, 2010

android - Move an object from one Activity to a Service -

android - Move an object from one Activity to a Service - i need move object activity service. effort @ activity side. waveform waveform = new waveform(); intent intent = new intent(this, stimulationservice.class); bundle bundle = new bundle(); bundle.putparcelable("test", (parcelable) waveform); intent.putextras(bundle); startservice(intent); i have placed code in onstart() function in service. bundle bundle = this.getintent().getextras(); if(bundle!=null) mwaveform = bundle.getparcelable(waveform); i'm getting errors function "getintent" , "waveform" within getparcelable(). help or guidance appreciated. services don't have getintent method. instead intent passed in argument onstart method. should utilize parameter instead. the getparcelable method takes string , in case of test code, should "test" . android android-intent android-activity

youtube api - Would it be possible to fetch videos on a certain tag published between certain dates -

youtube api - Would it be possible to fetch videos on a certain tag published between certain dates - we utilize google-api-java-client lookup videos , know if possible fetch videos on tag (say sports) published between dates (starting yesterday till now). how do this? i able using google-api-client 1.6.0-beta (downloaded via maven). modified illustration code little. api had changed since illustration code written. added query parameters youtube api reference guide , extended video class include couple more fields. if @ raw json returned query see add together several others fields including thumbnails, duration, aspect ratio, comment count etc. hope helps. import com.google.api.client.googleapis.googleheaders; import com.google.api.client.googleapis.json.jsoncparser; import com.google.api.client.http.*; import com.google.api.client.http.javanet.nethttptransport; import com.google.api.client.json.jsonfactory; import com.google.api.client.json.jackson.jacksonfac...

Android TimePicker SetTitle UIThread Issues -

Android TimePicker SetTitle UIThread Issues - i understand calledfromwrongthreadexception exception means, cannot comprehend how code have written isn't executing on uithread in situation. in main activity create handler. private final handler handler = new apphandler(this); in oncreatedialog method of activity, using constructor suggested android examples of timepicker dialogues. since getting calledfromwrongthreadexception in way didn't understand , wasn't reproducible on devices or emulator, tried pass reference of activity in create dialogue constructor. so code create dialog looks this. @override protected dialog oncreatedialog(int id) { final calendar c = calendar.getinstance(); switch (id) { case time_dialog_id: homecoming new timepickerdialog(this, this, gethandler(), mtimesetlistener, c.get(calendar.hour_of_day), 0, false); the first instance of "this" gets used context dialog, se...

c# - How can I find the first regex that matches my input in a list of regexes? -

c# - How can I find the first regex that matches my input in a list of regexes? - is there way write following? string input; var match = regex.match(input, @"type1"); if (!match.success) { match = regex.match(input, @"type2"); } if (!match.success) { match = regex.match(input, @"type3"); } basically, want run string thru gammut of expressions , see 1 sticks. var patterns = new[] { "type1", "type2", "type3" }; match match; foreach (string pattern in patterns) { match = regex.match(input, pattern); if (match.success) break; } or var patterns = new[] { "type1", "type2", "type3" }; var match = patterns .select(p => regex.match(input, p)) .firstordefault(m => m.success); // in original example, match lastly match if // unsuccessful. expect accident, if want // behavior, can instead: var match = patterns .select(p => regex.match(inp...

netty - How would you extend a Channel? -

netty - How would you extend a Channel? - i need little help netty. wondering how extend channel interface , add together own methods , create netty utilize (or cast it)? matt. i guess improve solution "wrap" channel class store class in channellocal or in channelhandlercontext. jsut retrieve implementation , utilize it. allow switch between nio , oio without need worry implementation. i'm doing similar in niosmtp: https://github.com/normanmaurer/niosmtp/blob/master/src/main/java/me/normanmaurer/niosmtp/transport/netty/nettysmtpclientsession.java this helps decouble code. to provide own channel need hack socket implementation. think should avoid whenever possible. netty

python - Regular Expression for Email address -

python - Regular Expression for Email address - here weird regular look emails . we can have various kind of email addresses string1@somemail.com string1@somemail.co.in string1.string2@somemail.com string1.string2@somemail.co.in the next regular look can find of mails above email2="santa.banta@gmail.co.in" email1="arindam31@yahoo.co.in'" email="bogusemail123@sillymail.com" email3="santa.banta.manta@gmail.co.in" email4="santa.banta.manta@gmail.co.in.xv.fg.gh" email5="abc.dcf@ghj.org" email6="santa.banta.manta@gmail.co.in.org" re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email) x=re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email2) x.group() santa.banta@gmail.co.in' x=re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email1) x.group() arindam31@yahoo.co.in' x=re.search('\w+[.|\w]\w+@\w+[.]\w+[.|\w+]\w+',email) x.group() 'bogusemail123@sillymail.com...

javascript - How do I test if an element with a certain ID exists on a page in jQuery? -

javascript - How do I test if an element with a certain ID exists on a page in jQuery? - in jquery, have written piece of code appears on every page of website. var d = $('#someelement').offset().top; however, not every page on website has element id of "someelement". unfortunately, on these pages lack such element, no jquery code works. to solve problem, want test if element on page indeed has id of "someelement" , run code snippet above if there is. how perform test? test solve problem? give thanks you. $('#someelement').length homecoming 1 if element exists, 0 otherwise. javascript jquery

c++ - for_each print data not correct -

c++ - for_each print data not correct - i learning opencl, , trying write "hello world" example; create platform, device, , context. now want device info device create , save info in vector print them. using clgetdeviceinfo . the problem homecoming info phone call in different format , trying write print function print data, have problem when utilize for_each print data. can' print of info because can pass 1 type info print function, , print function prints info in same type only. remaining info prints incorrectly. the homecoming info clgetdeviceinfo http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clgetdeviceinfo.html template <typename t > void print (void *data ) { boost::any _t = static_cast<t> (data); cout << boost::any_cast<t> (_t) << endl << endl; } cl_device_info devinfo_list[] = { cl_device_type , cl_device_vendor_id , cl_device_max_compute_units , cl_device_max_work_item...

Iterating over a dictionary in python and stripping white space -

Iterating over a dictionary in python and stripping white space - i working web scraping framework scrapy , bit of noob when comes python. wondering how iterate on of scraped items seem in dictionary , strip white space each one. here code have been playing in item pipeline.: for info in item: info[info].lstrip() but code not work, because cannot select items individually. tried this: for key, value item.items(): value[1].lstrip() this sec method works degree, problem have no thought how loop on of values. i know such easy fix, cannot seem find it. help appreciated. :) not direct reply question, suggest @ item loaders , input/output processors. lot of cleanup can take care of here. an illustration strips each entry be: class itemloader(itemloader): default_output_processor = mapcompose(unicode.strip) python dictionary whitespace scrapy

javascript - how to start svg application using Cross Platform? -

javascript - how to start svg application using Cross Platform? - hi new in svg development planning create simple application can run on mobile oses, blackberry, windows mobile, android phones, iphone , web also.how can start web application using svg files(test.svg,indiastates.svg) please forwards solution thanks in advance narasimha apache cordova (the apache project version of phonegap) allows write cross-platform mobile apps using technologies traditionally used client-side web development. i can't speak svg back upwards across platforms cordova covers, android , iphone (at least) utilize webkit derived browsers , should able handle svg. i'd expect of other platforms have back upwards too. javascript html5 svg cross-platform

php request vars in sef urls -

php request vars in sef urls - i have page (ie www.mysite.com/products.php?catid=5 ) in utilize $_request[catid'] category id , utilize in query. switched sef urls , urls display www.mysite.com/products/category/5 how can utilize new urls retrieve catid value? the next lines used in .htaccess file switching sef urls: rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^/index.php rewritecond %{request_uri} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [nc] rewriterule (.*) index.php rewriterule .* - [e=http_authorization:%{http:authorization},l] you need rewrite url correspondingly using mod_rewrite example. rewriterule ^(.*)$ index.php?url=$1 [nc,qsa] this rule rewrite url www.mysite.com/products/category/5 www.mysite.com/index.php?url=products/category/5 . point on can parse variable $_get["url"] or refine rewrite rule. php sef

mysql - MS sql limit statment without order by and without top -

mysql - MS sql limit statment without order by and without top - i've orm layer can communicates several dbs, mysql,oracle,ms sql , i'am usign pagging in applications, didn't know can results pages straightfully query, updating orm layer fit 3 dbs mentioned. in mysql select * mytable limit 5,5 in oracle select * ( select * mytable t rownum < 100 ) wehre rownum > 10 in ms sql cant find way of order by in query i apologize syntax errors in queries, memory. my question is, there way rid of order by , paging capabilities ms sql please re-think doing here. no matter database engine you're using, makes absolutely no sense seek rid of order by when want utilize paging. rows in relational databases don't have fixed order, need specify order by clause if want receive rows in order. if don't specify order by clause, database engine homecoming rows in random order. order looks sensible (like, ordered primary key) , if run same query ...

Hadoop data nodes stops reporting -

Hadoop data nodes stops reporting - i have 4 node (master + 3 slave) cluster running hadoop 0.20.203.0. every few days, datanodes become reported dead on master. on slave, appears fine , datanode process still running, nil suspicious in logs, although no longer receiving requests. on master, logs show datanode heartbeat has been lost. the solution manually stop datanode , start again. after several minutes datanode becomes reported live again. has else experienced this? if cause, , solution? we had similar problem, solusion increment open file limit. try add together line ulimit -n 4096 file hadoop-env.sh hadoop

nstimer - Is Asynchronous NSURLconnection in anyway helpful for real time update or sending constant request to the server in an iOS app? -

nstimer - Is Asynchronous NSURLconnection in anyway helpful for real time update or sending constant request to the server in an iOS app? - i'm much new objective c. have case need send request server url @ regular intervals. made asynchronous url connection , used nstimer function phone call viewwillappear function. - (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; nsurlrequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:@"myurl/test.csv"] cachepolicy:nsurlrequestuseprotocolcachepolicy timeoutinterval:15.0]; nsurlconnection *connection= [[nsurlconnection alloc] initwithrequest:request delegate:self]; if(connection){ label.text = @"connecting..."; }else{ // } } -(void)connection :(nsurlconnection *) connection didreceivedata:(nsdata *)data{ [self viewwillappear:true]; response = [[nsstring alloc] initwithdata:data encoding:ns...

Hibernate SchemaExport command line -

Hibernate SchemaExport command line - i found documentation http://docs.jboss.org/hibernate/core/4.0/manual/en-us/html/toolsetguide.html#toolsetguide-s1-3 saying can run schemaexport using command line java -cp hibernate_classpaths org.hibernate.tool.hbm2ddl.schemaexport options mapping_files can please provide illustration of how used? format of classpath (perhaps illustration classpath), how do hbm.xml mapping? thanks not problem :) example: java -cp "hibernate/*" org.hibernate.tool.hbm2ddl.schemaexport --properties=hibernate.properties --text person.hbm.xml user.hbm.xml here "hibernate/*" means have folder named "hibernate" libraries hibernate (incl. hibernate3 of course). in case: antlr-2.7.6.jar cglib-2.2.jar commons-collections-3.1.jar dom4j-1.6.1.jar hibernate-testing.jar hibernate3.jar javassist-3.9.0.ga.jar jta-1.1.jar log4j-1.2.16.jar slf4j-api-1.5.8.jar slf4j-log4j12-1.6.1.jar you have set in current folder f...

c# - Deserialize multiple xml files into objects -

c# - Deserialize multiple xml files into objects - i have programme that'll serialize number of different objects xml files stored on disk, arbitrary name (i can't alter naming)... how deserialize these objects again?? as can see it, need read xml file using xml doc reader figure out type of object stored in each file, , utilize type when creating instance of deserializer. seems lot of work first load file xml , deserialize right object... is there smarter way? there exist library doing this? you have xmlserializer each class, , seek candeserialize method each xml file. c# xml serialization

What is best solution to get next and previous month from given date php -

What is best solution to get next and previous month from given date php - i want next , previous month given date. code. $month = '2011-01-20'; $prevmonth = funp($month); $nextmonth = funn($month); what best solution that. $next_month_ts = strtotime('2011-01-20 +1 month'); $prev_month_ts = strtotime('2011-01-20 -1 month'); $next_month = date('y-m-d', $next_month_ts); $prev_month = date('y-m-d', $prev_month_ts); php

Managing global objects with side effects when reloading a module in Python -

Managing global objects with side effects when reloading a module in Python - i looking way correctly manage module level global variables utilize operating scheme resource (like file or thread). the problem when module reloaded, resource must disposed (e.g. file closed or thread terminated) before creating new one. so need improve pattern manage singleton objects. i've been reading docs on module reload , quite interesting: when module reloaded, dictionary (containing module’s global variables) retained. redefinitions of names override old definitions, not problem. if new version of module not define name defined old version, old definition remains. feature can used module’s advantage if maintains global table or cache of objects — seek statement can test table’s presence , skip initialization if desired: try: cache except nameerror: cache = {} so check if objects exist, , dispose them before creating new ones. python mo...

jquery - How to cancel an ajax request in Django when new page is requested -

jquery - How to cancel an ajax request in Django when new page is requested - in web page (built on django platform), have jquery requests server info via ajax request. how prevent error function executing when click away page before ajax request has responded. here jquery call: $(document).ready(function() { $.ajax( { url:'/server/url/', type: 'post', data: {some..data}, success:function(response) { stuff response }, error: function() {alert('error')} }); how prevent alert happening when click away page (to new page)? define global variable: var ajaxcancel = false; no need create true if user closes window: $(window).bind("beforeunload", function() { ajaxcancel = true; }); and alter ajax error line check value of variable first: ... error: function() {if (!ajaxcancel) alert('error'); } ... jquery ajax django

python - What is the best way of creating a list of querysets in django? -

python - What is the best way of creating a list of querysets in django? - i have model class "place", has field "state", , list of querysets grouped available distinct states in db. i doing this: place_list = [] places = place.objects.distinct('state') [place_list.append( place.objects.filter(state=p.state) ) p in places] is there improve aggregate command utilize optimizing this? best way this? ~ using python 2.6, django 1.3.1 from collections import defaultdict places_by_state = defaultdict(list) place in place.objects.all(): places_by_state[place.state].append(place) list_of_places_by_state = places_by_state.values() that hits database once, rather 1 time per state original version (assuming utilize results), end list of lists instead of list of querysets. python django

How do you link two elements together when they have the same name in xslt? -

How do you link two elements together when they have the same name in xslt? - i have these trees, 1 construction /cars/car , sec /maker/cars/car. first 1 has reference id of sec list of cars. <xsl:template match="t:cars/t:car"> <tr> <td> <xsl:if test="position()=1"> <b><xsl:value-of select="../@name"/><xsl:text> </xsl:text></b> </xsl:if> </td> </tr> i have this, filled in loop larn after bit could't it. this before: <xsl:template match="t:cars/t:car"> <tr> <td> <xsl:if test="position()=1"> <b><xsl:value-of select="../@name"/><xsl:text> </xsl:text></b> </xsl:if> <xsl:for-each select="/t:root/t:maker/t:car"> <xsl:if test="t:root/t:maker/@id = @ref"> ...

java - R can not be resolved while using MediaPlayer -

java - R can not be resolved while using MediaPlayer - import android.media.mediaplayer; mediaplayer mp = mediaplayer.create(moschipactivitysec.this, r.raw.button); here button .mp3 sound file resides in raw folder in res,getting r not resolved! two things might causing this. firstly have @ imports section of class. eclipse imports different r file, causes error. if there's in imports imports random r file delete line. otherwise r file hasn't been created properly, clean , rebuild fixes, other times i've had delete r file , rebuild. if neither of these prepare allow know. java android eclipse android-intent eclipse-plugin

clojure - Can't load-file -

clojure - Can't load-file - i have file male_female.clj in next directory on windows: c:\documents , settings\vreinpa\my documents\books\programmingclojure\code\src\examples before starting repl, switch directory: u:\>c: c:\>cd c:\documents , settings\vreinpa\my documents\books\programmingclojure\code\src\examples i start repl: c:\documents , settings\vreinpa\my documents\books\programmingclojure\code\src\examples>lein repl warning: classpath not declared dynamic , not dynamically rebindable, name suggests otherwise. please either indicate ^:dynamic classpath or alter name. repl started; server listening on localhost:13278. i seek load file, next error: user=> (load-file "male_female.clj") user=> filenotfoundexception male_female.clj (the scheme cannot find file specified) java.io.fileinputstream.open (:-2) what doing wrong here? file in directory changed before starting repl. are working programming clojure repo? ...

parsing an xml file for unknown elements using python ElementTree -

parsing an xml file for unknown elements using python ElementTree - i wish extract tag names , corresponding info multi-purpose xml file. save info python dictionary (e.g tag = key, info = value). grab beingness tags names , values unknown , of unknown quantity. <some_root_name> <tag_x>bubbles</tag_x> <tag_y>car</tag_y> <tag...>42</tag...> </some_root_name> i'm using elementtree , can extract root tag , can extract values referencing tag names, haven't been able find way iterate on tags , info without referencing tag name. any help great. thank you. from lxml import etree et xmlstring = """ <some_root_name> <tag_x>bubbles</tag_x> <tag_y>car</tag_y> <tag...>42</tag...> </some_root_name> """ document = et.fromstring(xmlstring) elementtag in document.getiterato...

ios - Using multiple nib files with a single view controller? -

ios - Using multiple nib files with a single view controller? - background i'm using interface builder create ui app i'm working on. app has single screen displays series of buttons. clicking on button displays associated view overlays buttons. clicking button hides previous overlay view , displays one. too create managing ui easier in ib i've decided create multiple nib files each sub view appear when clicking relevant button. i'm loading sub view's nib file in view controller's viewdidload method using uinib class. the thought behind avoid having multiple views stacked on top of each other in single nib file hard manipulate in ib. have created views in code require lot of tedious coding layouts of each sub view quite complex (with multiple kid views). example code loading sub view nib file. - (void)viewdidload { uinib *asubviewnib = [uinib nibwithnibname:@"asubview" bundle:nil]; nsarray *bundleobjects = [asubviewnib insta...

recursion - How does the the fibonacci recursive function "work"? -

recursion - How does the the fibonacci recursive function "work"? - i'm new javascript , reading on it, when came chapter described function recursion. used illustration function find nth number of fibonacci sequence. code follows: function fibonacci(n) { if (n < 2){ homecoming 1; }else{ homecoming fibonacci(n-2) + fibonacci(n-1); } } console.log(fibonacci(7)); //returns 21 i'm having problem grasping function doing. can explain what's going on here? i'm getting stuck on 5th line, function calls itself. what's happening here? you're defining function in terms of itself. in general, fibonnaci(n) = fibonnaci(n - 2) + fibonnaci(n - 1) . we're representing relationship in code. so, fibonnaci(7) can observe: fibonacci(7) equal fibonacci(6) + fibonacci(5) fibonacci(6) equal fibonacci(5) + fibonacci(4) fibonacci(5) equal fibonacci(4) + fibonacci(3) fibonacci(4) equal fibonacci(3) + fibonacci...

c - condition vs division -

c - condition vs division - given next statement executed lot: inormval = ival / uratio; would next create more sense (performance wise) if uratio == 1 (90%) of time? if(uratio > 1) inormval = ival / uratio; else inormval = ival; thanks.. you need profile measurement, it's hard guess. compiler might decide you're wrong , remove test, check , without optimizing. the actual cost of (integer) partition might rather low, on modern desktop-class processors. according this pdf, costs on modern (wolfdale/nehalem/sandy bridge) of 32/32-bit partition 14-23/17-28/20-28 cycles respectively. so, if lot, might add together up. in case, parallel (vectorized) options if possible. i seek avoid if @ possible, since introduces branch. branches have 2 disadvantages: create code more complex introducing multiple paths programmer reading code has understand, , can introduce execution overhead. c performance division

caching - Symfony2 homepage HTTP cache validation and independently ESI -

caching - Symfony2 homepage HTTP cache validation and independently ESI - i'm designing project has same construction blog symfony2. my home displays articles , have sidebar there links login, or links our business relationship if logged. my sidebar esi, question: if set validation cache on homepage (depending on updated date of lastly article), sidebar display content independently of cache ? otherwise, there solution ? (setting articles list esi, esi can have validation cache ?). thank answers yes, possible have parts of page cached independently. can implemented setting different headers $response: $response->setpublic(); //or $response->setprivate(); //or $response->setsharedmaxage(600); the detailed reply question can found @ symfony2 documentation page. validation caching symfony2 esi

asp.net - Push Notifications to Windows Mobiles -

asp.net - Push Notifications to Windows Mobiles - within asp.net application send force notifications mobile phones. user have client installed on phone. if have android, inquire install notifymyandroid on phone. if have ios inquire install prowl on phone. what best alternative windows mobiles? thanks in advance. push notifications part of wp7 os, read msdn article here: push notifications windows phone your end users not need install create work. asp.net windows-phone-7 push-notification mpns

java - GCHelper raising exception -

java - GCHelper raising exception - i writing programme (called enchanting, allow kids programme lego mindstorms nxt robots more easily) has front-end (based on scratch, , written in squeak smalltalk) , back-end (written in java, using lejos nxj framework). users drag , drop tiles create code; converted java source file , compiled. i have included 32-bit apache harmony jdk, because lejos framework requires 32-bit jdk, , because redistribute despite lejos offering re-implementation of java on embedded computer. things work fine under windows xp, , under windows 7 starter, both of 32-bit oses. on windows 7 (non-starter, 64-bit), backend fails. i've determined harmony. here simplest command produces failure, java -version , , output thereof (with locale set greek -- don't worry, of output english): microsoft windows [Έκδοση 6.1.7600] Πνευματικά δικαιώματα (c) 2009 microsoft corporation. Με επιφύλαξη κάθε νόμιμου δικαιώματος. c:\users\username>cd "\prog...

delphi - Saving RTM files compatible to previous versions of Report Builder -

delphi - Saving RTM files compatible to previous versions of Report Builder - i have study templates saved .rtm files. used application built delphi 5 , reportbuilder 5. now, need alter logo @ top of these study templates, no need rebuild application. working delphi 7 , reportbuilder 11, if seek open , edit .rtm files, new files have new properties not recognized application (outlinesettings, email settings, border.color etc) can save template format compatible study builder 5? the reports needs datapipeline properties, lose them if edit .rtm files outside original project? delphi delphi-7 compatibility delphi-5 reportbuilder

mysql - InnoDB to MyISAM conversion strange performance behaviour -

mysql - InnoDB to MyISAM conversion strange performance behaviour - this may trivial question dont understand it, because afaik myisam should faster i have database containing myisam tables except 1 - it's simple n:m joining table ~130k records. dont know why table innodb, wasnt intentional :) has indexes on both foreign keys pointing associated tables. i tried alter table myisam, cause tought boost performance, instead, queries involved table 50x slower (i tried recreate indexes, didnt help). why that? i suspect replacement indexes aren't getting used. have tried analysing query plan explain? should show whether indexes beingness used, , how. just come in "explain [yourquery];" mysql console. mysql performance innodb myisam

asp.net - RequestContext.RouteData.Route vs Page.RouteData.Route -

asp.net - RequestContext.RouteData.Route vs Page.RouteData.Route - im building high traffic asp.net webforms site. have componentized urls in class. when looking current route of request efficient? calling httpcontext.current.request.requestcontext.routedata.route or sending page.routedata.route method checks see if @ route url. example: public static bool iscurrentroute(string routename) { var route = httpcontext.current.request.requestcontext.routedata.route; if (route == system.web.routing.routetable.routes[routename]) homecoming true; homecoming false; } page.routedata wraps around context.routedata. taken justdecompile [designerserializationvisibility(designerserializationvisibility.hidden)] [browsable(false)] public routedata routedata { { if (base.context != null && base.context.request != null) { homecoming base.context.request.requestcontext.routedata; ...

python - how to check if an iterable allows more than one pass? -

python - how to check if an iterable allows more than one pass? - in python 3, how can check whether object container (rather iterator may allow 1 pass)? here's example: def renormalize(cont): ''' each value original container scaled same factor such total becomes 1.0 ''' total = sum(cont) v in cont: yield v/total list(renormalize(range(5))) # [0.0, 0.1, 0.2, 0.3, 0.4] list(renormalize(k k in range(5))) # [] - bug! obviously, when renormalize function receives generator expression, not work intended. assumes can iterate through container multiple times, while generator allows 1 pass through it. ideally, i'd this: def renormalize(cont): if not is_container(cont): raise containerexpectedexception # ... how can implement is_container ? i suppose check if argument empty right we're starting sec pass through it. approach doesn't work more complicated functions it's not obvious...

wordpress - CSS: IE "ignores" font-family, except for in body -

wordpress - CSS: IE "ignores" font-family, except for in body - i'm having problem getting ie recognise font in wordpress site i'm testing. i'm using helvetica of site, , "harabara" smaller sections. have body's font-family set helvetica , font-family of smaller parts set "harabara". here's @font-face: @font-face { font-family: 'harabarabold'; src: url('/harabara-webfont.eot'); src: url('/harabara-webfont.eot?#iefix') format('eot'), url('/harabara-webfont.woff') format('woff'), url('/harabara-webfont.ttf') format('truetype'), url('/harabara-webfont.svg#webfontheofuywt') format('svg'); font-weight: normal; font-style: normal; } and here's body: body { font-size:100%/130%; line-height: 1; color: black; background: #fff; font-family:helvetica,times new roman,verdana,garamond; width:100%; } and illustration of sub...

What does this PHP notice mean? -

What does this PHP notice mean? - <?php $username="xxx"; $password="xxx"; $database="mobile_app"; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "unable select database"); foreach (array('courseid','roomchosen') $varname) { $$varname = (isset($_post[$varname])) ? $_post[$varname] : ''; } if (isset($_post['prequestion'])) { $roomquery = " select room room (room = '".mysql_real_escape_string($roomchosen)."') "; $roomnum = mysql_num_rows($roomresult = mysql_query($roomquery)); mysql_close(); if($roomnum ==0){ $msg = "this room invalid '$roomchosen'"; } else { $msg = "this room valid '$roomch...

knockout.js - Two way binding in knockoutjs -

knockout.js - Two way binding in knockoutjs - i start using knockoutjs. in below code trying bind div's width in two-way. var viewmodel = function () { this.width = ko.observable(7); }; ko.bindinghandlers.widthbinding = { init: function (element, valueaccessor, allbindingsaccessor, viewmodel) { var div = $(element); var value = valueaccessor(); var width = ko.utils.unwrapobservable(value); div[0].style['width'] = width + "px"; }, update: function (element, valueaccessor, allbindingsaccessor, viewmodel) { var value = valueaccessor(); var width = ko.utils.unwrapobservable(value); div[0].style['width'] = width + "px"; } }; $("#contentdiv").enableresize(); ko.applybindings(new viewmodel()); <input data-bind="value: width" /> <div id="contentdiv" data-bind="widthbinding : width" > in above code have 2 ui element...

flash - IO and HTTP Error 2038 in Flex uploader with PHP backend -

flash - IO and HTTP Error 2038 in Flex uploader with PHP backend - i finished flex app multiupload php project. worked great in every browser. dragged component php project (photo cms) , flex alerts me io error after uploading of every file. ve wrong? both of project on same webserver. difference sec project contains handling sessions (upload in admin area). , works in ie. tips please? php flash flex io

c# - How do I disable keep-alive for a basicHttpRelayBinding to the Azure service bus? -

c# - How do I disable keep-alive for a basicHttpRelayBinding to the Azure service bus? - i'm trying disable http keep-alive , , can't seem find documentation on how accomplish that. ultimately, getting: system.servicemodel.communicationexception: underlying connection closed: connection expected kept live closed server i've heard best approach disable http keep-alive . ultimately solved own issue here little helper function takes basichttprelaybinding , modifies appropriately: private static system.servicemodel.channels.binding getbinding(system.servicemodel.channels.binding bin) { var bout = new custombinding(bin); var transportelement = bout.elements .find<httpsrelaytransportbindingelement>(); transportelement.keepaliveenabled = false; homecoming bout; } c# wcf servicebus azureservicebus

iphone - Secure Textfield value in UIAutomation script -

iphone - Secure Textfield value in UIAutomation script - i have login screen username field , password field. in uiautomation script have accessed password field as var passwordfield = window.securetextfields()["password"]; but when accessed value of passwordfield after entering value via uiautomation script by var password = passwordfield.value(); but getting value password black dots (••••) ie default masking character of iphone. how can real value of password? iphone uitextfield ios-ui-automation

jquery ui selectmenu, regarding changing selected items -

jquery ui selectmenu, regarding changing selected items - i'm trying implement currencty converter succeeded i'm implementing button alter selected alternative between 2 selected menus means if in first menu have usd selected , in sec menu have gbp selected when pressing button, want in first menu have gbp selected , in sec menu usd selected. have manage alter selected alternative on both menus, doesn't display in menu itself. have forgot ? $(function(){ $('a#switchbutton').click(function(){ var $sel1 = $('#fromcurrency'); var val1 = $sel1.val(); var $sel2 = $('#tocurrency'); var val2 = $sel2.val(); $sel1.find("option[value='"+val1+"']").attr("selected",false); $sel1.find("option[value='"+val2+"']").attr("selected",true); $sel2.find("option[value='"+val2+"']").attr("sel...

compiler construction - flex Start Conditions (matching string literals) -

compiler construction - flex Start Conditions (matching string literals) - i'm implementing start status matching c-style strings in flex manual. the segment i'm concerned is: <str>\" { /* saw closing quote - done */ begin(initial); *string_buf_ptr = '\0'; /* homecoming string constant token type , * value parser */ } i have no issue returning token type, i'm unsure how pass string value in situation. if print yytext when token returned, it's holding " terminator. so how string's value? thanks in advance; i'm new flex. you not homecoming yytext homecoming pointer string_buf . yytext contains terminator because content of lastly regular look matched state. in other cases (but terminator) of example, content of yytext copied string_buf (e.g. check lines *string_buf_ptr++=*yptr++; ), buffer holds final string. ...

java - How to write unit tests that tests concurrency invariants -

java - How to write unit tests that tests concurrency invariants - there other questions issue, i'm trying figure how approach unit testing this: public class semaphore extends lock { private atomicinteger semaphore = new atomicinteger(0); public synchronized boolean available() { homecoming semaphore.intvalue() == 0; } public synchronized void acquire() { semaphore.incrementandget(); } public synchronized void release() { semaphore.decrementandget(); } } this homespun locking mechanism (just learning purposes). how test thread safety of this? know there no guarantees when comes unit testing concurrent code, how go writing unit test attempts test obvious invariants inherent in locking mechanism? i guess i'll reply own question since did research. there's great framework called multithreadedtc. allows set tests so: public class safesemaphoretest extend...

Get hash key and convert into string ruby -

Get hash key and convert into string ruby - example hash hash = {:key => ["val1", "val2]} when did on rails 3.0.7, fine. > hash.keys.to_s => "key" > hash[hash.keys.to_s] => ["val1", "val2"] but if rails 3.1.3, isn't. > hash.keys.to_s => [\"key\"] > hash[hash.keys.to_s] => nil is because of rails version changed? , is there other way turn hash key string works both version (or rails 2 too)? did upgrade ruby rails? think alter between 1.8 , 1.9 try hash.keys.first.to_s (if there's 1 key) or hash.keys.join ruby-on-rails-3

how to parse this xml data using php? -

how to parse this xml data using php? - <?xml version="1.0" encoding="utf-8"?> <alexa ver="0.9" url="infosys.com/" home="0" aid="="> <rls prefix="http://" more="62"> <rl href="wipro.com/" title="wipro corporation"/> <rl href="tcs.com/" title="tata consultancy services"/> <rl href="satyam.com/" title="satyam computer services ltd"/> <rl href="ibm.com/" title="ibm corporation"/> <rl href="rediff.com/" title="rediff.com republic of india ltd."/> <rl href="moneycontrol.com/" title="moneycontrol.com"/> <rl href="in.com/" title="in.com"/> <rl href="google.co.in/" title="google india"/> <rl href="www.stiknowledge.com/" title="business pr...

text - Android programming sms messaging -

text - Android programming sms messaging - i'm newbie on android development platform. can 3rd party application (say 1 i'm developing) send sms messages? i believe not have access default text messaging app. hence plan develop 1 on own, read words used , process such texts before delivering receiver. know if there such apis allow send text messages. http://thinkandroid.wordpress.com/2010/01/08/sending-sms-from-application/ i think looking for. sec method described in article not need additional permissions, requires user types message. don't think there way send sms without permission. android text messages

mongodb - Using upsert with push to an array option on Ruby driver -

mongodb - Using upsert with push to an array option on Ruby driver - i'm trying upsert ruby driver mongodb. if row exist wish force new info , array, else create new document 1 item in array. when run on mongodb looks that: db.events.update( { "_id" : objectid("4f0ef9171d41c85a1b000001")}, { $push : { "events" : { "field_a" : 1 , "field_b" : "2"}}}, true) and works. when run on ruby looks that: @col_events.update( { "_id" => bson::objectid.from_string("4f0ef9171d41c85a1b000001")}, { :$push => { "events" => { "field_a" => 1 , "field_b" => "2"}}}, :$upsert=>true) and doesn't work. don't error don't see new rows either. will appreciate help in understanding doing wrong. so couple of issues. in ruby, command should :upsert=>true . note there not $ . docs here. you not running query :safe=>true ....

How do I add custom fields to a User when using django-social-auth -

How do I add custom fields to a User when using django-social-auth - i need add together booleanfield , manytomanyfield users. i'm using django-social-auth. seems utilize 'customuser'. guess that's it's for, how take use? i need know: where define these new fields how add together them new user when user created (ie logs in) how query fields afterwards (ie user.mybooleanfield?) thanks! create model called customuser or userprofile, whatever want, these fields. in settings.py add together setting auth_profile_module = "account.userprofile", named model. in signals social_auth, create sure user has profile, , if not create them when user created. now anywhere in site can phone call user.get_profile() , you'll have access these fields. django django-socialauth

How can I create a GTK combobox with no relief? -

How can I create a GTK combobox with no relief? - i know can remove button's relief with button.set_relief(gtk::relief_none); // gtkmm or gtk_button_set_relief(button, gtk_relief_none); // gtk but there's no corresponding method combobox. what's easiest way accomplish this? combobox gtk gtkmm

Dynamic dependent select menus jQuery PHP version -

Dynamic dependent select menus jQuery PHP version - in previous question made dynamic dependent select menus posted illustration code: http://jsfiddle.net/bs5db/50/. html version of particular jquery script. user @jsweazy helped me pointing should update jquery.uniform script every time select new state first menu. working version of illustration here: http://jsfiddle.net/bs5db/53/. know default alternative big menu fixed.... my problem utilize php version of script. in version updating jquery.uniform $.uniform.update(); doesnt trick. sec menu isnt visible anymore when insert update command. the php version following... $(document).ready(function(){ function populate() { if($('#state').val() == 'ak' || $('#state').val() == 'dc') // alaska , district columbia have no counties { $('#county_drop_down').hide(); $('#no_county_drop_down').show(); } else { fetch.dopost('../getcounties.php'); } }...

Dynamic buttons in jQuery Mobile footer? -

Dynamic buttons in jQuery Mobile footer? - dynamically injecting buttons jqm footers seems exercise in frustration. have clue how apply proper formatting this? here several anomalies found trying this: multi-column button grids not formatted in footer data-corners="false" attribute (to flush buttons) not apply first , lastly buttons in footer with data-role="controlgroup" data-type="horizontal" footer buttons, if there many buttons fit in 1 row styling looks weird (since buttons have rounded corners, others not) if data-role="controlgroup" data-type="horizontal" omitted footer buttons, buttons may rendered partially off screen... in general - argh!!!! have success dynamically injecting buttons footer? if so, much appreciate hear how achieved. thanks! would work: http://jsfiddle.net/eznh8/7/ js $('#addbuttonname').click(function() { var thefooter = $('#addmorebuttons'); var buttonname...

android - sqlite database reading error -

android - sqlite database reading error - hi reading info database created using sqlite manager , copied info folder of application cursor returning 0 when tried print getcount wrong in code below code error unable start activity componentinfo{your.pckage.namespac/your.pckage.namespac.tabaractivity},second error caused by: java.lang.nullpointerexception public class dbhelper { public static final string key_rowid = "id"; public static final string key_name = "name"; public static final string little = "small"; public static final string big = "large"; public static final string type1 = "type1"; public static final string type2 = "type2"; public static final string type3 = "type3"; public static final string tex = "tex"; public static final string origin = "origin"; public static final string description = "description"; publi...

java - Hard coded authentication for easier debugging -

java - Hard coded authentication for easier debugging - to create debugging easier coded authentication hard in application, like: user admin = new user("admin", "pw"); currentuser = admin; i’m lazy , don’t want delete these lines every time publish new version, created property-file debug-flag. when flag set on “true”, application starts in debug-mode without authentication, otherwise log-in shown. but i’m concerned fact, easy admin-access. how solve problem? kind regards stormsam the solution problem not that! this can lead several issues: too easy admin access, state incorrect application behaviour or bad debugging info. might test , debug admin, certainly users not admins! it command path in , of has planned around, coded , tested a improve solution might have mutual admin login , password on dev systems. can automatically type in or code tests. mutual login regular user thought can readily test that. depending on kind o...

java - Default detail formatter for arrays in Eclipse -

java - Default detail formatter for arrays in Eclipse - when debugging java programme in eclipse, in variables view, when highlight variable prints detail variable in pane below. pane called "detail view," , value displayed "detail" variable. default, result of calling .tostring() on variable. eclipse allows specify , customize "detail formatters" arbitrary objects maps them more helpful , descriptive strings in view. my question this: .tostring() method invoked on array (say of integers) returns unhelpful memory address. however, when highlight array variable in debug mode, eclipse seems intelligently parse helpful comma-delimited string (e.g. "[42, 13, null, 19]" ). gather means eclipse has established default detail formatter arrays helpful functionality. does know how can leverage detail formatter in code avoid rewriting identical logic? in case you're interested, motivation generating contents of in clause sql query. is...

Liferay 6.0.6 / JBOSS - How can I edit JavaScript in a portlet without constantly re-deploying? -

Liferay 6.0.6 / JBOSS - How can I edit JavaScript in a portlet without constantly re-deploying? - i'm trying prepare tricky javascript issue in liferay portlet (that happens run big flex app) , every time create change, have go prompt , "ant deploy" on portlet, wait deploy, reload page, wait flex app load. every time seek minor alter takes 3-4 minutes whole process. is there configuration or setting uncompress javascript , allow me straight edit js files on server without re-deploying every time? i've read on "developer mode" doesn't seem working, , liferay docs seem specific tomcat whereas i'm using jboss. if deploying war file, explode in place (in jboss deploy directory), rather having 1 compressed file called flexport.war, have directory called flexport.war have exploded content original war file. if update javascript files, might need clear cache in browser, otherwise should take effect right away. if update classes, can ca...

facebook graph api - Where did the Filter Friends lists go from the Requests dialog? -

facebook graph api - Where did the Filter Friends lists go from the Requests dialog? - so old requests dialog had dropdown "filter friends" allowed user select own custom friends lists. but new requests 2.0 allows select either installed or uninstalled users or create our own set of filters. there way enable old filters? because alternative know requesting user give our app read_friendslists permission , querying lists. the requests dialog has ability allow creator pass in filter lists want show. (see https://developers.facebook.com/docs/reference/dialogs/requests/) need know filter lists able so. check out http://developers.facebook.com/tools/console/. i've found info reading thru various examples. valuable info not disclosed on main documentation pages. came across filter selection dialog. additionally, application can suggest custom filters dictionaries name key , user_ids key, respectively have values string , list of user ids. name n...