Posts

Showing posts from April, 2011

matlab - Computing Cost function for Linear regression with one variable without using Matrix -

i'm new matlab , machine learning , tried compute cost function gradient descent. the function computecost takes 3 arguments: x mx2 matrix y m-dimensional vector theta : 2-dimensional vector i have solution using matrix multiplication function j = computecost(x, y, theta) m = length(y); h = x * theta; serror = (h - y) .^ 2; j = sum(serror) / (2 * m); end but now, tried same without matrix multiplication function j = computecost(x, y, theta) m = length(y); s = 0; = 1:m h = x(i, 1) + theta(2) * x(i, 2); s = s + ((h - y(i)) ^ 2); end j = (1/2*m) * s; end but didn't same result, , first sure (i use before). you have 2 slight (but fundamental) errors - pretty simple errors though can overlooked. you forgot include bias term in hypothesis: h = x(i,1)*theta(1) + x(i,2)*theta(2); %// ^^^^^^ remember, hypothesis when comes linear regression equal theta^{t}*x . didn't include of theta terms - second term

javascript - Infinite data scroll in Yii2 -

i want make infinite scroll list in yii2 so far have done this, below jquery code $(document).ready(function(){ var postparams ={user_id:'1',start:0,end:15}; $('#notificationlist').ready( function () { $.ajax({ 'url':'../../../frontend/web/app/notificationlist', 'type':'post', 'data': postparams, success: function(data) { var notificationlist = data.notificationlist; var notificationcount = data.notification; if(notificationcount !== 0){ $.each(notificationlist, function (index, value) { mood = notificationlist[index].mood_message; output = '<li id='+index+' value='+notificationcount+'>'+index +'</li>'+ 'first label'+ 'second label'+ 'third label'+

image - Replicate PHP ImageMagick's paintOpaqueImage Function in JavaScript -

imagemagick has function allows scan through picture , replace colors color specify , replace these colors color specify. i'm interested in replicating functionality using javascript. is, apply image filter changes every color approximately red black, instance. how possible? side note: tested out github project somehow manages clone imagemagick's functionality using web workers. sadly, slow (takes 5.632 seconds load image filter want local server.. , i'm trying apply filter twice). it's pretty cool though - https://github.com/manuels/unix-toolbox.js-imagemagick . i wrote quick , dirty webgl code copied https://developer.mozilla.org/en-us/docs/web/api/webgl_api/tutorial/getting_started_with_webgl , http://duriansoftware.com/joe/an-intro-to-modern-opengl.-table-of-contents.html . changing color happens in vertex shader line 14 in html file. <script id="shader-fs" type="x-shader/x-fragment"> varying highp vec2 vtextureco

mongodb - Return array of elements from multiple arrays -

i got collection of companies looks this. want merge other documents deals. need this: { "_id" : objectid("561637942d25a7644cae993e"), "locations" : [ { "deals" : [ { "name" : "1", "_id" : objectid("561637942d25a7644cae9940") }, { "name" : "2", "_id" : objectid("562f868ce73962c626a16b15") } ] } ], "deals" : [ { "name" : "3", "_id" : objectid("562f86ebe73962c626a16b17") } ] } { "_id" : objectid("561637942d25a7644cae993e"), "locations" : [ { "deals" : [ { "nam

r - How to get p_values of features in survreg? -

i working on survival analysis , each time use different test set , @ end have avg of coefficients, p each feature , p value of model. can coefficients using srfit$coefficients. don't know how p values, although can see them using summary(srfit). summary(srfit) call: survreg(formula = surv(time) ~ f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10, data = train, dist = dist_pred[i_dist]) value std. error z p (intercept) 1.59e+03 632.0632 2.5092 1.21e-02 f1 -2.07e+00 1.2283 -1.6881 9.14e-02 f2 1.03e+00 1.8070 0.5677 5.70e-01 f3 -7.61e-02 1.3764 -0.0553 9.56e-01 f4 -3.24e+00 1.4836 -2.1843 2.89e-02 f5 4.37e-01 0.0961 4.5474 5.43e-06 f6 -1.36e+00 0.7555 -1.8011 7.17e-02 f7 -6.26e-03 0.0081 -0.7719 4.40e-01 f8 3.92e-03 0

android - How to deal with a force close -

i developing game application android. problem crashes , displays "unfortunately...has stopped" dialog. running application again not force close app when getting same point, appear every often. what potential reasons might happen? i've done research couldn't find anything you should review logcat possible exceptions. if have no exceptions causing app crash -meaning code aparently "ok"- there's chance application consuming lots of memory. if application making garbage collector overwork, android may shut down application. you must take care not overcreating objects, or leaving load behind cleaned garbage collector. means, if can reuse objects, that's idea. there's <application> element in android manifest. can set there attribute named android:largeheap="true" . in way android assign more memory application. do last resort. try first improve object management in app. ain't easy task, luck.

javascript - dynamic amount of divs = dynamic color change steps? -

i want have dynamic amount of divs (sometimes 3, 10 etc), should colored based on color gradient (say green red). so, when there 2 divs, make first 1 #0f0 , second 1 #f00 . when there 10 divs, make first , last same, between change gradually green red. is there way pure css? if not, how javascript? i'm thinking doing javascript right now, it's gonna reaaally complicated way think it. advice? thanks here fiddle want ;) https://jsfiddle.net/tkzr99vx/ it create div amount pass in createdivs method. use rgb values did simpler code. still can use hex values have convert rgb.

r - Print or write RData file to view file contents -

i have .rdata file has multiple objects of varying type , size. can't view printing, because can see half objects (even when increase max.print maximum). don't think can write .txt file or .csv file because of multiple objects , error message: error in data.frame(description = "global model", dataname = "scm.rdata", : arguments imply differing number of rows: 1, 10, 11, 20 i've tried view, , indexing .rdata file view components separately no success. there way view contents of .rdata file?

Generic way to translate $ngBootbox messages with $translate service -

i'm using $ngbootbox module display alerts , confirm dialogs. also, i'm using angular-translate module translate string resources. i wanted generic way implement these translations shown in dialogs avoid repetitive , dirty code follows: $scope.displaymsg = function(){ $translate('message').then(function(translated_msg){ $ngbootbox.alert(translated_msg); }); } i wanted share solution using $provide.decorator app.config(function($provide){ $provide.decorator('$ngbootbox', function($delegate, $translate, $q){ return angular.extend($delegate, { alert: custommessagehandler($delegate.alert), confirm: custommessagehandler($delegate.confirm), prompt: custommessagehandler($delegate.prompt) }); //receives delegated method $ngbootbox function custommessagehandler(method){ return function(message){ var deferred = $q.defer();

sql - Converting ROW_NUMBER column affects performance -

i need know reason behind why there big performance difference when converting column generated row_number window function data type. example : with mycte ( select row_number() on (order id asc) rownumber, * ( select distinct * ( select j.*, -- other columns here table j -- join other tables here ) -- filter records select * mycte convert(int, rownumber) between convert(int, 40000) , convert(int, 40010) if convert rownumber column first int execute 3 secs ideal. where convert(int, rownumber) between convert(int, 40000) , convert(int, 40010)` but if not convert it, took 1 minute execute query. where rownumber between convert(int, 40000) , convert(int, 40010) can me concept behind this? row_number() function returns value of bigint datatype , constant 40000 returns int . because of difference in datatypes (yes, int , bigint ) sql-server can't estimate

c++ - How to define the constructor of an inner template class of another template class? -

i have inner template class of template class: // hpp file template< class t1 > class c1 { // ... public: // ... c1(); template< class t2 > c2 { // ... c2(); }; }; when declare inner class constructor errors: //cpp file template<> c1< mytype >::c1() { // ... } template<> template< class t2 > c1< mytype >::c2::c2() // error: invalid use of template-name ‘class c1<mytype>::c2’ without argument list { // ... } i have tried : template<> template< class t2 > c1< mytype >::c2<t2>::c2() // error: invalid use of incomplete type ‘class c1<mytype>::c2<t2>’ { // ... } incomplete type, constructor has no type... i little stuck here. how declare it? perform following: template<typename t1> template<typename t2> c1<t1>::c2<t2>::c2() { }

android - jTDS / JDBC call Store Procedure, error… getMoreResults() -

here code of ms sql server stored procedure have 1 input , 1 output parameter : alter procedure [dbo].[additem] @numer nvarchar(50) , @ff int output begin select category = @ff [awe_database].[dbo].[items] catalog_number=@numer end and try run on phone ( using android studio). connect database use jtds-1.3.1 library. try { callablestatement cs ; cs = this.connect.preparecall("{call additem(?,?)}"); cs.setstring(1, c); cs.registeroutparameter(2, java.sql.types.integer); int s = cs.getint(2); cat = getstring(s); toast.maketext(getapplicationcontext(), cat, toast.length_short).show(); } catch (sqlexception e) {e.printstacktrace(); } i such error: java.sql.sqlexception: output parameters have not yet been processed. call getmoreresults(). i searched forum find sollution , tryed many examples no 1 works. how shoudl use getmoreresults() ? or other wrong ? a

javascript - Customize the amCharts Stock Chart legend -

i use amcharts' stock chart comparison function. use stocklegend object legend , want customize valuetextcomparing parameter. actually, have : var stocklegend = new amcharts.stocklegend(); stocklegend.markertype = 'bubble'; stocklegend.markersize = 8; stocklegend.horizontalgap = 1; stocklegend.spacing = 100; stocklegend.periodvaluetext = '[[value.close]]'; stocklegend.valuetextcomparing = '[[value]] | [[percents.value]]%'; what want have 2 different colors [[percents.value]] switch value positive or negative (and add bold effect on valuetextcomparing ). i see in documentation valuefunction parameter, not equivalent comparing. can me? ok find way want. it's bit cheating it's work. first, use specific character separate value , percent (here "|") : stocklegend.periodvaluetext = '[[value.close]]|[[percents.value.close]]%'; stocklegend.valuetextcomparing = '[[value]]|[[percents.value]]%'; after that,

wordpress - How to prevent htaccess from rewriting urls on the redirected page which are the same as the url of the original page? -

Image
*** note **** please skip "update 9" highlighted below real question; below troubleshooting original issue find going on. *** (previous title of question: "after rewriting image url htaccess, new page shows fine image redirect not display unless reload page?") a strange thing occurring, maybe problem htaccess code. here code: rewritecond %{request_filename} .*jpg$|.*gif$|.*png$ [nc] rewritecond %{http_referer} !mysitee\.com [nc] rewriterule ([^/]*)\.(jpg|gif|png)$ http://mysitee.com/?attachment=$1 what change: http://mysitee.com/wp-content/uploads/2015/10/myimage.jpg to this: http://mysitee.com/?attachment=myimage the code works well, strange thing happens need fixed. using wordpress way. the problem on new page, image on attachment page rewrite url go to, not display unless manually reload page. perhaps has htaccess redirecting before http request display image happen? here's happens on redirect: but when manually pr

Query the map size in MongoDB -

suppose have map of variable size in mongodb. how can documents have map size, example >2? {map:{k1:v1, k2:v2, k3,v3}} {map:{k1:v1, k2:v2}} you'd need pre-calculate such map size if want queries on them later consider creating new field "keycount" holds number of keys map subdocument. consider following demonstration: populate test collection db.test.insert([ { "_id" : 1, "map" : { "k1" : "v1", "k2" : "v2", "k3" : "v3" } }, { "_id" : 2, "map" : { "k1" : "v1", "k2" : "v2" } } ]); as current design, need mechanism count of keys inside map document. possible through map-reduce . following mapreduce operation populate separate collection new field "keycount" adde

tortoisesvn - How can undo commit on SVN with revision number? -

this question has answer here: undoing commit in tortoisesvn 3 answers i have committed code want undo commit, have revision , branch number well, unable undo. my clientis tortoise svn, committed intellij idea. please help. please check link. describes rollback process. http://tortoisesvn.net/docs/nightly/tortoisesvn_en/tsvn-howto-rollback.html

c# - Changing property of a value in a list without changing the value itself -

i have list values in (these types class class1). every single value has date property in it. i'm trying when 1 element gets added list: var entry = list.first(); list.add(entry); list.first().dateval = new datetime(list.first().dateval.value.year,1,1); so i'm copying element , changing property dateval 01.01.xxxx. happens changes whole value 01.01.xxxx. happens both values. example: value: 05.10. property: 05.10.2015 after get: value: 01.01. property: 01.01.2015 value: 01.01. property: 01.01.2015 what want is: value: 05.10. property: 01.01.2015 value: 05.10. property: 05.10.2015 how change property? i'm wondering why code above not work. does work updating new objects property? var original = list.first(); var newobject = new class1(){ dateval = original.dateval, //set other properties }; newobject.dateval = new datetime(newobject.dateval.value.year, 1, 1); list.add(newobject); the reaso

python - Grammar rule extraction from parsed result -

i following result when execute stanford parser nltk. (s (vp (vb get) (np (prp me)) (advp (rb now)))) but need in form s -> vp vp -> vb np advp vb -> prp -> me rb -> how can result, perhaps using recursive function. there in-built function already? first navigate tree, see how iterate through nodes of tree? , how navigate nltk.tree.tree? : >>> nltk.tree import tree >>> bracket_parse = "(s (vp (vb get) (np (prp me)) (advp (rb now))))" >>> ptree = tree.fromstring(bracket_parse) >>> ptree tree('s', [tree('vp', [tree('vb', ['get']), tree('np', [tree('prp', ['me'])]), tree('advp', [tree('rb', ['now'])])])]) >>> subtree in ptree.subtrees(): ... print subtree ... (s (vp (vb get) (np (prp me)) (advp (rb now)))) (vp (vb get) (np (prp me)) (advp (rb now))) (vb get) (np (prp me)) (prp me) (advp (rb now)) (rb now) and

disable dropdown options based on the previously selected dropdown values using jquery or javascript? -

i have 3 dropdowns same options. want is, when selecte option dropdown, same option other 2 dropdowns disabled, except first 1 (the option 'select one'). for using following logic, here when 1 dropdown selected 1 value instead of disabling selected value remaining 2 dropdowns, disabling of these 3 dropdowns don't want. disabling of value should happen remaining ones not current dropdown. how can this? <select class="form-control positiontypes"> <option value="">select one</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> </select> <select class="form-control positiontype

qt - How to handle QComboBox signals in inner classes -

i using qt5 , have created class "outer" "inner" class. "inner" class has 2 qcombobox "cb1" , "cb2" objects private variables. in principle, displayed text of second qcombobox, "cb2", depends of current text of first qcombobox "cb1". in fact, easy implement connection between these two, using signals , slots writing appropriate slot. the problem qt not support writing slots inside inner class. makes me confused. how can handle connection between these 2 qcomboboxes in "inner" class? for code, class outer : public qdialog { q_object // private variables; class inner : public qwidget { qcombobox *cb1, *cb2; // other variables; public: // public methods public slots: void setindex(int i); }; // other things; }; inner implementation outer::inner::inner() { // useless things; connect(cb1, signal(currentindexchanged(int)), this, slot(setindex(int))); } o

c# - Error when running JSON.NET -

i have added using statement class running: using newtonsoft.json.linq; and referencing newtonsoft.json.dll in same project. i no compile-time errors. run-time one. cant simple code (the hello doesn't show before crashing): public void main() { messagebox.show("hello"); jobject j = new jobject(); dts.taskresult = (int)scriptresults.success; } i following error: dts script task has encountered exception in user code: exception has been thrown target of invocation with following stacktrace: at system.runtimemethodhandle.invokemethod(object target, object[] arguments, signature sig, boolean constructor) @ system.reflection.runtimemethodinfo.unsafeinvokeinternal(object obj, object[] parameters, object[] arguments) @ system.reflection.runtimemethodinfo.invoke(object obj, bindingflags invokeattr, binder binder, object[] parameters, cultureinfo culture) @ system.runtimetype.invo

html - Images are not showing up on mobile devices -

Image
i've got weird issue, apparently happens on mobile devices (or devices less width/height normal desktop, tested on chrome viewport rendering). images on bottom of page not displaying, but.. they appear in specific moments: when refresh page when images in viewport, appear correctly, when resize screen, images appear, when change css properties (doesn't matter one, can change existing property, add one, or disable one) in chrome inspector appear preview picture: sure not connected grayscale filter, becauase removing property , problem still occurs. i've tried remove transitions, overflow , still no help. here css class .partners--partner .partners--partner { border: 5px solid #f4f4f4; font-size: 0; height: 144px; line-height: 134px; overflow: hidden; position: relative; text-align: center; transition: 0.3s ease; vertical-align: middle; } more information structure , code: http://jsfiddle.net/8kuuyulp/2/

excel - Autofilling table rows from one data -

Image
i have table data (all unique) like: id name surname age 1 jack gong 21 2 danny manny 24 if insert 1 more row , write surname gong cell, there excel function fills "age", "name" , "id" automatically 21 , jack , 1 ? there no automatic way (outside of vba procedure, perhaps) this, can set through formulas: using below picture, place formula shown in formula bar cell a4, copy cell b4 , d4. then insert new row, copy row , paste in next row , input new surname in column c. id, name , age columns if value has been entered above , fill results if so. if value not listed, id, name , age columns return blanks, @ point can enter them manually. each time insert new row, ensure have row full of formulas id, name , age. (alternatively, can copy these down above rows individually - notice appropriate cell locking ensure captures entire range).

tkinter - Module Object has no Attribute Listbox - Python 3 -

i trying create scrollbar on buttonclick. below code: username = stringvar() self.uentry1=ttk.entry(self.frame1,textvariable=username) self.uentry1.pack() self.ubutton=ttk.button(self.frame1,text="name!",command=self.get_user_info) self.ubutton.pack() def get_user_info(self): self.uscrollbar = ttk.scrollbar(self.frame1) self.uscrollbar.pack(fill='both',expand=1) self.ulist = ttk.listbox(self.page5,yscrollcommand=self.uscrollbar.set) self.ulist.pack(side=left,fill='both') self.uscrollbar.config(command=ulist.yview) self.ubutton1 = ttk.button(self.frame1,text = "pid's",width = 10) self.ubutton1.grid() this throws error module object has no attribute listbox . please point out going wrong.(the above code incomplete need clear go further) just error telling you, ttk module has no att

backbone.js - Finding where id or class was used in a Marionette application - reversed reverse engineering -

i'm debugging huge application. how figure out display or render id or class used? it's other way around rather right-clicking on element doing inspect element. problem i've been opening many modals , inspecting dom manually , hoping see id or class. i'll find crazy! i'm not doing right.

javascript - How to resize chart in Plottable.js -

i using plottable.js draw chart on page. resize chart when window being resized. i've tried set size via css (as svg width , height attribute) no success. here attempt set via svg attribute: $('#svgsample').attr('width', w); $('#svgsample').attr('height', h); here attempt set via css: $('#svgsample').css({ 'width': w + 'px', 'height': h + 'px' }); any idea? thanks i believe need call plot.redraw() after setting svg attributes here's example: window.onload = function() { var data = [ { x: 1, y: 1 }, { x: 2, y: 1 }, { x: 3, y: 2 }, { x: 4, y: 3 }, { x: 5, y: 5 }, { x: 6, y: 8 } ]; var xscale = new plottable.scales.linear(); var yscale = new plottable.scales.linear(); var plot = new plottable.plots.scatter() .adddataset(new plottable.dataset(data)) .x(function(d) { retu

How to get current Location(latitude , longitude) while gps is off using FusedLocationApi in android -

i have used latest api. have implement fusedlocationapi , getting current location if gps on. have connected google play services still not getting current location. i use code: import android.app.alertdialog; import android.content.context; import android.content.dialoginterface; import android.content.intent; import android.location.location; import android.os.bundle; import android.provider.settings; import com.google.android.gms.common.connectionresult; import com.google.android.gms.common.api.googleapiclient; import com.google.android.gms.common.api.googleapiclient.connectioncallbacks; import com.google.android.gms.common.api.googleapiclient.onconnectionfailedlistener; import com.google.android.gms.location.locationrequest; import com.google.android.gms.location.locationservices; public class gpstracker implements connectioncallbacks, onconnectionfailedlistener, com.google.android.gms.location.locationlistener { private onlocationchangedlistener mlocationcha

c++ - Are EHOSTDOWN and EHOSTUNREACH fatal in connect()? -

how respond these errors when happen in connect() (non-blocking)? want know whether should kill socket , create new one, or can wait time , try again existing socket , work (if remote host became online)? you can try connecting again in these cases, since creating , binding socket again unnecessary work.

Combinations for every x and y items in Spinners Android -

i have 2 spinners items dynamic i.e, there can 'n' number of items in both spinners. want possible combinations of every items both spinners. suppose there a1,a2 items in spinner1 , b1,b2,b3 items in spinner2 want combination of item a1 , a2 spinner1 items of spinner2 i.e, a1b1, a1b2, a1b3 , a2b1,a2b2,a2b3. how can achieve that? suppose first spinner1 data in list1. list<string> spinner1 = new arraylist<string>(); spinner1.add(a1); spinner1.add(a2); and spinner2 data in list2. list<string> spinner2 = new arraylist<string>(); spinner2.add(b1); spinner2.add(b2); spinner2.add(b3); list<string> finaldata = new arraylist<string>(); now final spinner data, for(string s1 : spinner1){ for(string s2 : spinner2){ string str = s1.concat(s2); finaldata.add(str); } }

excel - Just want to show a Popup Or Status bar during running of VBA code -

i have long code & taking approx. 1 min 30 sec execute , want show status bar showing "please wait...running" or popup same message or else on easy. consist many while, & if conditions.. don't want use long code or heavy method show message, please suggest small way this. here short procedure demonstrate adjusting application.statusbar property text in loop. sub sb_text() dim w long, s long, d double s = 2 '<~~ seconds between actions application.statusbar = "preparing ..." d = + timeserial(0, 0, s): while < d: doevents: loop w = 1 5 application.statusbar = "working: " & w d = + timeserial(0, 0, s): while < d: doevents: loop next w application.statusbar = "finished" d = + timeserial(0, 0, s): while < d: doevents: loop application.statusbar = vbnullstring end sub i've set 2 second pause can observe changes status bar text. in actual proce

pointers - Passing address of a char* C++ -

void display(char* word) { static char* pointertoword = word; cout << pointertoword; } void initialise(char* word) { display(word); } void main() { char* word[3]; char* currentword; word[0] = "hello"; word[1] = "world"; word[2] = "hahahaha"; currentword = word[0]; initialise(currentword); currentword = word[1]; //displays word[0] display(0); currentword = word[2]; //still displays word[0] display(0); } char* bit of pain in neck. can me syntax right? all want is initialise() display() 's pointer current word use display() display wherever pointer pointing to in reality i've got few classes involved, example pretty illustrates problem. have no intention of modifying string, strings constant. change code follows: first put pointertoword @ global scope: static char* pointertoword = ""; overload display function: void display() { cout << pointertoword; } void

r - How can I get mean of every n rows and keep the date index? -

i have dataframe year index , val index. i create mean of every n rows of val , keep corresponding year index. basically, output (for n=2) year val 1990 mean(row1,row2) 1992 mean(row3,row4) 1994 mean(row5,row6) 1996 mean(row7,row8) how can this? structure(list(year = c(1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013), val = c(84l, 67l, 72l, 138l, 111l, 100l, 221l, 108l, 204l, 125l, 82l, 157l, 175l, 252l, 261l, 185l, 146l, 183l, 245l, 172l, 98l, 216l, 89l, 144l)), .names = c("year", "val"), row.names = 13:36, class = "data.frame") a short one-liner solution data.table : library(data.table) setdt(df)[,.(val=mean(val)), year-0:1] # year val # 1: 1990 75.5 # 2: 1992 105.0 # 3: 1994 105.5 # 4: 1996 164.5 # 5: 1998 164.5 # 6: 2000 119.5 # 7: 2002 213.5 # 8: 2004 223.0 # 9: 2006 164.5 #10: 2008 208.5 #11: 2010 157.0 #12: 2012 116.5

Need Help in Case Output (BASH) -

i have simple case says like case "$1" in -b*) myfunction exit 0;; -b*) echo "invalid!" >&2 exit 1;; esac what want when user input argument using " b ", stuff myfunction. else, if user input using " b ", print error , exit program. however, happens when user input " b ", prints invalid! exit 1 instead of invalid! also, gives exit value of " 0 " instead of " 1 ". know part did wrong? replace in script echo "invalid!" >&2 exit 1 by echo "invalid!" >&2; exit 1

Android TTS speaks 0 as "oh" -

when using android texttospeech speak messages have digits, android speaking 0 (zero) "oh" rather "zero". other digits spoken expected. i've tried couple different ways speak, of them result in issue. first, tried in normal way: mtts = new texttospeech(mcontext, this); string text= "this test"; string digits= "0 0 0 1"; string finalstring= text+digits; // speak using google tts bundle lparams = new bundle(); lparams.putint(texttospeech.engine.key_param_stream, constants.tts_audio_stream); mtts.speak(finalstring, texttospeech.queue_flush, lparams, ""); i tried digits "0001" (no spaces). both ended spoken "this test oh oh oh one". next, tried using ttsspans: mtts = new texttospeech(mcontext, this); string text= "this test"; string digits= "0 0 0 1"; string finalstring= text+digits; spannable lspannedmsg = new spannablestring(

Seleniume Webdriver using Proxy IP -

i using selenium webdriver scrap data website.due heavy traffic ip, not able access website(may ip blocked website). is there way setup proxy ip , treated new ip every-time run webdriver..? you can set proxy ip selenium webdriver per following way : firefoxprofile profile = new firefoxprofile(); profile.addadditionalpreference("network.proxy.http", "localhost"); profile.addadditionalpreference("network.proxy.http_port", "8080"); webdriver driver = new firefoxdriver(profile); you should change desired ip address , port in above code. for more detail , please have @ : selenium webdriver proxy

.net - Skip rule is not working -

i've edited csproj file according post , files in app_data deleted anyway. on other hand, when modify msdeploy command shown in post, skip applied. i'm using web deploy v3. , command msdeploy.exe" -verb:sync -source:package=c:\builds\app.zip -dest:auto -setparam:"iis web application name"="default web site/app" is there anyway debug can causing behavior ? <propertygroup> <onbeforepackageusingmanifest>addcustomskiprules</onbeforepackageusingmanifest> </propertygroup> <target name="addcustomskiprules"> <itemgroup> <msdeployskiprules include="skipdeleteappdata"> <skipaction>delete</skipaction> <objectname>filepath</objectname> <absolutepath>$(_escaped_packagetempdir)\\app_data\\.*</absolutepath> <xpath> </xpath> </msdeployskiprules> <msdeployskiprules includ

c# - Can I find total time of 1st time and 2nd time in DATETIME? -

i find total time of 2 datetime. have 2 datetimes: logindt , logoutdt. logindt database , logoutdt now. code below datetime logindt = (datetime)readers["login_date_time"]; datetime logoutdt = datetime.now; datetime total = ?????????????? how should do? all time intervals in c# measured timespan structure. can substracting 2 datetime variables: datetime logindt = (datetime)readers["login_date_time"]; datetime logoutdt = datetime.now; timespan total = logoutdt - logindt;

javascript - Why can we modify an object with a function argument, but we cannot redefine an object the same way? -

this question has answer here: is javascript pass-by-reference or pass-by-value language? 28 answers example code: var person = { name: 'sam', age: 45 }; // function able modify name property function namechanger (obj, name) { obj.name = name; } namechanger(person, 'joe'); // modifies original object but trying redefine objection in similar function doesn't work @ all: var person2 = { name: 'ashley', age: 26 }; function personredefiner (obj, name, age) { obj = { name: name, age: age }; } personredefiner (person2, 'joe', 21); // original object not changed this second example not modify original object. have change function return object, set person2 = personredefiner(person2, 'joe', 21); why first example work second example not? in second example, you're initializing new o

java - Why is my component an instance of JRootPane if I never assigned it to one? -

let me explain code does: have created own class extends jdialog. class, lets call class a, contains a: jmenubar, jmenu, jmenuitem, jbutton, jdialog, jpanel , mouseadapter. project similar freecell game, in trying move multiple images, in own jpanels. right now, issue this: when user clicks on on screen, point coordinated of clicked , set component component component = getcomponentat(point); i check see if instance of jpanel, ie card if (component instanceof jpanel) so can move card around. problem arrises. when print out components class is, states jrootpane, have never used or seen object in entire life, until looked now. know why component object of jrootpane when never used use it. no matter click on screen, keeps stating component jrootpane... it because jrootpane contains jdialog? https://docs.oracle.com/javase/7/docs/api/javax/swing/jrootpane.html it because jrootpane contains jdialog? no jrootpane doesn't contain jdialog. jdialog contains jro

jsp - how to insert values in mysql database -

enter image description here please 1 help... using jsp mysql database,its isa relation type,i have created table named product has "product_id" primary key, , have created 2 other tables named "spare_parts" , "accessories" doesn't has primary key have foreign key of product table. depending on form submission want insert data in either of tables. please help as per tutorial: http://www.java2s.com/tutorial/java/0360__jsp/insertdatatoatable.htm use query as: insert product(id, name, brand, quantity) values (....) insert spareparts(productid, weight) values (...) insert accessories(productid, color) values (....) you should merge spareparts , accessories table if no other fields needed.

oauth 2.0 - OAuth2 user token best practice -

i'm using "code grant flow" in order obtain token server-side passing secret. need send token server client, able make ajax request bearer token in header. safe way this? any method long return on secure https channel. application specific call, running between frontend , backend of single application, based on session cookie maintains state between 2 of them.

objective c - How to Convert an array values into booleans values -

i have array this myarray=[0,0,1]; i want convert array values boolean values below myarray=[false,false,true]; i assign array values strings mystring=[myarray objectatindex:0]; if possible here can convert 0, 1s boolean values. you can keep way store value. whatever number store bigger one, considered yes when retrieve bool type. however, give actual number if retrieve nsinteger or int . so, use booleanvalue method retrieve so: nsnumber *value1 = myarray[0]; bool boolvalue1 = [value1 booleanvalue];

datetime Attribute error in python -

i'm trying run following 3 lines of python code on command line using python 3.5.0. gives me error- attribute error: module 'datetime' has no attribute 'date'. want print current date. please help. import datetime current = datetime.date.today() print(current) there nothing wrong code. reduced bit though: import datetime datetime.date which should cause error. if causes error, installation messed or, unlikely, there's bug in python. please make sure don't have datetime.py in working directory. further, check output of dir(datetime) after importing , different version of python.

python - how to get total number of pages in PdfQuery -

i'm trying how many pages pdf has. attempt this: pages = pdf.doc.catalog['pages'] print pages but prints <pdfobjref:2> . got finaly pdf.doc.catalog['pages'].resolve()['count'] it respond number of pdf pages

command line - Using ZSH for storing environment variable -

it suggested me utilize zsh storing environment variables project i'm working on. when set them export var_name='secret_key' on command line works, not persist beyond shell session. reading around sounds should adding them in .zshenv file. file not appear exist me. not sure how create file in $path. contrary approach told use .zshrc file. though when add env vars in there export var_name='secret_key' not picked application when ran syntax command line. i'm kinda lost in best approach this, , how done. couple resources i've been reading though: http://zsh.sourceforge.net/guide/zshguide02.html where place $path variable assertions in zsh? closed down , walked away day. came morning , worked. c'est la vie. not sure killed server few times trying figure out, working now. still not sure if saving env vars in .zshrc file best practice. or if location more ideal.

apache - Public Key Pinning not working -

hello trying implement public-key-pinning on apache server running proxy web-app, won't work (if enter wrong hash page still displayed instead of error, should shown in firefox or chrome). sure header correct – hash correct, have tested chrome. my configdata is <virtualhost *:443> servername subdomain.*******.***:443 sslcertificatefile /etc/apache2/ssl/___.crt sslcertificatekeyfile /etc/apache2/ssl/___.key sslcertificatechainfile /etc/apache2/ssl/___.ca header set public-key-pins "pin-sha256=\"****\"; pin-sha256=\"****\"; max-age=120; includesubdomains" <proxy *> order deny,allow allow </proxy> proxypass / ****:****/ proxypassreverse / ****:****/ <location /> order allow,deny allow </location> </virtualhost> at first had 1 hash added second 1 in case required. doing wrong? note: of course have mod_header enabled , loaded. two hashes required