Posts

Showing posts from June, 2012

asp.net - Cannot post object from .net Client web-api web service -

i have 1 .net client tries make http request web api service here request: public list<category> getcategories() { httpclient client = new httpclient(); client.baseaddress = new uri("http://localhost:54558/"); client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); task<string> response = client.getstringasync("api/categoryapi/"); list<category> lstcategory = jsonconvert.deserializeobjectasync<list<category>>(response.result).result; return lstcategory; } public void create(category category) { client.defaultrequestheaders.accept.add(new mediatypewithqualityheadervalue("application/json")); var stringcontent = new stringcontent(category.tostring()); httpresponsemessage responsemessage = client.postasync("api/categoryapi/", stringcontent).result; } and ...

MySQL Delete-Select row -

i'm trying delete row table subscription there 2 foreign keys ( id_user , id_journal ). information have email table user , nome table journal . deleted row needs match user.email , journal.nome . can't find solution. how can it? table user: id name email password table journal: id name table subscription: id id_user id_journal the last 2 queries tried: delete assinatura ( select tbluser.id, journal.id tbluser, journal email = '$email' , nome = '$nome') delete assinatura inner join tbluser on (tbluser.email = '$email') inner join journal on (journal.nome = '$nome') i've tried many others queries, unsuccessful. think it's important i'm new @ mysql. delete subscription id_user in ( select usr.id user usr usr.email = input_email ) , id_journal in ( select jrnl.id journal jrnl jrnl.name = input_name )

Problems getting jobs and education on Linkedin with Django (Python Social Auth) -

i'm trying linkedin profile, complete possible. problem linkedin not give me "r_fullprofile" option whereby, "educations" them "null" , "positions" returns me current jobs the permissions linkedin offers me, are: r_basicprofile r_emailaddress rw_company_admin w_share how can information before returning r_fullprofile me? best regards access r_fullprofile requires apply , granted access information linkedin. these profile fields available applications have applied , been approved apply linkedin use case. member profile fields the following selection of profile fields available linkedin developers: basic profile fields location fields position fields member profile fields available apply linkedin developers: the following selection of profile fields available applications have applied , been approved apply linkedin use case: full profile fields contact info fields company fields publication fi...

javascript - IIFE: var vs this - is there any difference? -

is there difference between this , var in invoced function expressions(iife)? (function(){ var foo = 0; this.bar = 0; })(); if code executed in global context, 2 options: you're in use strict mode, , in case this points nothing (null or undefined) , you'll see exception. you're not in use strict mode , this points window, in case you'll set bar global variable. var keeps variable local (same scope run in) , not exposed outside calls of iife.

TypeScript: Lambdas and using 'this' -

javascript frameworks call callbacks using apply(). typescript's arrow notation, however, doesn't seem allow me access 'this' pointer. how's done? if isn't, there place down-vote current 'this' handling on lambdas? typescript's handling of this in arrow functions in line es6 (read: arrow functions ). due specification, inconsistent act other way. if want access this of current function, can use regular function. for example, change: function myscope() { var f = () => console.log(this); // |this| instance of myscope f.call({}); } new myscope(); to: function myscope() { var f = function() { console.log(this); } // |this| {} f.call({}); } new myscope();

javascript - Filter by checkbox show/hide div link jquery -

i have jquery checkbox filter works showing/hiding div, when added <a href="#"></a> the checkbox no longer shows/hides div 2 of div's links demonstrate, other 2 purposefully not links show work. question needs added jquery enable checkbox act on div's when inside <a href> i tried var selecteddivs = $('#categories > .linkkk > div').hide(); didn't seem work https://jsfiddle.net/f7srx0dd/22/ <input type="checkbox" class="checkbox" name="high" data-category-type="high">high <input type="checkbox" class="checkbox" name="low" data-category-type="low" > low <input type="checkbox" class="checkbox" name="low" data-category-name="bread" > bread </div> <div id="categories"> <a href="#" class="linkkk"><div class="hide" data-c...

objective c - DDMathParser failing to tokenize solitary plus character -

using ddmathstringtokenizer , while 2 + 4 tokenizes fine 3 tokens (with second being + operator , first , third being numbers), if pass on + alone, fails return token . this not hold true every other operator i've tried, such / * - etc. i can force somehow how can ddmathstringtokenizer tokenize + correctly? to reproduce issue: following return array no objects. if change string value operator character return valid array. nserror *error = nil; nsstring *string = @"+"; ddmathoperatorset *opset = [ddmathoperatorset defaultoperatorset]; ddmathstringtokenizer *tokenizer = [[ddmathstringtokenizer alloc] initwithstring:string operatorset:opset error:&error]; nslog(@"tokens:%@", [tokenizer allobjects]); this tokenizer trying smart. since + character first token, it's assumed unary operator (no left-hand-side). gets dropped on floor, because unary + worthless operator: doesn't affect evaluation, gets omitted token stream. i b...

javascript - setInterval doesn't get cleared, function keeps getting executed -

i have following function: function monitorclimate() { var sensorreadinginterval; function startclimatemonitoring(interval) { sensorreadinginterval = setinterval(function() { io.emit('sensorreading', { temperature: sensor.gettemp() + 'c', humidity: sensor.gethumidity() + '%' }); }, interval); console.log('climate control started!'); } function stopclimatemonitoring() { clearinterval(sensorreadinginterval); console.log('climate control stopped!'); } return { start: startclimatemonitoring, stop: stopclimatemonitoring }; } i watching button changes of state this: button.watch(function(err, value) { led.writesync(value); if (value == 1) { monitorclimate().start(1000); } else { monitorclimate().stop(); } }); the problem after monitorclimate().stop() call, s...

ios - Swift 2.0 Migration errors -

i've watched wwdc sessions, reading new programmers book on swift, , reading related questions on stack overflow find. fixed errors in app after migrating swift 1.2 swift 2.0. however there's still few i've not managed solve. downcasting anyobject error: cannot downcast '[anyobject]' more optional type '[nsmanagedobject]' code: let fetchrequest = nsfetchrequest(entityname: formulaentity) var error: nserror? { let fetchedresults = try managedcontext.executefetchrequest(fetchrequest) as! [nsmanagedobject]? if let results = fetchedresults { stocks = results } else { print("could not fetch \(error), \(error!.userinfo)") } } catch { print("error: \(error)") } the error shown happening in let fetchedresults = try... line another strange error i'm having in appdelegate: error: 'nsmutabledictionary' not convertible ...

PHP -modify value of last accessed element in multidimensional associative array -

i reading gedcom -formatted family tree flat file, , producing array data staging table. if encounter values conc <some value> , then, instead of adding element, need append <some value> value of last element inserted (regardless of dimension depth). i tried current(...) etc work multidimensional associative array? please consider following element in array: [@n163@] => array ( [indi] => array ( [text] => data of person) ) if next line reads "1 conc including profession" instead of adding line such [@n163@] => array ( [indi] => array ( [text] => data of person) [indi] => array ( [conc] => including profession) ) i array follows: [@n163@] => array ( [indi] => array ( [text] => data of person including profession) ) what have researched far: end($thearray) set pointer last inserted element followed $thearray[key($thearray)] = .... update element. b...

php - Twilio cURL calling a phone -

based on documentation of twilio , curl have php curl routine: function twilio($mobile,$msg,$twocode){ $url = 'https://api.twilio.com/2010-04-01/accounts/'.twilio_account_sid.'/calls.json'; $callurl = 'http://myweb.com/code/say/'.$twocode; $auth = twilio_account_sid.":".twilio_auth_token; $fields = array( 'to' => $mobile , 'from' => '+16262471234' , // number 'url' => urlencode( $callurl ) , 'method'=>'get' , 'fallbackmethod'=>'get', 'statuscallbackmethod'=>'get', 'record'=>'false' ); $post = http_build_query($fields); $curl = curl_init($url); // set options - passing in useragent here curl_setopt($curl, curlopt_post, true); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_httpauth, curlauth_basic); curl_setopt($curl, curlopt_ssl_verifypeer, false); curl_setopt($curl, curlopt_useragent , 'm...

javascript - Div expands then shrinks - jQuery/HTML -

i trying create div not displayed @ first, when clicked becomes visible slide down animation. however, div want show grows lot in terms of height shrinks , im not sure why. i find problem occurs when browser refreshed, div clicked after works fine view code here: http://www.codeply.com/go/eqtmv0dlfp

Google cloud SDK code to execute via cron -

i trying implement automated code shut down , start vm instances in google cloud account via crontab. os ubuntu 12 lts , installed google service account can handle read/write on google cloud account. my actual code in file /home/ubu12lts/cronfiles/resetvm.sh #!/bin/bash echo y | gcloud compute instances stop my-vm-name --zone us-central1-a sleep 120s gcloud compute instances start my-vm-name --zone us-central1-a echo "completed" when call above file this, $ bash /home/ubu12lts/cronfiles/resetvm.sh it works perfect , job. now wanted set in cron automatically every hour. did $ sudo crontab -e and added code in cron 0 * * * * /bin/sh /home/ubu12lts/cronfiles/resetvm.sh >>/home/ubu12lts/cron.log and made script executable chmod +x /home/ubu12lts/cronfiles/resetvm.sh i tested crontab adding sample command of creating .txt file sample message , worked perfect. but above code gcloud sdk doesn't work through cron. vm doesn't stop neither ...

Python - Remove Braces and Commas from a Tuple CSV File -

i'm printing out csv file this: bdictionary = ## bdictionary big list of tuples w = csv.writer(open("testnucsv.csv", "w")) sent in bdictionary: w.writerow(sent) and prints out fine , looks this: (u'my', u'd') (u'dog', u'n')............... (u'the', u'd') ............................ how can print out this my d dog n d this tried, , isn't working. splits every charachter: w = csv.writer(open("testnucsv.csv", "w")) sent in bdictionary: sent = ''.join(str(v) v in sent) w.writerow(sent) wrap in list, writerow expects iterable iterates on string splitting single characters: sent = [' '.join(" ".join(v) v in sent)] you need join strings in tuple above not call str on tuple i.e: t = [(u'my', u'd'), (u'dog', u'n')] print(" ".join([" ".join(v) v in t])) d dog n you...

javascript - Experimenting with bookmarklet; redirecting normal? -

i'm trying become better in art of making bookmarklets. they're fascinating! however, code works in console doesn't work bookmarklet, as, after execution, page redirected url of code.; there reason? code: <a href='javascript:try{document.getelementsbytagname("title")[0].innerhtml=prompt("new title")||"empty"}catch(e){}'>change title</a> javascript: try { document.getelementsbytagname("title")[0].innerhtml = prompt("new title")||"empty" // in event there no user input } catch(e) {} // in event no title found try appending ;void(0) @ end of bookmarklet link. there's explanation of why that's necessary bookmarklets in this other answer . more info on bookmarklet return values provided here, http://subsimple.com/bookmarklets/rules.php#returnvalues .

netty - Apache Camel: How to read a multi-line XML response using netty4:tcp -

only xml declaration being returned since textline, without textline not work. isn't there decode codec this? the following being used send message: .recipientlist(simple("netty4:tcp://$simple{property.server}:{{server.port}}?textline=true&sync=true")) but first line of xml response containing xml declaration statement being returned: <?xml version="1.0"?>

android - Am I using findFragmentByTag Correctly -

my activity creates fragments dynamically , not created right off start(hidden). need able identify fragments can send data , them activity. keep getting null object reference when trying call fragment's function (addathletetolist) main activity. says athlete object null identifying(creating) fragment references correctly? thanks if not, how create tags fragments? main activity function sends data fragment b (athleteslist): // interface function // sends athlete information athlete list @override public void send(athlete athlete) { log.e("", "main activity: " + athlete.getfirstname()); athleteslist athleteslist = (athleteslist) getsupportfragmentmanager().findfragmentbytag("athletelist"); arraylist<string> athleteevents = new arraylist<string>(); athleteevents = athlete.getevents(); for(int = 0; < athleteevents.size(); i++) { log.e("", "athlete event: " + athleteevents.get(i...

Define word delimiter in Notepad++ -

can notepad++ configured recognise spaces word delimiters? currently, in string "hello!" said. , places word boundaries this: "|hello|!" |she |said|. . want place them this: "hello!" |she |said. scintilla (the system underlying n++) defines characters treat word delimiters. n++ can't redefine them, nppexec plugin can temporarily set them current open tab. so, install nppexec, go plugins>nppexec>execute... , enter sci_sendmsg 2077 0 @" " . put whichever characters want delimiters between quotes. discussion here: https://sourceforge.net/p/notepad-plus/discussion/331754/thread/993b6ab9/

vpn - Android VpnService with multiple addresses and routes? -

i'm working on android version of app connect software defined networks. native code behind supports connecting multiple virtual networks @ time, , i'm adapting android's vpnservice. since android limits single vpn interface, call vpnservice.builder.addaddress() , vpnservice.builder.addroute() once each virtual network, call establish() . once establish() called, can ping android device on each of assigned addresses other devices on 2 virtual networks, can routing 1 of virtual networks within android os. is possible using vpnservice.builder assign multiple addresses , routes tun interface? update: jun 15, 2015 things appear getting configured correctly. looking around in logs , via adb shell, have tun0 , tun0:1 # ifconfig tun0 tun0: ip 10.248.13.87 mask 255.255.240.0 flags [up point-to-point running] # ifconfig tun0:1 tun0:1: ip 29.182.13.87 mask 254.0.0.0 flags [up point-to-point running] and both tun entries in routing table iface destination ...

ios - iOS9 error on activityManager.startActivityUpdatesToQueue -

i opened app in new xcode7 beta worked fine in older version. i'm receiving errors, , don't know how solve it. here code. error commented out. import uikit import coremotion class viewcontroller: uiviewcontroller { let activitymanager = cmmotionactivitymanager() let pedometer = cmpedometer() @iboutlet weak var activitystate: uilabel! override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. if(cmmotionactivitymanager.isactivityavailable()){ print("yess!") self.activitymanager.startactivityupdatestoqueue(nsoperationqueue.mainqueue(), withhandler: {(data: cmmotionactivity!) -> void in //cannot invoke 'startactivityupdatestoqueue' argument list of type '(nsoperationqueue, withhandler: (cmmotionactivity!) -> void)' dispatch_async(dispatch_get_main_queue(), {() -> void in if(data.stationary == true){ self.activitystate.text = "statio...

c - Does '\0' appear naturally in text files? -

i encountered annoying bug today string (stored char[]) printed junk @ end. string suppose printed (using arduino print/write functions) correct (it correctly included \r , \n). however, there junk printed @ end. i allocated element store '\0' after '\r' , '\n' (which last 2 characters in string printed). then, print() printed string correctly. seems '\0' used indicate print() function string had terminated (i remember reading in kernighan's c). this bug appeared in code reads text file. occurred me did not encounter '\0' @ when designed code. leads me believe '\0' has no practical use in text editors , merely used print functions. correct? c strings terminated nul byte ( '\0' ) - implicitly appended string literals in double quotes, , used terminator standard library functions operating on strings. follows c strings can not contain '\0' terminator in between other characters, since there no way tell ...

How To use svn code base(custom extenstion) in hybris environment? -

i have hybris custom extension in svn , hybris package in local machine. need use svn custom extension can commit module changes/updates svn server. how edit custom extension path in localextensions.xml use svn code hybris package? so understanding want extensions save in different folder hybris/bin/myextensions, correct? if not problem. create folder want save extensions, you've said have done. open localextensions.xml in config. include extensions this: <extension> <!-- there should path dir defined within config below --> <path dir="${hybris_bin_dir}" /> <!-- navigate extensions defined, can create own path variable above if want too, example --> <extension name="${hybris_bin_dir}/../../myextensionsfolder/extension1" /> <extension name="${hybris_bin_dir}/../../myextensionsfolder/extension2" /> </extension> once build these e...

ios - Async request does not enter completion block -

the following code attempt me better understand [nsurlconnection sendasynchronousrequest:queue:completionhandler] . there nslog statements in completionhandler block, when run in main.m in xcode command line project, never enters completionhandler blocks. i've tried using different queues, mainqueue , currentqueue neither work. my hunch queue being deallocated before request completed , retain cycles involved. #import <foundation/foundation.h> int main(int argc, const char * argv[]) { @autoreleasepool { nscache *mycache = [[nscache alloc] init]; nsarray *images = @[ @"http://i.stack.imgur.com/e66qr.png", @"http://www.tiempoyquimera.com/wp-content/uploads/2010/01/euro-trash-girl-2010.jpg", @"http://1.bp.blogspot.com/-mxd8ab2nbqy/uycisjiqz3i/aaaaaaaaah8/tc43u8aa9dm/s1600/tarantino10colhans_1460858i.jpg", @"https://awestruckwanderer.files.wordpress.com/2014/02/alan-watts....

sqlite - Android Database Access Pattern -

is appropriate way database access in android app? should opening , closing database connections this, or should have 1 sqlitedatabase object continually run queries against? method specific column data cursor appropriate? public list<object> getobjects() { sqlitedatabase db = sqlitedatabase.opendatabase(this.path, null, sqlitedatabase.open_readonly); list<object> ret = new arraylist<object>(); cursor cursor = db.rawquery("select * objects", null); while(cursor.movetonext()) { object obj = new object(); obj.setid(cursor.getint(cursor.getcolumnindex("id"))); obj.settitle(cursor.getstring(cursor.getcolumnindex("title"))); ret.add(obj); } db.close(); return ret; } the singleton pattern have on final static object acces database common databases

linux - How to divide one row into multiple rows? -

the data format this(separated tab): a 1 2 3 5 6 9 b 2 3 4 6 7 8 c 5 5 7 5 6 9 output: a 1 2 3 5 6 9 b 2 3 4 b 6 7 8 they separated tab. there way it? awk -f"\t" -v ofs="\t" '{print $1, $2, $3, $4"\n" $1, $5, $6, $7}' file awk allows reference fields in data number, note $1 gets used twice, , returns first value line. same $2-$7. fields determined the fs (field separator variable), in case, -f input fs, while ofs output fs. both set tab char ( \t ). output a 1 2 3 5 6 9 b 2 3 4 b 6 7 8 c 5 5 7 c 5 6 9 ihth

raspberry pi - Beginner: How to I access an external SMB server? Windows 8.1 -

i have raspberry pi, samba configured properly. it's ip address xx.xx.xx.xx , proper ports forwarded. can access mac doing open smb://xx.xx.xx.xx not know how windows computer. have tried \\xx.xx.xx.xx\sharedfolder in browser , mapping network drive @ \\xx.xx.xx.xx\sharedfolder crashes computer when using "map network drive." i know stupid question, have found no through google searches, highly appreciated. you open start menu, search run , click enter, , type in \xx.xx.xx.xx .

javascript - generate alert on button click based on input type hidden -

i have html has tile view , each tile has info button. want check value of input hidden field , if value not in array defined raise alert. html <div class="box" style="width:30%%"> <div class="boxinner"> <form id="form_myws" method="post"> <input type="hidden" name="state" value="%s"> <div class="titlebox"> <input type="submit" value="submit" name="ws_butt" id="submit" /> </div> </form> </div> </div> javascript <script type="text/javascript"> $('#submit').click(function(){ var state_list=["available","impaired","inoperable",]; var curr_state=$(this).find("input[type='hidden'][name='state']"); console.log(curr_state.val()); if (jquery.inarray(curr_state.val(),state_...

html - 5th and 6th div tags not working -

this website designed last 2 tags don't go through tried everything, lost need help. in last 2 not performing well. not able understand problem exactly. <html> <head> <title> ggwa </title> <style> div header { width: auto; height: 48px; } div img { display: block; width: 100%; } div li { height: 30px; background: #ff5000; } div ul { margin: 0; padding: 0; } div nav ul li { list-style: none; } div.nav ul li { text-decoration: none; float: left; display: block; padding: 10px 20px; color: black; } div.nav ul li a:hover { color: white; } </style> </head> <body> <div class="header"> <img src="../images/header1.png" alt="smiley face"> </div> <div class="nav">...

position polygon accurately in Corona SDK? (relative to known vertices - issue is it creates it own centre -

question: how can 1 position polygon relative 1 of it's known vertice points? in other words how calculate auto generated center of polygon relative 1 of known vertices (i.e. used in path)? e.g. image placing specific shape on map make polygon, want position on map, can't accurately without knowing it's corona engine created centre is. extract api: "the local origin @ center of polygon , anchor point initialized local origin." ps wondering if should using line , appending points create polygon, perhaps can't add background color in case(?) the center calculated corona center of bounding box of polygon. i assume have table points of polygon stored that: local polygon = {x1,y1,x2,y2,...,xn,yn} 1) find bounding box of original points, loop thru points; smallest x , smallest y values give coordinates of top-left point; largest x , y values bottom-right point; local minx = -math.huge local miny = -math.huge local maxx = math.huge lo...

asp.net mvc - Calling actionresult from view -

this actionresult() public actionresult pay() { return view(); } [httppost] public actionresult mytry() { return view(); } and view pay.chtml @using (html.beginform("mytry", "home")) { <table> <tr> <td align="center"> <input type="button" value="submit" /> </td> </tr> </table> } i not able call mytry() action result here. how it? in order submit form, must use <input type="submit" /> or <button type="submit"> try following: @using (html.beginform("mytry", "home", formmethod.post)) { <table> <tr> <td align="center"> <input id="btnsubmit" type="submit" value="submit" /> </td> </tr> </table> }

html - Positioned divs spilling out of container -

i'm trying use this jquery grid plugin, it's not working layout. images stacked on top of each other, seem spilling out of .main, , overlap footer. help? :c body { padding: 0; margin: 0; color: $fontcolor; background-color: #eee; font: 100% 'open sans', sans-serif; background-color: $main-bg; width: 100%; height: 100%; } .container { margin: 0 auto; width: 80%; height: 100%; } .main { width: 100%; background-color: $content-bg; } .grid-container { background-color: #f9f9f9; box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.15); margin: 20px auto; position: relative; } .grid-item { display: inline-block; font-size: 0; position: absolute; } .grid-item img { cursor: pointer; display: block; width: 100%; } <body> <div class="container"> <div class="main"> <div class='grid-container'> <div class='grid-it...

CakePHP Overide getCrumbList -

how can go overiding cakephp's code without creating manually myself? i'm attempting customise getcrumblist function. the lastclass option applying class 'li' tag sucesfully, i'd remove link/ ahref altogether last tag. function generating crumbs echo $this->html->getcrumblist(array('class' => 'breadcrumb', 'lastclass' => 'active'), 'home'); output of getcrumblist <ul class="breadcrumb"><li class="first"><a href="/">home</a></li><li><a href="/scheduler">scheduler</a></li><li class="active"><a href="/scheduler/downloadedplaylist">downloaded playlists</a></li></ul> simple solution - dont include url in addcrumb. doh!

ruby - Should my $PATH be returning anything RVM related? -

i running command echo $path which returning following information containing rvm /users/rai/.rvm/gems/ruby-2.1.1/bin:/users/rai/.rvm/gems/ruby-2.1.1@global/bin:/users/rai/.rvm/rubies/ruby-2.1.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/users/rai/.rvm/bin should command return following? /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin note using on zsh should command return following? no, returns what's been set. @ ~/.zshrc file starters there other places $path can set.

javascript - Not able to debug node js app from browser -

i want debug node application(via webstorm10 & i've 9),i've put breakpoint in required file , edit run configuration following (for local debug want debug local host...) ,i want send post message via postman or fiddler , debug it... https://www.jetbrains.com/webstorm/help/running-and-debugging-node-js.html the issue program using following code app.set('port', process.env.port || 3000); and when click on debug(in ws) every time new port like debugger listening on port 59267 what should in case? i wanted debug app.get('/aa', function(req, res) { when put in browser http://localhost:59267/aa not stops , got in browser following response: type: connect v8-version: 3.28.73 protocol-version: 1 embedding-host: node v0.12.2 content-length: 0 always use process.env.port or 3000 in browser you can actual port below: console.log('server running @ port:' + app.get('port'));

python - store old values FiPy -

i'm trying solve differential equations using fipy in python , newbie, still have problems. following: define cell variable, solve equation variable , update it. want store values after each time iteration. here example: a = cellvariable(mesh,name='a', value=0., hasold=true) # eq equation involving 'a' # define array store values of 'a' after solving 'eq' a_tt = [] t in range(10): eq.sweep(dt=0.01) a.updateold() a_tt.append(a) i realize mistake - values in 'a_tt' updated every time update 'a', have @ end array same elements. shoud alternatively avoid this? i think a_tt.append(a.copy()) might work. otherwise, method used in sweeps part of http://www.ctcms.nist.gov/fipy/examples/diffusion/generated/examples.diffusion.mesh1d.html should work. like: a_tt.append(cellvariable(mesh=m, value=a.value))

intellij idea - spring boot switching from in-memory database to persistent database -

i have developed web-application using spring-boot , spring-data-jpa , and in-memory database, , have couple questions: how can switch persistent, let's say, mysql database? have change in configuration? can spring-boot set database me specific port , stored in file system? does intellij provide datasource browser created database? i sure must covered somewhere in endless jungle of spring-boot documentation. you can change application properties datasource according link gabor bakos provided. that depends on type of database want use. hsqldb , h2 allow specify file path database file, database instance still running within application process. full rmdbs mysql have install , configure mysql server , provide connection data spring boot application. yes, intellij has datasource browser major databases (maybe have download database driver).

mysql - Error 1064 ... near ':30) interval 1 week etc -

i have used following code on 1 site , trying replicate on another, above error. this post on stackoverflow, search might, can't find original, apologies creating new question. the various dates, week interval , limit derived form fields, user can generate required number of dates repeat pattern (e.g. 3 dates, 1 every week or 6 dates 1 every month). the num tables has single field, 'i', rows 0-26 select date_add(2015-01-01, interval @num := @num + 1 week) start_date, date_add(addtime(2015-01-01, 01:30 ), interval @num week) end_date, num.* num num.i not null limit 3 i'd grateful if point out glaringly obvious! thanks chris

jframe - Draw things after board is drawn with paint (JPanel) (java) -

i trying make simple tic tac toe game in java. however, cannot figure out how draw after i've drawn board. here's structure of game. public class threeinarowmain extends jpanel { public static final int width = 600, height = 640; public void paint(graphics g) { g.setcolor(color.white); g.fillrect(0, 0, width, height); g.setcolor(color.black); g.drawstring("1.", 0,20); g.drawstring("2.", 210,20); g.drawstring("3.", 410,20); g.drawstring("4.", 0,220); g.drawstring("5.", 210,220); g.drawstring("6.", 410,220); g.drawstring("7.", 0,420); g.drawstring("8.", 210,420); g.drawstring("9.", 410,420); //horizontal lines g.drawline(0, 200, width, 200); g.drawline(0, 400, width, 400); //vertical lines g.drawline(200, 0, 200, height); g.drawline(4...

.net - How to save json attribute in some c# variables -

this question has answer here: how convert json object custom c# object? 14 answers i made code uses apis provided football-data.org , managed download json containing parameters expect receive. unless content in responsetext, divide content of responsetext in variables. string requesturl = "http://api.football-data.org/alpha/soccerseasons/?season=2014"; httpwebrequest request = webrequest.create(requesturl) httpwebrequest; request.method = "get"; request.contenttype = "application/json"; string responsetext; using (httpwebresponse response = request.getresponse() httpwebresponse) using (var responsestream = new streamreader(response.getresponsestream())) { responsetext = responsestream.readtoend(); } console.writeline(responsetext); as can see structure of json shown in documentation follows: example response: { "_lin...

multithreading - How WPF Multi threading works? -

i knew basic building blocks of multithreading in wpf, have question quite confusing me. wpf applications start 2 threads: one handling rendering , managing ui. this sounds good,but ui thread bothering me, ui thread nothing application thread the thread creates wpf ui element owns elements , other threads can not interact ui elements directly,this known thread affinity. say,i have 2 text box , 1 button in myapplication , each text box have own dispatcherobject ,on button click i'll update textbox values,hope this'll done ui thread . 1.now,my question ui thread application thread, button have own dispatcherobject , two text boxes have own dispatcherobject , how ui thread has own dispatcherobject , different these ui controls dispatcherobject can update textboxes? my question is, if create new textbox in background thread can update text box ui thread? please correct understanding,i couldn't proceed further. each dispatcherobjec...

templates - C++ std::get equivalent with run-time arguments -

one cannot directly use std::get run-time arguments: template<typename tuple> void get(size_t i, tuple const& t) { using std::get; std::cout<<get<i>(t)<<std::endl; //error: 'i' not constant expression } int main() { std::tuple<int,double> t; get(1,t); } however, 1 can manually map run-time compile-time information: template<typename tuple> void get_impl(size_t i, tuple const& t, typename std::tuple_size<tuple>::type) {} template<size_t n, typename tuple, typename = std::enable_if_t<std::tuple_size<tuple>::value != n> > void get_impl(size_t i, tuple const& t, std::integral_constant<size_t, n>) { if(i==n) { std::cout<<std::get<n>(t)<<std::endl; } else { get_impl(i, t, std::integral_constant<size_t, n+1>()); } } template<typename tuple> void get(size_t i, tuple const& t) { get_impl(i, t, st...

ios - GeneratorOf<T> Cannot find an initializer Error -

Image
my attempts understand generators , sequences lead me idea implement fibonacci sequence. works perfect: struct fibonaccigenerator : generatortype { typealias element = int var current = 0, nextvalue = 1 mutating func next() -> int? { let ret = current current = nextvalue nextvalue = nextvalue + ret return ret } } struct fibonaccisequence : sequencetype { typealias generator = fibonaccigenerator func generate() -> generator { return fibonaccigenerator() } } then decide use sequenceof , generatorof same, stuck on generatorof gives me error "cannot find initializer type 'generatorof' accepts argument list of type '(() -> _)'" next code. var current = 0 var nextvalue = 1 var fgof = generatorof{ let ret = current current = nextvalue nextvalue = nextvalue + ret return ret } but if wrap function works fine: func getfibonaccigenera...

security - Android how to handle sensitive data in memory -

please have following scenario: the app uses password access remote webservice on https; to so, app asks user password, not store on device (and use in safe manner access webservice). my concern following: it's theroetically possible access memory read data contains , retrieve password. please how prevent happening? thanks please how prevent happening? i wear tin-foil hats on professional basis (besides, think spiffy...), , beyond worry about. i'd worry making https code won't victim of martian-in-the-middle (mitm) attack, that's lot easier attacker execute. that being said, samgak alludes in comment, string immutable. once password in string , @ risk attack describe. if use edittext collect password, not call gettext().tostring() user typed in. gettext() return editable , allows @ characters, not string . then, if http client api allows fill in password using char[] , once http request done, can clear out contents of char[] , clear(...

jquery - Responsive Html - vertical line across image -

Image
please me create html section below image. have used div table , created basic structure. cannot able implement vertical line across centr image.as responsive page cannot able give fixed values.please guide me on assuming icon image, should know sizes in px, right? then, wrap inside parent element, icon , table itself, example shown here. .parent { position: relative; } .parent table { width: 100%; border-spacing: 0; border-collapse: collapse; } .icon { display: block; position: absolute; left: 50%; top: 50%; margin-left: -32px; margin-top: -32px; width: 64px; height: 64px; background: #e5e5e5 url(https://cdn4.iconfinder.com/data/icons/nature-and-ecology/128/nature__eco_water_reuse-64.png) no-repeat; border-radius: 32px; } .left, .right { border: 1px solid #252122; text-align: center; padding: 15px; width: 50%; vertical-align: middle; } table span { display: block; } table td span:first-child { ...

python - Plot only one or few rows of a correlation matrix -

Image
i have correlation matrix named corrdata calculated using numpy.corrcoef . extract 1 or few rows of matrix, , want plot them instead of whole matrix. because matrix no longer square, not possible plot data using pcolor , imshow , or likes. so want ask best alternative way plot these extracted correlation coefficients , same appearance correlation matrix in terms of coloured squares representing value of correlation coefficient, showing few rows of full matrix. you can insert singleton dimension in order turn (n,) 1d vector (1, n) 2d array, use pcolor , imshow etc. normal: import numpy np matplotlib import pyplot plt # dummy correlation coefficients coeffs = np.random.randn(10, 10) row = coeffs[0] # indexing none (or equivalently, np.newaxis) inserts singleton # dimension plt.imshow(row[none, :], cmap=plt.cm.jet, interpolation='nearest') see here more ways convert 1d vector 2d array.

Livecode Block Tab Key -

how block tab key? //this handler not executed on simulator, maybe because supported in desktop , web? on tabkey end tabkey what want is, when user pressed tab key, should not add space. pressing tab in development not add add space when ran in ipad simulator 8.2, adds space when tab pressed. the rawkeydown message should want. on rawkeydown thekey if thekey not 65509 pass rawkeydown end if end rawkeydown

python - How to make matplotlib work in ipython console connecting to a remote ipython kernel -

i started ipython kernel on ubuntu machine , connect (qt)console windows run matplotlib plotting code, work when set remote kernel use inline backend, how can make work qt backend? i.e. need separated window popup plot on windows side instead of inline (small) plot console?

c++ - How do I share headers and libraries in subdirectory by cmake? -

i want use headers , libs common libraries app1 , app2. project tree below. image/ , math/ library directories used app1 , app2. in case, should set same settings both cmakelists.txt under app1 , app2? of course know works, there smarter ways set common libraries? |-- cmakelists.txt |-- app1 | |-- cmakelists.txt | `-- main.cc |-- app2 | |-- cmakelists.txt | `-- main.cc |-- image | |-- cmakelists.txt | |-- include | | `-- image_func.h | `-- src | `-- image_func.cc `-- math |-- cmakelists.txt |-- include | `-- math_util.h `-- src `-- math_util.cc roots cmakelists.txt below. possible set math , image parameters app1 , app2? actual project has many applications uses multiple libraries. cmake_minimum_required(version 2.8) add_subdirectory("./image") add_subdirectory("./math") add_subdirectory("./app1") add_subdirectory("./app2") with newer versions oft cmake (since 2.8.12) ...

unit testing - Verifying a call on $httpBackend in angularjs test -

i trying write test angularjs mocking $httpbackend. following test. describe('test', function() { beforeeach(function (){ module('abcapp'); }); var $httpbackend, filterservice; beforeeach(inject(function($injector) { $httpbackend = $injector.get('$httpbackend'); filterservice = $injector.get('filterservice'); })); it('getcompany calls on http correct parameter', function () { $httpbackend.when('get', 'api/abc').respond([]); filterservice.getabc(); $httpbackend.flush(); expect($httpbackend.get).tohavebeencalled(); }); }); when run test following error:- error: expected spy, got undefined. any ideas how assert $httpbackend.get have been called required parameter using expect. expect($httpbackend.get).tohavebeencalled(); is invalid. first because $httpbackend doesn't have (documented) get() method. second, because $httpback...

excel - INDEX/MATCH for closest value to a certain date -

in sheet "dividends" have table dividends sorted daily dates. e.g, columns , b contain following entries: 6/14/2015 6/13/2015 6/12/2015 0.045 6/11/2015 6/10/2015 this means stock paid dividend of 0.045 on 6/12/2015. in sheet "adjclose", have table weekly dates , stock prices, e.g. 6/15/2015 1.23 6/8/2015 1.24 6/1/2015 1.06 5/30/2015 1.10 5/23/2015 1.22 5/16/2015 1.20 i compute yield, divide dividend stock price closest date of dividend payout, smaller date. the result should be: 0.045/1.24 how this? many input. following 4 named ranges simplicity in code: "dividends": dividenddates (column a); dividendspaid (column b) "adjclose": stockdate (column a); stockprice (column b) try (in column c in "dividends": {=index(stockprice;match(max(if((stockdates<=a1);stockdates));stockdates;0))} assuming dividend date want find adjusted stock price in cell a1. and copy down each dividen...

ios - How to create a UIView? -

i'm following tutorial ( https://github.com/mrcapone/myadmobcontroller-ios ) add banner in app, don't understand thing, here: "for show bannerview first create uiview , add top of root uiview : uiview *adview = [[uiview alloc] initwithframe:adrect]; [[ccdirector shareddirector].view addsubview:adview]; then add bannerview it: [[myadmobcontroller sharedcontroller] addbannertoview:adview]; where says create uiview, means have create new scene? because don't know uiview (i'm beginner), can give me example of have do? the line: uiview *adview = [[uiview alloc] initwithframe:adrect]; shows how view created. , no uiview not scene. a view simple building block of ios interface components.. rect angle..

html - Changing image source in JavaScript -

i'm new javascript, , i'm trying alternate image every click 1st 2nd , 2nd 1st(indefinitely). tried this: function change() { var imgid = document.getelementbyid("image"); var ubuntu = imgid.src="ubuntu.jpg"; var debian = imgid.src="debian.jpg" if(imgid.src="ubuntu.jpg") { return debian; } else if(debian) { return ubuntu; } } <img id="image" src="ubuntu.jpg" width="160" height="120" onclick = "change()"> also, know reason why code changing image ubuntu debian not debian ubuntu. you can toggle src between 2 images so: function change () { var imgelement = document.getelementbyid("image"); if (imgelement.src === 'debian.jpg') { imgelement.src = 'ubuntu.jpg'; } else { imgelement.src = 'debian.jpg'; } } or, us...

Html+jQuery : How movable (drag) content of div? -

Image
i have parent div 150 * 150px , child div 3000 * 3000px . i want move child inside parent div, this: how can this? yo can jquery $("#child").draggable({ containment: 'parent' });

php - How to get number of video views with YouTube API V3? -

i use code achieve don't work : <?php $json = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=statistics&id=hqepb5hzub0&key={your-api-key}"); $json_data = json_decode($json); $views = $json_data->{'entry'}->{'yt$statistics'}->{'viewcount'}; echo $views; ?> thanks try this: $json = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=statistics&id=hqepb5hzub0&key={your-api-key}"); $json_data = json_decode($json, true); echo $json_data['items'][0]['statistics']['viewcount'];

jquery - Hiding a Table Row -

so here's scenario. i imported set of data xml file monitor status of printers , formatted in table. now, want make series of buttons (or checkboxes) that, when clicked, hide corresponding table row. i've tried several methods , none of them have been able work. here's code. <html> <head> <meta http-equiv="refresh" content="60"> <style> table, th, td { border: 1px solid black; border-collapse:collapse; } th, td { padding: 5px; } </style> </head> <body> <script> xmlhttp=new xmlhttprequest(); xmlhttp.open("get","runningprinters.xml", false); xmlhttp.send(); xmldoc=xmlhttp.responsexml; document.write("<table><tr><th>printer</th><th>status</th></tr>"); var x=xmldoc.getelementsbytagname("printer"); (i=0;i<x.length;i++) { document.write("<tr><td>"); document.write(x[i].getelementsbytagname(...

Project Euler #19, Python -

i solving project euler #19: how many sundays fell on first of month during twentieth century (1 jan 1901 31 dec 2000)? and here code : months = { "january": 31, "february" : 28, "march" : 31, "april" : 30, "may" : 31, "june" : 30, "july" : 31, "august" : 31, "september" : 30, "october" : 31, "november" : 30, "december" : 31} def countingsundays(): day = 1 sunday_count = 0 year in xrange(1901,2001): m in months: day += months[m] if year % 4 == 0 , m == "february": day += 1 if day % 7 == 0: sunday_count += 1 print "sundays:", sunday_count the output of program 172 incorrect. searched answer 171. wanted know why getting 1 sunday ? you're iterating...

c# - How call a cshtml view from a static html page -

i using kool-swap plugin allows transitions when redirecting new pages. when implementing plugin in c# mvc 5, can make work static html pages not cshtml pages. how can call w cshtml satic html page???? who know valid href???

yarn - hadoop ReentrantReadWriteLock -

my resourcemanager process crash, , found 78 threads 'parking wait <0x00000005a3abb250> ', , no thread held object 0x00000005a3abb250 . what hapend? "658922022@qtp-1157567439-10404" daemon prio=10 tid=0x00007fde30737000 nid=0x305a waiting on condition [0x00007fde3763d000] java.lang.thread.state: waiting (parking) @ sun.misc.unsafe.park(native method) - parking wait <0x00000005a3abb250> (a java.util.concurrent.locks.reentrantreadwritelock$nonfairsync) @ java.util.concurrent.locks.locksupport.park(locksupport.java:186) @ java.util.concurrent.locks.abstractqueuedsynchronizer.parkandcheckinterrupt(abstractqueuedsynchronizer.java:834) @ java.util.concurrent.locks.abstractqueuedsynchronizer.doacquireshared(abstractqueuedsynchronizer.java:964) @ java.util.concurrent.locks.abstractqueuedsynchronizer.acquireshared(abstractqueuedsynchronizer.java:1282) @ java.util.concurrent.locks.reentrantreadwritelock$readlock.lock(reentr...