Posts

Android String.format() Returns Question Mark (??) [FIXED] -

i have app downloads files internet. source file name dynamically generated depending on user selection. use following method create source file name. note fileid integer (1-99). final string filename = "file_" + string.format("%02d", fileid) + "_download.jpg"; the issue have seen users unable download files (and of course leave 1 start ratings :( ). when check server log see download requests came file names file_??_download.jpg . looks string.format() has returned ?? instead of 2 digit number. i searched everywhere , not find solution this. can tell me what's wrong code? not re-produce error on of devices. thanks! you have instead: final string filename = "file_" + string.format("%d", fileid) + "_download.jpg"; or final string filename = "file_" + fileid + "_download.jpg"; if want 2 last digits, it: int formattedfileid = fileid % 100; final string filename = "fil...

c - How to properly parse numbers in an arithmetic expression, differentiating positive and negative ones? -

i have assignment in data structures class in have program calculator solves arithmetic expressions 4 basic operations , parenthesis, input done via stdin buffer , same output. it easy @ beginning, teacher provided algorithms (how transform expression infix postfix , how evaluate it) , goal implement our own stack , use it, calculator not work quite well, , think because of parser. this algorithm , , code, used parse numbers, operators , parenthesis while putting them array store expression in way easier evaluate later. // saida array of pairs of integers, first value of pair value of info (the number or ascii value of operator) // second value indicator of whether number or operator (i = 0; < exp_size; i++) { c = expression[i]; // if current char digit, store helper string , keep going until non-digit found // atoi() used transform string int , store it. if (c >= '0' && c <= '9') { j = 1, k = i+1; tempint[0] =...

python - Preserving order of occurrence with size() function -

Image
i preserve order of dataframe when using .size() function. first dataframe created choosing subset of larger one: df_south = df[df['region_name'] == 'south'] here example of dataframe looks like: with dataframe count occurrences of each unique 'tempbin_cons' variable. south_count = df_south.groupby('tempbin_cons').size() i maintain order exists using sort column. created column based on order 'tempbin_cons' variable appear after counting. can't seem appear in proper order though. i've tried using .sort_index() on south_count , not change order groupby() creates. ultimately solution fixing axis ordering of bar plot creating of south_count. ordering difficult read , appear in logical order. for reference south_count, , subsequently axis of bar plot appears in order: try this: south_count = df_south.groupby('tempbin_cons', sort=false ).size() looks though data sorted string.

laravel - Edit active database on the fly -

so i'm working on little web application in can manage database. now can use following function retrieve databases db::select('show databases') but want able tables each of databases , more databases, figured if working wouldn't problem. normally you'd have different database in config, since want application work "any" database , make sure don't have manually add databases etc since that's kind of work want web app done me. i've tried tricking around bit without success example. db:select('use dbname; show tables'); db::select('select dbname(); show tables'); obviously didn't work, there "proper" solution this? thought editing .env variable on fly might've been option, can't seem find "legit" way either. you don't need this. i thought editing .env variable on fly might've been option, can't seem find "legit" way either. what need this ...

jboss - create ActiveMQ MQTT broker to connect to Moquitto broker -

i want use activemq create broker connect mosquitto broker. , then, can use activemq receive message mosquitto broker. what done is: integrate activemq jboss eap 6.3. create mqtt broker in activemq: http://activemq.apache.org/mqtt.html but after add networkconnector in broker-config.xml: <transportconnectors> <transportconnector name="openwire" uri="tcp://localhost:61616"/> <transportconnector name="mqtt" uri="mqtt://localhost:1883"/> </transportconnectors> <networkconnectors> <networkconnector uri="static:(tcp://mosquitto_server_ip:1883)"/> </networkconnectors> the server shows exception after starting: "network connection between vm://localhost#8 , tcp:///mosquitto_server_ip:1883@42688 shutdown due remote error: java.util.concurrent.timeoutexception" i try use "mqtt://..." connect, it's still failed: java.lang.illegalargumentexc...

regex - Is it possible to mark the n-th occurrence of a pattern with n in vim? -

say have text following. the man walking, , man eating. how should use substitution convert following? the man 1 walking, , man 2 eating. i know can use :%s/\<man\>//gn count number of occurrences of word man , know /\%(\(pattern\).\{-}\)\{n - 1}\zs\1 can find n-th occurrence of pattern. how mark n-th occurrence? any sincerely appreciated; in advance. you'll need have non-pure function counts occurrences, , use result of function. " untested let s:count = 0 function! count() let s:count += 1 return s:count endfunction :%s/man\zs/\=' '.count()/

android - Logical concurrency issue with Picasso in custom View -

i creating custom view displays image bitmap loaded picasso framework. initialize need both bitmap , view measure. struggling threading cannot predict thread finish earlier. the view starts picasso custom target in constructor. saves view's width , size in onsizechanged . public class figureview extends view { public figureview(context context) { super(context); target = new loadpicturetarget(); picasso.with(getcontext()).load(r.drawable.amalka).into(target); } protected void onsizechanged(int w, int h, int oldw, int oldh) { super.onsizechanged(w, h, oldw, oldh); tilesrect.set(0, 0, w, h); } and target sets bitmap , computes resized picture dimensions fit view's available space: class loadpicturetarget implements target { public void onbitmaploaded(bitmap bitmap, picasso.loadedfrom from) { basebitmap = bitmap; origpicturerect = new rect(0, 0, basebitmap.getwidth(), basebitmap.getheight()); scaledpicturerect = misc...