Posts

Showing posts from March, 2014

c# - Cannot cast IStorageItem to StorageFile -

the following code not compile because isoftype not accepted method on item. documentation states: when method completes successfully, returns istorageitem represents specified file or folder. if specified file or folder not found, method returns null instead of raising exception. to work returned item, call isoftype method of istorageitem interface determine whether item file or folder. cast item storagefolder or storagefile. can me please? private async void restoredata(string filename) { storagefolder folder = applicationdata.current.localfolder; var item = folder.trygetitemasync(filename); if (item == null) { existingdata = false; } if (item.isoftype(storageitemtypes.file)) { await readdataasync(item storagefile); existingdata = true; } existingdata = false; } thanks... robert you missing await keyword await result of async me

javascript - Would this conditional statement work in an HTML page? -

i want load html5shiv.js file if web browser less ie 9. the code have is <doctype html> <html> <head> <!--[if lt ie 9] <script type="text/javascript" src="html5shiv.js"></script> --> </head> <!-- ... --> </html> when test see if works or not (i changing browser mode option version lower ie 9 in developer tools - i'm not clear whether works or not. does work - or code atleast right ? you may missing chevron @ end of first line , closing tag: <!--[if lt ie 9]> <script type="text/javascript" src="html5shiv.js"></script> <![endif]-->

double assign in python results in identical lists even when different operation is done. Why? -

this question has answer here: how clone or copy list? 16 answers i'm facing situation can't crack logic behind. i have piece of code user_id = user_email = [] id, email in users: # users tuple of tuples looks ((a,b),(c,d)...) user_id.append(id) user_email.append(email) when check result, found user_id == user_email when assign them separately, can correctly id's , email's, instead of 2 identical lists contain both id's , email's i'm wondering what's logic behind double assign , causes phenomenon happen. when set user_id = user_email = [] you link user_id , user_email 1 list. when list changes both variables change. set these variables separately. user_id = [] user_email = [] this can confusing if coming language c. think of variable in python name not variable. this incredibly helpful

MySQL ORDER by two columns, limit on a single one -

is there way order results in mysql based on column , b , limit results x per values of a, in order a, (b limit x) ? assume have table_a in following format: +------+--------+------+ | col1 | col2 | col3 | +------+--------+------+ | | 100 | abc | | | 200 | acd | | | 300 | atd | | | 400 | aem | | | 500 | ieb | | b | 150 | aio | | b | 250 | loe | | b | 350 | wmd | | b | 450 | zir | | b | 550 | oui | +------+--------+------+ i obtain x highest values of column 2 associated each value of column 1. here example of result if wanted have top 3 each col1 result: +------+--------+------+ | col1 | col2 | col3 | +------+--------+------+ | | 500 | ieb | | | 400 | aem | | | 300 | atd | | b | 550 | oui | | b | 450 | zir | | b | 350 | wmd | +------+--------+------+ how achieve such behaviour without relying on 1 query per value of column 1? try this;) sql fiddle

java - Resizing an array: How much should it be done? -

i implementing stack using array. , needs grow @ point push items on stack. wondering how should resized? should resize constant number? please let me know. from 1 hand, don't want often, on big sets of data. other hand, don't want waste memory. strategy multiply size 2 (or 1.5, if more concerned memory on performance). doubling adapt possible growth, , predictable number of growth operations.

c# - How can I do async await in the repository pattern? -

i have code long running i/o bound perfect async/await . doing repository pattern , can not figure out how await in controller i'm getting object not contain awaiter method on code public class homecontroller : controller { private imainrepository _helper = null; public homecontroller() { this._helper = new mainrepository(); } public async task<string> aboutt() { // here error object main = await _helper.top_five() ?? null; if(main != null) { return main.tostring(); } else { return null; } } } the method implementing works fine can see below. data out of database , return in string format. find way make object main = await _helper.top_five() ?? null; await otherwise mixing async synchronous code. suggestions great ... public async task<string> top_five() { try { using (npgsqlconnection conn =

sum - Excel Sumproduct with Flexible Inequality -

Image
i'm trying write sumproduct references other cells inequality conditions. i'd able change direction of inequality (i.e. <, >, <=, >=) referencing cell text instead of hardcoding inequality in formula. possible? this code works, $b7 , $d7 cutoff conditions: sumproduct(--('data'!$a$2:$a$231>=$b7)*('data'!$a$2:$a$231>=$d7)) however, variations of code don't work, when use references inequalities: sumproduct(--('data'!$a$2:$a$231 & $b1 & $b7)*('data'!$a$2:$a$231 & $d1 & $d7)) in above case, $b1 , $d1 both >= is possible sumproducts? thanks! sumproduct() cannot integrate comparison operator cell, sumifs , countifs can. =sumifs(a2:a50,a2:a50,b1&b7,a2:a50,d1&d7) a2 a50 has ascending whole numbers. the condition not make sense, though, since both sumproduct , countifs use , combine conditions. in example both conditions use same operator, condition values greater d7

How can I define a variable in another namespace within a function/macro in Clojure? -

i'm experimenting ns in clojure , here's try: user=> (in-ns 'some-ns) #<namespace some-ns> some-ns=> (def aa 100) #'some-ns/aa some-ns=> (in-ns 'user) #<namespace user> user=> (= some-ns/aa 100) true user=> (= user/aa 100) compilerexception java.lang.runtimeexception: no such var: user/aa, compiling:(no_source_path:5:1) ;this works expected user=> (defn function [] (in-ns 'some-other-ns) (def cc 100) (in-ns 'user)) #'user/function user=> (function) #<namespace user> user=> (= some-other-ns/cc 100) compilerexception java.lang.runtimeexception: no such var: some-other-ns/cc, compiling:(no_source_path:8:1) user=> (= user/cc 100) true i'm confused, why doesn't work in function? also, tried following: user=> (binding [*ns* (create-ns 'some-a-ns)] (def dd 100)) #'user/dd user=> (= some-a-ns/dd 100) compilerexception java.lang.runtimeexception: no such var: some-a-ns/dd, compiling:(no

string - Concatenating remaining arguments beyond the first N in bash -

i did not have write bash script before. here need do. my script run set of string arguments. number of stings more 8. have concatenate strings 9 , onward , make single string those. this... myscript s1 s2 s3 s4 s5 s6 s7 s8 s9 s10....(total unknown) in script, need this... new string = s9 + s10 + ... i trying this...(from web search). array="${@}" tlen=${#array[@]} # use loop read string beyond 9 (( i=8; i<${tlen}; i++ )); echo ${array[$i]} --> show string beyond 9 done not working. prints out if i=0. here input. ./tastest 1 2 3 4 5 6 7 8 b c i expecting b c printed. have make abc. can help? it should lot simpler looping in question: shift 8 echo "$*" lose arguments 1-8; print other arguments single string single space separating arguments (and spaces within arguments preserved). or, if need in variable, then: nine_onwards="$*" or if can't throw away first 8 arguments in main shell process:

reference - Dereferencing Conditionally in Perl -

i have scalar may or may not reference array. if reference array, dereference , iterate on it. if not, treat one-element array , iterate on that. my $result = my_complicated_expression; $value (ref($result) eq 'array' ? @$result : ($result)) { # work $value } currently, have above code, works fine feels clunky , not perlish. there more concise way express idea of dereferencing value fallback behavior if value not expect? being perl, there's going several answers 'right' 1 being matter of taste - imho, acceptable shortening involves relying on fact the ref function returns empty string if expression given scalar. means don't need eq 'array' if know there 2 possibilities (ie, scalar value , array ref). secondly, can iterate on single scalar value (producing 1 iteration, obviously), don't have put $result in parentheses in "scalar" case. putting these 2 small simplifications togeather gives; use v5.12; $result1

php - how can i insert only one part of a page with an iframe? -

i trying part of page, example http:/example.com/home.html , home has div id="content" , id set iframe , display "content" ... have tried load (with jquery) post says http://stackoverflow.com/questions/4249809/reload-an-iframe-with-jquery but no results yet, idea how it? in jquery or direct php. thanks in advance. perhaps don't need use iframe - used embedding website, not quite need. instead, make ajax request url need, , use jquery parse response , fetch div need load. example: $.ajax({ type: "get", url: "http://stackoverflow.com/questions/4249809/reload-an-iframe-with-jquery", success: function(r) { var content = $(r).find("#content"); //now have content div stored in variable } });

sql server - SQL Performance with stacking -

i trying understand there performance impact if stack table1 in table2 ? better performance? query #1: select * table1 id = 100 output: id col1 col2 ------------- 100 1 0 200 0 1 300 1 0 400 0 1 query #2: select * table2 id = 100 output: id col data ---------------- 100 col1 1 100 col2 0 200 col1 0 200 col2 1 300 col1 1 300 col2 0 400 col1 0 400 col2 1 also how sql server scan records? thanks table 1 normalized, while table 2 designed eav considered anti-pattern, , reasons. and while believe performance better table 1, there other factors considered here besides performance. imho, reason choose eav design when don't have other choice. (and that's case, since databases today can handle complicated data types such xml or json) in case, choice quite obvious - table 1 has better design, no question it.

python - "ImportError no module named gnuradio" when trying to execute ./uhd_fft -

i have followed instructions out lined here: http://forums.nuand.com/forums/viewtopic.php?f=9&t=2804 and installed gnu radio git repo (scroll down section says "building gnuradio git". used ./build-gnuradio.sh script , took while, appeared build successfully, per instructions. i running on ubuntu 12.04 lts. when attempt run "./uhd_fft" function following error message: traceback (most recent call last): file "./uhd_fft", line 23, in <module> gnuradio import gr, gru importerror: no module named gnuradio i have googled error message , of forums claim there problem pythonpath. when echo $pythonpath /usr/bin/python2.7 but when check python2.7 directory not see gnuradio. guess makes sense i'm getting import error when tries import gnuradio. bigger question why? i installed gnu radio (per instructions nuand forum) using ./build-gnuradio.sh script. should have installed. i appreciate if python / gnu radio expert

javascript - How can I start a delayed sound on a page I'm about to navigate to? -

my onclick function start delayed sound never getting called, or is, no sound happens. depends on navigate in conjunction onclick, , navigate. understand sounds killed when navigate away. below code. func, little_ding(), arranges do_bike_bell() called 1.5 sec later. there's 4 cases. cases a/b within home page, navigating same/different page. c/d similar, within non home page. case works fine. case b calls little_ding(), do_bike_bell() never called. cases c&d never call little_ding(). w/ chrome. case b sort of works in firefox: after return home page, do_bike_bell() called , hear it- not intention. // javascript function do_bike_bell() { //prompt("hello do_bike_bell()"); audio_ld.play(); settimeout(kill_bike_bell,4000);} // kill later sure function little_ding() { // prompt("hello little_ding()"); settimeout(do_bike_bell,1500); } // html. home_page.html calls same/level 2 page: <a href="#id_in_same_file" onclick=&

javascript - How to remove multiple divs from a webview by class and id? -

i trying remove multiple divs class , id webview. how can this? this have tried: webview.loadurl("javascript:(function() { " + "document.getelementsbyclassname('header-top')[0].style.display='none'; " + "document.getelementsbyclassname('inchoo-socialconnect-login')[0].style.display='none';" + "document.getelementbyid('before-footer')[0].style.display='none';" + "document.getelementbyid('footer')[0].style.display='none';" + "})()"); in code above remove first element found. method getelementsbytagname returns array, loop through elements rather [0] element things done. also recommend call javascript function in webpage rather printing entire function in webview.loadurl

python - Is it possible to trigger a mousePressEvent artificially on a QWebView? -

due astronomically atrocious bug on pyqt4 , need fire mousepressevent artificially on qwebview last breath of hope. obscure reason, qwebview's linkclicked , urlchanged signals not pass qurl when clicked link has javascript involved (it not work on youtube videos, example) and when link clicked left mouse button. qurl can accessed when link clicked middle , right buttons. class cqwebview(qtwebkit.qwebview): def mousepressevent(self, event): if type(event) == qtgui.qmouseevent: if event.button() == qtcore.qt.leftbutton: # fire qtcore.qt.middlebutton event here, # can bloody link afterwards. elif event.button() == qtcore.qt.middlebutton: self.emit(qtcore.signal("open_in_new_tab")) # example elif event.button() == qtcore.qt.rightbutton: self.emit(qtcore.signal("xxx")) # example so, literally want "click artificially", click without c

String Concatenation in bash with space and putting quote around -

i got response in last question . idea process n number of inputs command line, save first 9 variables , make string 10 onward. i found easiest solution. var1="$1" var2="$2" var3="$3" var4="public" var5="$5" var6="''" var7="$7" var8="$8" var9="$9" var10="$(shift 9; ifs=""; echo "$*")" echo snmptrap $var1 $var2 $var3 $var4 $var5 $var6 $var7 $var8 $var9 "$var10" snmptrap $var1 $var2 $var3 $var4 $var5 $var6 $var7 $var8 $var9 "$var10" the output looks this... ./snmptas -v 2c -c "" 9.48.85.57 "" 1.3.6.1.4.1.2.6.201.3 s s abc ddef efff snmptrap -v 2c -c public 9.48.85.57 '' 1.3.6.1.4.1.2.6.201.3 s s abcddefefff but wanted $var10 in form "abc ddef efff". this needs changed. it's taking spaces off. var10="$(shift 9; ifs=""; echo "$*")" how can make

c - How to cast a struct of 2 uint into a double -

i have struct below: struct pts_t { uint32_t lsb; uint32_t msb; }; i cast double. safe of directly write: pts_t t; double timestamp = t; and more complex, if struct type part of c dll api, without having "packing" attribute (for compiler) in case have copy pts_t* receive througth api pts_t instance create control struct packing ? void f(pts_t* t) { pts_t myt; myt.lsb = t->lsb; myt.msb = t->msb; double timestamp = *(double*)(&myt.lsb); } the initial thought write following: double timestamp = *( ( double * ) &( t.lsb ) ); to step through (assuming in 32-bit environment): you getting address of identifier t.lsb because need find memory address of first byte in structure. note, can alternatively &t . you casting memory address pointer double (8 bytes). you lastly dereferencing pointer , storing 8 bytes in 8 byte block of memory identifier timestamp uses. remark: you need consider little/big endianness

Unable to get values of unbound fields in gridview asp.net c# -

i trying values gridview. i use stored procedure set datasource it, let's gridview uses dynamic pivot colums can't create bound field them. here code trying textbox value , header value protected void dgvtask_selectedindexchanged(object sender, eventargs e) { var grid = (gridview)sender; gridviewrow selectedrow = grid.selectedrow; int rowindex = grid.selectedindex; int selectedcellindex = int.parse(this.selectedgridcellindex.value); textbox txtlogs = (textbox)selectedrow.cells[selectedcellindex].findcontrol("txtdata"); string cellvalue = txtlogs.text; string headervalue = grid.headerrow.cells[selectedcellindex].text; scriptmanager.registerclientscriptblock(this, this.gettype(), "alertmessage", "alert('" + selectedcellindex + "')", true); binddgvtask(); } i tried use string cellvalue = grid.selectedrow.cells[selectedcellindex].text; to cell value both of these returns these err

Difference between colors with a same rgb value in sRGB space and CIE RGB space -

could tell me why colors same rgb value (for example 127, 127, 127) same in image using srgb space , 1 using cie rgb space? since 1 non-linear (with gamma correction) , other 1 linear (without gamma correction), think should kinda different. image i've created looks same (i used photoshop create former , latter, tried photoshop, opengl , opencv). the difference coming when manipulating image or color (changing brightness or saturation of image). visible when lowering saturation of yellow. try in photoshop rgb , lab mode. not switch grayscale mode, because using luminance correction, saturation slider in adjustment>hue/saturation menu. you can see difference when playing color picker (just scroll down full-blown example), represents colors in cie lch space (it using cie lab in background).

cmd - Unexpected token Illegal in Node.js -

Image
trying command cd change directive c:\xampp\htdocs\project . facing issue node.js cmd. first exit node, (ctrl+c) cd directory. need npm init/install/update ever. never need node command unless obscure stuff :) good luck

spark streaming - each data in mongodb local.oplog.rs, is it a standard bsonobject structure -

i use spark mongo-connector sync data mongodb collection hdfs file, code works fine if collection read through mongos, when comes local.oplog.rs, replica collection read through mongod, gives me exception: caused by: com.mongodb.hadoop.splitter.splitfailedexception: unable calculate input splits: couldn't find index on splitting key { _id: 1 } i think data structure different between oplog.rs , normal collection, oplog.rs doesn't have "_id" property, newapihadooprdd can not work nomally, right? yes, document structure bit different in oplog.rs. find actual document in "o" field of oplog document. example oplog document: { "_id" : objectid("586e74b70dec07dc3e901d5f"), "ts" : timestamp(1459500301, 6436), "h" : numberlong("5511242317261841397"), "v" : 2, "op" : "i", "ns" : "urdb.urcollection", "o" : { "_id" : objectid(

c# - Pass Exception and Subclasses over NamedPipe -

i'm trying pass objects of type exception (or 1 of it's subclasses) on namedpipe. servicecontract: [servicecontract] public interface iwcfcallback { [operationcontract] void sendexception(exception e); } it works fine when use this: _pipeproxy.sendexception(new exception("bla bla 99")); but pass subclass: _pipeproxy.sendexception(new argumentexception("fridgemaster 3000")); i exception, saying deserialisation failed. i read knowntypes attribute, can't figure out how use classes not implemented myself. can give me hint here? one of "best practices" on wcf, not serialize exception. if servicehost throwing exception, suppose use faultexception. 1 of reason why exception not safe transfer, exception serializable, can derive it, , guarantee custom derived exception serialable. you pass data contract object exception stack string , type enum, work-around.

jquery - Display text based on info selected in two drop downs -

i need write quick bit of code allows users @ top of 1 of our article pages following: drop down 1: how old you? drop down 2: what's favourite fruit? based on inputs above, summary text instantly displays below after second selection made, based on both selections above e.g. for 18-24 year olds apples: apples build immune system @ age! for 50-60 year olds bananas: bananas vitamin c , bone density in later life. it depends on how data structured. assuming there going quite few ages , fruits, sort of data structure work: var text = [ { fruit: "bananas", ages: [ { range: "18-24", text:"bananas awesome"}, { range: "50-60", text:"bananas vitamin c , bone density in later life."} ] }, { fruit: "apples", ages: [ {range: "18-24", text:"apples build immune system @ age!"}, {range: "50-60", text:"apples cheap."} ]

java dom parser only gets the first entity -

this code returs 1 "question " tag's element have 9 question element inside xml file.what wrong thing in here?do need loop.because when checked loop, loops 1 time.what problem?i figure out. here xml: <results> <question> <eno>3</eno> <qno>1</qno> <qtext>the battle of gettysburg fought during war?</qtext> <correctanswer>c</correctanswer> </question> <question> <eno>3</eno> <qno>2</qno> <qtext>neil armstrong , buzz aldrin walked how many minutes on moon in 1696?</qtext> <correctanswer>b</correctanswer> </question> </results> my source code: nodelist listofquestions = doc.getelementsbytagname("question"); for(int s=0; s<listofquestions.getlength(); s++) { system.out.println(listofquestions.getlength()); node firstquestionnode = listofquestions.item

python - Forking a child in another thread: parent doesn't receive SIGCHLD on termination -

normally, when process fork child process, receive sigchld signal if child terminates. but, if fork happens in thread other main thread of application, parent won't receive anything. i test in python, on different gnu/linux machines. x86_64 . my question is: python behaviour, or defined behaviour of posix standard? , in both cases, why so? here sample code re-produce behaviour. import signal import multiprocessing import threading import time def signal_handler(*args): print "signal received" def child_process(): time.sleep(100000) def child_thread(): p = multiprocessing.process(target=child_process) p.start() time.sleep(100000) signal.signal(signal.sigchld, signal_handler) p = multiprocessing.process(target=child_process) p.start() t = threading.thread(target=child_thread) t.start() time.sleep(100000) print "waked" time.sleep(100000) then, send sigkill each child. when first child (the 1 forked in main thread)

best method Implements followers with meteor/mongodb -

i'm doing app users can follow topics. best schema implement mongodb , meteor? i thought 2 solutions: first 1 collection: schemas.follow = new simpleschema({ userid: { type: string } topicid: { type: string } } pro: no problems document 16mb limit cons: performances search slow (?) second use ids array in users , topics collection schemas.user = new simpleschema({ ... follows: { type: [string] } } schemas.topic = new simpleschema({ ... followedby: { type: [string] } } pro: better performance of search cons: problem of 16mb limit per document have better solution mongodb , meteor? thanks! a mongodb objectid 12 byte object repesented string of 24 characters. if assume large storage overhead (say, 100 bytes per id), 16 megabyte document can store on hundred thousand ids. assuming users humans, , follow topics manually, it's safe store topic ids in array.

javascript - Radio button value undefined -

i have following radio buttons, php code: <form class="small-box-footer" style="text-align:left;padding:10px;" method="post" name="namehere"> <?php $query = "select * subject"; $result = mysql_query($query); while ($row39 = mysql_fetch_array($result)) { $referrer_id = $row39['subject_id']; $referrer_name = $row39['subject_name']; ?> <input type="radio" class="subject-selected" name="subject" value="<?=$referrer_id?>"> <?=$referrer_name?><?=$referrer_id?><br /> <?php } ?> </form> html generated: <input type="radio" class="subject-selected" name="subject" value="2"> gcse maths2<br /> <input type="radio" class="subject-selected" name="subject" value="3"&g

angularjs - How to make this app multi-select? -

i want below angularjs code example here . "," should added after every color select. red,white,black <!doctype html> <html> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body> <div ng-app="myapp" ng-controller="myctrl"> <p>select car:</p> <select ng-model="selectedcar" ng-options="x.model x in cars"> </select> <h1>you selected: {{selectedcar.model}}</h1> <p>its color is: {{selectedcar.color}}</p> </div> <script> var app = angular.module('myapp', []); app.controller('myctrl', function($scope) { $scope.cars = [ {model : "ford mustang", color : "red"}, {model : "fiat 500", color : "white"}, {model : "volvo xc90", color : "black"} ]; }); &l

php - Store path to uploaded Image in database -

i'm trying add path of uploaded image database in order use display thumbnail post. found tutorial , used code upload image. gets else statement , exit("error while uploading image on server"); have form collect data: <form action='' method='post' enctype="multipart/form-data"> <p><label>title</label><br /> <input id="title-input" type='text' name='posttitle' value='<?php if(isset($error)){ echo $_post['posttitle'];}?>'></p> <p><label>description</label><br /> <textarea id="textarea" name='postdesc' cols='20' rows='5'><?php if(isset($error)){ echo $_post['postdesc'];}?></textarea></p> <p><label>content</label><br /> <textarea name='postcont' cols='20' rows='5'><?php if(isset($error)){ echo $_post['pos

validation - Validate LinkedIn Company is exists or not using LinkedIn API -

i want validate linkedin company exists or not using linkedin api. have used this link shows { "errorcode": 0, "message": "unknown authentication scheme", "requestid": "ju7wn815ma", "status": 401, "timestamp": 1464156122597 } note: have created app in this link got client id , client secret. followed this link too. how access token, secret key , all. you need follow steps outlined on linkedin developer website acquire oauth 2.0 access token let make api call. more details here: https://developer.linkedin.com/docs/oauth2

html - Dynamic redirect url for PayPal Buy Now button -

i have integrated paypal buy button on site follows: <form name="_xclick" action="https://www.paypal.com/uk/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="receiver@receiver.com"> <input type="hidden" name="currency_code" value="usd"> <input type="hidden" name="item_name" value="description here"> <input type="hidden" name="amount" value="100"> <input type="image" src="https://www.paypalobjects.com/en_us/nl/i/btn/btn_buynowcc_lg.gif" border="0" name="submit" alt="make payments paypal - it's fast, free , secure!"> </form> upon succesfull purchase, redirect user page (not known in advance - dynamic ). how can achieved?

php - Twitter app-only auth works on localhost, but not on server -

i'm using app-only auth twitter , trying search results. i'm using codeigniter part, code in question plain php. it happily returns search results when i'm running on localhost, running on server gives me following error: [code] => 99 [label] => authenticity_token_error [message] => unable verify credentials so it's failing @ first request bearer token. this seems bit screwy me , hard debug. i'm missing quite basic, gratefully accepted! below code: // consumer key , consumer secret config files $consumer = array( 'key' => $this->config->item($provider.'_key'), 'secret' => $this->config->item($provider.'_secret'), ); // encode format twitter expects $bearertokencred = base64_encode($consumer['key'].":".$consumer['secret']); // set request $opts = array('http' => array( 'method'

naming conventions - Why is Multimap not camel cased? -

this 1 annoys me (and colleague). it's not hashmap treemap org.apache.commons.collections.multimap etc. so why didn't notice naming convention flaw or there intention behind typo? the word " multimap " (one word, entirely lowercase) refers specific data structure. it's different "map", data structure. since they're different data structures, have different names. the map interface use in java chosen name associative array , known "map", "dictionary", "hash", etc. likewise, guava's multimap interface representation of multimap data structure.

python - Multiple columns extracted from one Pandas column -

i have (parsed) datetime column in pandas dataframe. need generate multiple columns based on 1 column, 1 year, 1 month, hour, day of week etcetera. i'm doing number of individual applies large dataset , i'm iterating on df multiple times. there better pattern accomplish this? can apply return dataframe paste behind it? if dtype datetime can use vectorised datetime accessor dt add columns: in [11]: df = pd.dataframe({'date':pd.date_range(dt.datetime(2016,1,1), end = dt.datetime(2016,1,10))}) df out[11]: date 0 2016-01-01 1 2016-01-02 2 2016-01-03 3 2016-01-04 4 2016-01-05 5 2016-01-06 6 2016-01-07 7 2016-01-08 8 2016-01-09 9 2016-01-10 in [13]: df['year'],df['month'],df['day'], df['day_of_week'] = df['date'].dt.year, df['date'].dt.month, df['date'].dt.day, df['date'].dt.dayofweek df out[13]: date year month day day_of_week 0 2016-01-01 2016 1 1

switch statement - Windows container -

i have created azure vm windows server 2016 tp5. on server able create images containers , docker engine installation. my issue follows first time working proper. shutdown vm through azure portal , next day started portal, not able start container created on vm error belwo ps c:> docker start iisdemo error response daemon: failed create endpoint iisdemo on network nat: hns failed error : failed create e ndpoint error: failed start containers: iisdemo virtual switch details below . befor stutdown vm, virtual switch type internal (powershell command à get-vmswitch) name switchtype netadapterinterfacedescription ---- ---------- ------------------------------ nat internal after start vm, virtual switch type changed blank (no switch type assign vm switch) name switchtype netadapterinterfacedescriptio

mysql - Convert SQL-query with CAST() to HQL -

please me write hql query following sql query: select max(cast(substring([columnname], 6) unsigned))+1 [tablename] distrcode = [(value)]; i cannot try myself, searching around found these probable solutions: solution 1 select max(cast(substring([columnname], 6) unsigned integer))+1 solution 2 select max(cast(substring([columnname], 6) integer))+1 maybe can try both , report back, 1 worked.

php - Change getInternalDate into user readable date? -

i got messages gmail api php,here have tried date getinternaldate output long number!so want change user readable date can't when format date() using php!! $single_message = $service->users_messages->get('me', $message_id, $optparamsget2); $date = $single_message->getinternaldate();//'1464161738000' var_dump(date("y",$date));// 1956 ,should 2016 seems getinternaldate return value in miliseconds instead of second. have divide 1000 , use date function. $date = $single_message->getinternaldate() / 1000; var_dump(date("y-m-d h:i:s", $date));

database design - Node in multiple linked list -

in our neo4j graph created serval linked list of top items specified category. example: top-50 week 2016-01 - mike posner - afrojack - willy william at point created this: (node top 50 week 201601)-[first]->(node mike posner)-[next]->(node afrojack)-[next]->(node willy). but next week, order changed willy, mike, afro. , end having multiple next relationships on each artist. traversal list slower. any idea, how model in better way. the answer @stdob-- more valid, doesn't scale well. imagine want find artists ever been number 1 , how many times, you'll have match of them traversing relationships , filter on rank property. nightmare if have 1 million artists. the idea of linkedlist fine, nodes in linkedlist can example rankitem node related artist. (week1)-[:first]->(rankitem)<-[:has_ranking_positon]-(artist) for previous question, can : match (w:week)-[:first]->()<-[:has_ranking_position]-(artist) return artist, count(*) o

python - Double Click On A WebElement in an iframe nested in an other iframe -

basically, page has following spec: <html> ... <iframe id="lvl1"> <html> <iframe id="lvl2"> <div>double click me !</div> </iframe> </html> <iframe> </html> i can't manage double click on given element (using actionchain) because when movetargetoutofboundsexception thrown. selenium.webdriver.common.action_chains import actionchains selenium.common.exceptions import movetargetoutofboundsexception try: action = actionchains(context.browser) action.double_click(webelement) action.perform() except movetargetoutofboundsexception: context.browser.switch_to_default_content() context.browser.switch_to_frame("lvl1") context.browser.switch_to_frame("lvl2") actions = actionchains(context.browser) my_locationxy = emoji.get_location() action

.net - String formatting of cell comments EPPLUS library -

Image
is possible format comments when creating .xlsx file using epplus? far know method is: excelcomment addcomment (string text , string author ); are there other known limitation comments library? if yes there better alternative in .net ? as turns out wrong in deciding prematurely epplus limited comment format the addcomment method created object , returns it. way edit objects using richtextcollection inside excelcomment this example puts in bold part of cell comment: excelcomment commento = witem.addcomment(null, "sys"); commento.richtext.removeat(0); excelrichtext ert = commento.richtext.add(dataitem.commento[0]); ert.bold = true; ert = commento.richtext.add(dataitem.commento[1]); ert.bold = false; truncation as truncation wasn't visible @ first because of dimension of comment bubble. used autofit property witem.comment.autofit = true;

php - Symfony3 form errors are not shown(just notNull/notBlank), the rest of them are working -

i try validate symfony3 form, use 2 constraints each entity field, (notblank , float). float constraint's error message shown correctly, notblank error messages shown whole form(global errors) not each separated filed. i've tried use notnull instead of notblank, didn't me. bellow i've copy/pasted snippets of code. class parameterstype extends abstracttype { /** * @param formbuilderinterface $builder * @param array $options */ public function buildform(formbuilderinterface $builder, array $options) { $builder ->add('variable_sheer_header', numbertype::class, [ 'label' => 'parameters.variable_sheer_header', 'error_bubbling' => true , 'attr' => [ 'placeholder' => 'parameters.variable_sheer_header', "class" => 'form-control'

javascript - im getting error. angular.js:13550 TypeError: Cannot read property '$invalid' of undefined -

i'm trying copy code: http://blog.mgechev.com/2014/02/08/remote-desktop-vnc-client-with-angularjs-and-yeoman/ getting error (see error down below). can me? here js code: 'use strict'; angular.module('clientapp') .controller('mainctrl', function ($scope, $location, vncclient) { $scope.host = {}; $scope.host.proxyurl = $location.protocol() + '://' + $location.host() + ':' + $location.port(); $scope.login = function () { var form = $scope['vnc-form']; if (form.$invalid) { form.$setdirty(); } else { vncclient.connect($scope.host) .then(function () { $location.path('/vnc') }, function () { $scope.errormessage = 'connection timeout. please, try again.'; }); } }; }); and html code: <div class="container"> <div class="row" style="margin-top:20px"> <di

Ruby beginner needs a hand -

i beginner in ruby. i've tried run code , shows run time error. what's wrong code? class calc attr_accessor :val1, :val2 def initialize (val1,val2) @val1=val1 @val2=val2 end end a=calc.new(2,3) a.add_two_numbers(3) def add_two_numbers(v3) return @val1+@val2+v3 end the method add_two_numbers not defined on class calc , using if is. problem. i presume got nomethoderror . update : pointed out in comments, in actuallity, method defined on object class default, gets auto inherited classes, private. means getting error saying private method being called. fix remains same, since overarching problem confusion in how define classes , methods. the fix define method on class, putting in class body. class calc attr_accessor :val1, :val2 def initialize (val1,val2) @val1=val1 @val2=val2 end def add_two_numbers(v3) return @val1+@val2+v3 end end

Re-execute if the workbook exists or not using vba Excel -

i want execute, if workbook exists re- run if not exists create workbook. i have uniques values(x) , array(names). need compare them if both equal if not has create workbook name of array(names) not had in uniques values(x) my code: sub mac() dim c integer dim x range dim s_agingscm string dim array_scm_aging variant dim newbook workbook dim newbook_scm workbook dim master_workbook workbook dim rngcopy_aging range dim rngfilter_ws2 range c = lbound(array_scm_aging) ubound(array_scm_aging) set master_workbook = thisworkbook s_agingscm = array_scm_aging(c, 1) set x = master_workbook.sheets("bass").range("ay" & c) if x = s_agingscm rngfilter_ws2 .autofilter field:=32, criteria1:="<>(a) 0 - 360", operator:=xlfiltervalues .autofilter field:=

javascript - Using SockJS with Spring, with Websocket disabled -

i need help, have using websocket client "disabled websocket" no problems while try use without oauth2 authentication or enabled websocket, in trouble when try disabled ws && oauth2auth. var accesstoken = oauth.getaccesstoken(); var socket = new sockjs("/ws?access_token=" + accesstoken); self.stompclient = stomp.over(socket); self.stompclient.connect({}, function (frame) { console.log("connecteded");... ws/info?access_token=.. goes well ws/1234/abc/xhr_streaming?access_token=.. goes too ws/1234/abc/xhr_send?access_token=.. throws 404 not found error(this 1 goes when don't add access_token in url, but, ofc, i'm not authorized, cause i'm not identified, using others services) this spring configuration resourceserverconfig @configuration @enableresourceserver @enableglobalmethodsecurity(prepostenabled = true, proxytargetclass = true) public

parsing - Proper design to parse file in c++ -

i'm trying parse file , store different fields in variable. however, i'm not sure of proper design this: should have class parsing , class storage, or should parser used storage hold fields ? i have keep in mind might need extend parser new fields may appear in file. edit: has been mentionned question broad. included more details here didn't want influence answers implemented. in current implementation faced issues extended parser, , pointed out shouldn't separate data storage , parser (because of single responsibility principle) me made sense separate them. it's question of necessity. if problem stay small, put parsing , storage together. you'll have have parsed data somewhere in memory regardless, why not right comes in? the main reason you'd want separate them if need store in different ways, such database or file, , need sort of interface can deal extensibility. but think if looks come up.

jquery - Remove DIVs others than clicked does not work -

i trying delete divs other clicked 1 using jquery in html: <div id="categories-picker"> <h2>seleccione una categoría</h2> <div class="product-left" id="cstep1"> <ul id="step1"> <li><a data-resp="main" data-id="1" class="step" href="#">monitors</a></li> <li><a data-resp="main" data-id="2" class="step" href="#">cameras</a></li> <li><a data-resp="main" data-id="4" class="step" href="#">scanners</a></li> <li><a data-resp="main" data-id="5" class="step" href="#">printers</a></li> <li><a data-resp="main" data-id="6" class="step" href="#">mi