Posts

javascript - Math.random() and .replace() cross-browser -

i wrote code generate 10 characters randomly. math.random() gives decimal tostring(36) , numbers replaced. math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10); does have hint why firefox (47.0) , chrome (51) don't handle equally? chrome tests: math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10); "spkcirhyzb" "gcqbrmulxe" "sallvbzqbk" "pcdcufhqet" "knfffqsytm" firefox tests: math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10); "zxntpvn" "hebfyxlt" "zclj" "ormtqw" "cfbsnye" live version: for (var n = 0; n < 5; ++n) { console.log(math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10)); } update (string average): var test; var count = 0; (var n = 0; n < 1000; ++n) { test = math.random().tostring(36).replace(/[^a-z]+/g,'').substr(1,10); cou...

Excel Finding average speed -

i have got 1500 rows of travels. in column have got total time on travel, in column b total km driven. in column c did calculation on average speed of specific travel. whats best way calculate average speed of travels? lengths 0 20 kms approx, time shorter 1 hour. first eliminated travels shorter 2 km managed frequency table , have written frequencies of speeds in 0-5,5-10,... km/h. can histogram, should eliminate more data or how approach problem? in cell enter: =sum(b:b)/sum(a:a) a common error try average values in column c .

Running .bat file before .exe automatically in Advanced Installer -

i'm new advanced installer. after installing file setup, need run ".bat" file before running ".exe" file every time. found add it, setting it's attributes (hidden, vital , system), need run every time before lunching application. please me, thanks if you're launching application finish action dialogs page, here steps: go custom actions page , add launch file custom action without sequence launch bat file enable custom action's "when system being modified (deferred)" , "run under system account full privileges (no impersonation)" options go dialogs page, select exitdialog first time install in install sequence select finish button go published events tab , enable "show events" option add "execute custom action" event passing in "launch file" created above argument set event's condition checkbox's name bat doesn't execute unless user selects checkbox launch applicatio...

jQuery function not working for each selector -

i having difficulties getting code work every selector. have made 2 accordions opening css animation. issue second accordion doesn't work, , animation doesn't work separately both accordions. here source: jsfiddle here jquery im using $('#accordion').find('.accordion-toggle').click(function() { //expand or collapse panel $(this).next().slidetoggle('slow'); //hide other panels $(".accordion-content").not($(this).next()).slideup('fast'); if ($('img').hasclass('moved')) { $('img').removeclass('moved'); } else { $('img').addclass('moved'); } }); try following code ,replace id class use find() find elements relative accordion-toggle $('.accordion').find('.accordion-toggle').click(function() { //expand or collapse panel $(this).next('.accordion-content').slidetoggle('slow'); //hide other panels $("...

python - Polling a subprocess using pid -

i have django project in allows user start multiple subprocesses @ time. processes may take time , user can continue working other aspects of app. @ instance user can view running processes , poll 1 of them check if over. need poll process using pid. popen.poll() expects subprocess.peopen object while have pid of object. how can desired result? in models.py: class runningprocess(models.model): #some other fields p_id=models.charfield(max_length=500) def __str__(self): return self.field1 in views.py: def run_process(): .... p= subprocess.popen(cmd, shell =true, stdout=subprocess.pipe, stderr=subprocess.stdout) new_p=runningprocess() new_p.p_id=p.pid .... new_p.save() return httpresponseredirect('/home/') def check(request,pid): #here want able poll subprocess using p_id e.g like: checkp = pid.poll() #this statement wrong if checkp none: else: else i need valid statement i...

python - Why doesn't `finally: return` propagate an unhandled exception? -

this question has answer here: python try-finally 1 answer why function not raise exception? it's apparently not caught. def f(): try: raise exception finally: return "ok" print(f()) # ok this explicitly explained in the documentation : if exception occurs in of clauses , not handled, exception temporarily saved. finally clause executed. [..] if finally clause executes return or break statement, the saved exception discarded

Predicting with function `arima` producing NaN values in R -

i using arima function intraday forecasting. data available every 15 minute in day. in code below, working fine except few values of in loop. output displayed i=223. predict function produces nan values. have checked dataset, there no nan value there. kindly suggest me how rid of problem. predict1=c() predict2=c() for(i in 1:456){ y1n=ts(nbl$nbp[(12385+(i-1)*4):(15356+(i-1)*4)],frequency=96) y1n[which(is.na(y1n))]=y1n[which(is.na(y1n))-96] arima1=arima(y1n,order=c(1,1,0),seasonal=c(2,1,1),method="css") predict1=predict(arima1,8) predict2[(((i-1)*4)+1):(((i-1)*4)+4)]=predict1$pred[5:8] } arima1 call: arima(x = y1n, order = c(1, 1, 0), seasonal = c(2, 1, 1), method = "css") coefficients: ar1 sar1 sar2 sma1 0.0241 -0.1122 -0.1068 -0.7830 s.e. 0.0188 0.0240 0.0224 0.0189 sigma^2 estimated 1490: part log likelihood = -14583.05 > predict1=predict(arima1,8) > predict1 $pred time serie...