Posts

Force Rails Heroku App from subdomain.herokuapp.com to apex domain? -

what proper way send subdomain.herokuapp.com apex domain of application? avoid multiple domain names same content. https://github.com/tylerhunt/rack-canonical-host seems perfect choice this. leaving here else has same question.

android - Starting activity from static method -

i've problem starting activity's. i'm trying start new activity whithin static method. this code that: static dialog dialog=null; public static void nextlevel(context c,string title,string message){ alertdialog.builder alertbox = new alertdialog.builder(c); alertbox.settitle(title); alertbox.setmessage(message); alertbox.setpositivebutton("volgende level", new dialoginterface.onclicklistener() { public void onclick(dialoginterface arg0, int arg1) { } }); alertbox.setnegativebutton("terug naar menu", new dialoginterface.onclicklistener() { public void onclick(dialoginterface arg0, int arg1) { startactivity(new intent(main.this, mainmenu.class)); } }); alertbox.show(); } the startactivity doesn't work because can't start activity static method. can't seem figure out way solve problem because can't create context myself start it. ...

bluej - Java Incompatible Types Error Arraylists -

i'm using bluej ide , whenever try compile java code gives me error: incompatible types highlighting brackets of: s.getcourtsportarraylist() why happening? public void showcourtbookings() { for(sport s : sportlist) { for(court c : s.getcourtsportarraylist() ) { system.out.println("court: " + c.getcourt); int i; i=1; for(booking b : c.getbookings()) { system.out.println("booking: " + + "start time: " + b.gettimestart() + "end time :" + b.getendtime()); = + 1; } } } } this class club , contains 2 arraylists; private arraylist<member> memberlist; private arraylist<sport> sportlist; the sport class has following arraylist: private arraylist<court> courtlist = new arraylist<court>(); the court class has these arraylists: private arraylist<booking> listbooking; hopefully can point me in right direction. thanks! edit: code, p...

How to get user's google api version on android? -

i'm facing rare problem. have device running on android api 14. anytime try use mapactivity same error - java.lang.noclassdeffounderror: android.security.messagedigest . on other 99% devices works perfect. after digging, i've found root of problem. the error result of device manufacturer or rom creator using older maps library new version of android. (more @ what 'android.security.messagedigest''? ) the functionality of mapactivity isn't required application, want check if user has such device. how can user's google api version on android? use google map v2 . you want use google map console register sha-1 signing key in google api console. the complete tutorial can found here .

java - Offer foreground download to user with possible dialog -

i'm fighting usability design. let's have application has 1 permission, android.permission.internet . i want download image remote url (where cannot control server-side), download user can choose whether , download file. displaying dialog process approval and/or choosing final destination. i have considered these solutions: downloadmanager using setdestinationinexternalpublicdir two bugs, don't want add write_external_storage permission, , user cannot decide whether download or not using intent.action_view launch browser standalone display image user, not initiate download automatically using intent.action_view , custom proxy script server not mine, , don't want provide server-side proxy download forcing script replacing http(s) ftp, , let user decide does not work, images on server not available through ftp providin compatibility download applications (such "download files", various "file managers", ...) how achieve...

Directly accessible data structure Java -

i have following situation: a data structure can ever extended ( ever add things in tail) i need able keep track of elements have seen (i have index, , ideally want able start traversing list again particular element) i reads never blocking, , addition of new element ever lock tail of queue rather whole queue this structure heavily modified multiple threads. what best data structure this? arraylist . ideal able directly access last element seen using index, leads concurrent modifications exceptions. make synchronised, avoid locking (or locking apart last element, 1 there might concurrent writes add new elements) concurrentlinkedqueue . solve concurrency problem, has problem have store current position of iteration rather integer index. has problem returns weakly consistent iterator not guaranteed return new objects have been added list since iterator created (source: javadoc) concurrenthashmap index keys. has benefit can access data corresponding correct index dire...

c# - Threading in a Windows Service -

i've created app uses observable lists. i've made observablelist class threadsafe (i think) , it's working fine in application. now i'm trying install application service. works fine well, untill point gets added list. think thread there dies. i've got following code: /// <summary> /// creates new empty observablelist of provided type. /// </summary> public observablelist() { //assign current dispatcher (owner of collection) _currentdispatcher = dispatcher.currentdispatcher; } /// <summary> /// executes action in right thread /// </summary> ///<param name="action">the action should executed</param> private void dodispatchedaction(action action) { if (_currentdispatcher.checkaccess()) action.invoke(); else _currentdispatcher.invoke(dispatcherpriority.databind, action); } /// <summary> /// handles event when collection has changed. /// </summary> /// <param name=...

asp.net - Oracle Dual vs Sys.Dual -

i using oracle end asp.net project. have user named test. sequence worked fine (select seq_name.nextval dual;) cannot access dual directly (the sequence work when select seq_name.nextval sys.dual .so have use sys.dual. caused function ora_aspnet_createuser function (asp.net membership) become invalid since guess uses dual rather sys.dual. any clues?

gnu make - automake-ing in bison which works fine with handwritten makefile -

friends, i trying create makefile via gnu-autotools flex+bison+c code (toy code, ma say). handwritten makefile works fine cc=gcc #-g -wall flex=flex bison=bison libs=lfl prog=parse ${prog}:bib.y scan.l main.c ${bison} -d bib.y ${flex} -i scan.l ${cc} -wall main.c lex.yy.c bib.tab.c `pkg-config --cflags --libs gtk+-3.0 glib-2.0` -${libs} -o $@ clean: rm -f lex.yy.c bib.tab.h ${prog} bib.tab.c touch scan.l bib.y main.c only giving warnings unused variables: $ make -f makefile bison -d bib.y flex -i scan.l gcc -wall main.c lex.yy.c bib.tab.c `pkg-config --cflags --libs gtk+-3.0 glib-2.0` -lfl -o parse main.c: in function ‘main’: main.c:35:8: warning: type defaults ‘int’ in declaration of ‘yy_create_buffer’ [-wimplicit-int] main.c:35:8: warning: unused variable ‘yy_create_buffer’ [-wunused-variable] lex.yy.c:1120:17: warning: ‘yyunput’ defined not used [-wunused-function] lex.yy.c:1161:16: warning: ‘input’ defined not used [-wunused-function] bib.y: in ...

How to highlight several countries using Google Chart API by country code? -

i have simple request selects country on map code (e.g. fr france) in google chart: http://chart.apis.google.com/chart?&cht=t&chs=440x220&chtm=europe&chco=f5f5f5,edf0d4,6c9642,13390a&chld=fr&chd=s:fr i know can extended selecting several countries cannot construct proper request. can give example of how (e.g. highlighting fr , it)? i think got syntax more or less: http://chart.apis.google.com/chart?&cht=t&chs=440x220&chtm=europe&chco=f5f5f5,edf0d4,6c9642,13390a&chld=fr|it|cz|de&chd=s:afhx so 1 should use "|" separate countries , provide enough color using alphanumeric encoding (1 char per country)

PHP: Best practice regarding "public" visibility in OOP -

do add public beside methods , properties inside classes? or leave out? 1. option 1, without public: <?php class simpleclass { // property declaration $var = 'a default value'; // method declaration function displayvar() { echo $this->var; } } ?> 2. option 2, public: <?php class simpleclass { // property declaration public $var = 'a default value'; // method declaration public function displayvar() { echo $this->var; } } ?> personally think adding public adds little more clarity code, though considered best practice? best practice pick coding standard , follow (and put info somewhere in code). i guess psr commonly used in php: https://github.com/php-fig/fig-standards/tree/master/accepted and according psr-2: "visibility must declared on properties." so second option way go. you can check this: http://www.phptherightway.com/

java - liferay portlet soap client, proxy authentication -

i have portlet deployed in liferay portal (windows) somewhere makes call soap service like: url url = new url("https://walter.dia.fi.upm.es:8443/integrate_collaborative_tools/services/semanticinteroperabilitylayer?wsdl"); string namespace = "http://queryengine"; string servicename = "semanticinteroperabilitylayer"; qname serviceqn = new qname(namespace, servicename); service service = service.create(url,serviceqn); qname qn = new qname(namespace,"semanticinteroperabilitylayerhttpssoap11endpoint"); semanticinteroperabilitylayerporttype porttype=service.getport(qn,semanticinteroperabilitylayerporttype.class); now, need deploy test server behind proxy. how going alter liferay, os or code configuration in order authenticate proxy?

python - copy.deepcopy or create a new object? -

i'm developing real-time application , need create instances new objects same data. first, did instantiating them, realised maybe copy.deepcopy faster. now, find people deepcopy horribly slow. i can't copy.copy because object has lists. my question is, know faster way or need give , instantiate them again? thank time i believe copy.deepcopy() still pure python, it's unlikely give speed boost. it sounds me little classic case of optimisation. suggest writing code intuitive which, in opinion, instantiating each object. can profile , see savings need made, if anywhere. may in real-world use-case different piece of code bottleneck. edit: one thing forgot mention in original answer - if you're copying list, make sure use slice notation ( new_list = old_list[:] ) rather iterating through in python, slower. won't deep copy, however, if lists have other lists or dictionaries you'll need use deepcopy() . dict objects, use copy() method. if...