Posts

Showing posts from February, 2011

sending JSON response from HTTP server in python -

i'm trying send data json object python http server client. here do_post function use client request: def do_post(self): if none != re.search('/compile/*', self.path): ctype, pdict = cgi.parse_header(self.headers.getheader('content-type')) print "ctype = %s", ctype if ctype == 'application/json': length = int(self.headers.getheader('content-length')) data = json.loads(self.rfile.read(length)) response = doeverything(data["userid"], data["files"]) ##response = json.dump(response, self.wfile) response = json.dumps(response) self.send_response(0) self.end_headers() self.wfile.write(str(response)) print 'everything ok' el...

angularjs - Update data from drop down list -

how can update content of element when selection made drop down list? i want update: the description fields, price , id in block details. here link of plunker created code (must manually navigate version dated jun 13, 2015 2:49:35 pm ), in following snippet. (function() { 'use strict'; var app = angular.module('testapp', []); app.controller('testctrl', ['$scope', function($scope) { $scope.variants = [{ 'id': 'p-12345', 'url': 'section/food/product/p-12345', 'title': 'product 1', 'price': '£21.15 - 21x15', 'description': 'lorem ipsum dolor' }, { 'id': 'p-12366', 'url': 'section/food/product/p-12366', 'title': 'product 2', 'price': '£11.15 - 10kg', 'description': 'lorem ip...

android - parse.com - Nested query and Join Table -

i have problem nested query. in query5.whereequalto("piwo", followlist2.get(0)) want object, spits error followlist2 needs declared final, when anonymous class gets in red cannot resolve constructor(...) error. got before? parsequery<parseobject> query3 = parsequery.getquery("piwo"); query3.whereequalto("marka", beer); // todo if(beer == "all") don't use query3.findinbackground(new findcallback<parseobject>() { public void done(list<parseobject> followlist2, parseexception e) { if (followlist2 != null) { log.d("asd", "szukane piwo: " + followlist2.get(0).getstring("marka")); } else { log.d("asd", "zero wyników1"); } parsequeryadap...

documentation - Python Sphinx anchor on arbitrary line -

Image
how can set anchor reference @ arbitrary line in rest using sphinx? to more clear, here example: a title anchor ---------------------- stuff this create heading a title anchor , add on-hover ¶ character @ end of line, anchor reference line/heading. now in following case... ``some arbitrary line`` definition ...i want have anchor some arbitrary line , same way heading. you can role called ref : http://sphinx-doc.org/markup/inline.html#role-ref specifically read 2nd bullet point addresses happens if reference not placed before title. for example, in file called example.rst how use: .. _arbitrary-anchor: arbitrary line definition the label "arbitrary-anchor" has unique through out document. reference anchor somewhere in document, this: lorem ipsum :ref:`here anchor link <arbitrary-anchor>` dolor sit amet unfortunately, anchor not show when hover on referenced line, should able access using explicit link http://example.com...

What should "git reflog show <ref>" show? -

i have 2 branches, master , b1. when i'm on b1, 'git reflog show' displays changes b1. however, after switch master , run 'git reflog show b1', displays different. manpage 'git reflog' not explain how arg, <ref>, affects output. it shows history of <ref> . if <ref> not provided, shows history of head. note not head points to , rather head itself. when git reflog show while on b1, showing history of head, not b1. when git reflog show b1 , shows history of b1. difference comes from.

unable to create a label in gmail api using javascript -

sorry being amateur @ please help,i trying create new label name news1 , code have done. this function call have used. createlabel(); my function function createlabel() { var newlabelname="news1"; var request = gapi.client.gmail.users.labels.create({ 'userid' : 'me', 'labels' : { "labellistvisibility" : "labelshow", "messagelistvisibility" : "show", "name" : newlabelname, "id" : "news" } }); request.execute(); } if use function only, can't works. have authenticate first client id provided google , permissions scopes need code. ressources : quickstart gmail js (authentification) : https://developers.google.com/gmail/api/quickstart/js creation label doc : https://developers.google.com/gmail/api/v1/reference/users/labels/create

ios - Google Places API results not showing on map? -

so have google places api working (entering url in browser displays results), yet none of results displayed on actual map. why this? using web key not ios know common error not that. code: -(void) querygoogleplaces: (nsstring *) googletype { nsstring* url = [nsstring stringwithformat:@"https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=removed stackoverflow&radius=5000&types=atm&sensor=true&key=removedforstackoverflow"]; //formulate string url object. nsurl *googlerequesturl=[nsurl urlwithstring:url]; // retrieve results of url. dispatch_async(kbgqueue, ^{ nsdata* data = [nsdata datawithcontentsofurl: googlerequesturl]; [self performselectoronmainthread:@selector(fetcheddata:) withobject:data waituntildone:yes]; }); } -(void)fetcheddata:(nsdata *)responsedata { //parse out json data nserror* error; nsdictionary* json = [nsjsonserialization jsonobjec...

Is it okay to attach methods to singleton arrays in javascript? -

is there reason why attaching methods individual instance of array might inadvisable? everyone on team seems agree fine: function communicate() { console.log(this.sound); } var maru = {name: 'maru', sound: 'prrrrrr'}; var garfield = {name: 'garfield', sound: 'anyone lasagna?'}; maru.talk = garfield.talk = communicate; there's option of making formal constructor, if need 1 cat, it's nice don't have bother. this bit more controversial on team: function socialize() { this.foreach(function(creature) { creature.talk(); }); } var cats = [garfield, maru]; cats.meowfest = socialize; cats.meowfest(); //=> prrrrrr //=> lasagna? other developers on team insist must subclass array rather adding methods on-the-fly. me, seems same fundamental principle in first example. there's option of making formal constructor, if need 1 cats array, it's nice don't have bother. wrong? so far, i've heard 2 argu...

animation - Did WPF storyboard end naturally, or was it interrupted? -

background: creating application using eye tracking. prevent buttons being activated inadvertently short glance, wish introduce delay between user's gaze landing on button , button being activated. i have created animation colours button left right give user visual feedback, shown below on number '6' (ignore red dots, tracking markers won't show normally). if user looks away before timeout, button not activated; if gaze still on button @ end of timeout, button activated. don't have reputation post images; it's @ http://i.stack.imgur.com/fu3j7.jpg . as using animation provide visual feedback user, seems sensible me trigger button activation animation completion. the animation triggered follows: <style.triggers> <trigger property="**attached property providing gaze notification**" value="true"> <trigger.enteractions> <beginstoryboard storyboard="{staticresource animatebutton}" /> </trig...

java - NullPointerError on saveOrUpdate Hibernate -

i trying update object in function: public void pricelot(long lotid) throws exception { lot lot = this.getlotbyid(lotid); list list = bookservice.getbooksbylotnumber(lotid); book book = new book(); productavailability pa = null; float retail = 0; for(int = 0; < list.size(); i++) { book = (book) list.get(i); retail += book.getprice(); } if(retail == 0) { retail = 1; } float ratio = lot.getamount() / retail; for(int = 0; < list.size(); i++) { book = (book) list.get(i); pa = book.getproductavailability(); pa.setcost(pa.getretail() * ratio); productavailabilityservice.saveorupdateproductavailability(pa); } lot.setpriced(true); this.saveorupdate(lot); } it runs line productavailabilityservice.saveorupdateproductavailability(pa); and here, dead-ends , returns nullpointerexception . don't know why it's doing this--nothing should null. here stack trace: ja...

android - Dynamically disable auto-capitalization of an EditText -

i dynamically creating edittext , want disable auto-capitalization on sentences (new lines). i have tried variation of flags edittext.setinputtype(int) none of them have accomplished disabling shift key being enabled on new lines. here code: sharedpreferences preferences = preferencemanager.getdefaultsharedpreferences(context); edittext edittext = new edittext(context); int type = inputtype.type_class_text | inputtype.type_text_flag_multi_line | inputtype.type_text_flag_ime_multi_line; if (preferences.getboolean("disable_suggestions", true)) { type |= inputtype.type_text_flag_no_suggestions | inputtype.type_text_variation_visible_password; } if (preferences.getboolean("disable_auto_capitalization", true)) { // // todo: stackoverflow rescue! flag need? // } edittext.setinputtype(type); i have searched stackoverflow extensively answer , question found this . as @commonsware pointed out, doing shou...

html - Other divs moving when list appears as dropdown in navbar -

i'm bit new css please forgive me shortcomings side. i working on website , have made navbar in have few divs. of divs contain list kind of drops down when hover of them. problem makes div increase in width , makes other divs around move around. have observed width increases width of lengthiest element in list. have no idea causing , have tried playing position nothing seems work. stop moving around of above divs doesn't weird. html: <body> <div class="header" id="banner"></div> <div class="header" id="navbar"> <div class="nb_item">home</div> <div class="nb_item">about <ul id="abtus_menu"> <li>la martiniere college, lucknow</li> <li>la martiniere model united nations</li> <li>secretariat</li> </ul> </div> <div class="nb_i...

python - DJANGO DATATABLES template not working -

i'm working on simple example using datatables fetch result templates not showing @ , there's no error in console ! html page : trial.html {% load static %} <html> <head> <link rel="stylesheet" href="{% static "css/jquery.datatables.css" %}" type="text/css" /> <link rel="stylesheet" href="{% static "css/datatables.tabletools.css" %}" type="text/css" /> <link rel="stylesheet" href="{% static "js/jquery.js" %}" type="text/javascript" /> <link rel="stylesheet" href="{% static "js/jquery.datatables.js" %}" type="text/javascript" /> </head> <body> <table cellpadding="0" cellspacing="0" border="0" id="example"> <thead> <tr><th></th></tr> </thead> <tbody></tbody...

callback - Twilio: Best method for retrieving media uri for sent sms -

when server sends sms mediaurl parameter specified, want utilize link location(s) twilio assigns image(s) construct img tags src properties based on media->uri. up until today, following code working... $client = new services_twilio($twilio_sid, $twilio_token); $params = array ( "to" => $to, "from" => $from, "body" => $body, "mediaurl" => $media, "statuscallback" => $twilio_callbackurl ); $message = $client->account->messages->create($params); $sid = $message->sid; $status = $message->status; $attachments = ""; foreach ($message->media $media) { $attachment = $twilio_mediaurl . $media->uri; $attachments .= "<br><br><a href='" . $attachment . "' target='_blank'><img src='" . $attachment . "' target='_blank'></a>"; } i'm not sure whether above shown techniqu...

javascript - I have Jquery set to read a JSON file but only i see it on the website? -

i have few friends helping me out going on website see if comes up, show me nothing comes up, , me stuff json file shows me php file ajax: <?php include '../filter.php'; $chatjson = file_get_contents('chats.json'); $chatarray = array(); $sender = securepost($_post["sender"]); $message = securepost($_post["message"]); if ($sender || $message) { $chatarray[] = array('sender' => $sender, 'message' => $message); if (json_decode($chatjson)) { $chatarray[] = json_decode($chatjson); } file_put_contents("chats.json",json_encode($chatarray)); } ?> ajax var j = jquery.noconflict(); var chats = []; var xhr; if (window.xmlhttprequest) { xhr = new xmlhttprequest(); } else if (window.activexobject) { xhr = new activexobject("msxml2.xmlhttp"); } else { throw new error("ajax not supported browser...

python - calling function with dataframe data gives error (cannot convert the series to <class 'float'>) -

i have option pricing model (very simple black scholes) works fine data in fashion: in [18]: bs2(100.,100.,1.,.001,.3) out[18]: 11.96762435837207 the function here: black sholes function def bs2(s,x,t,r,v): d1 = (log(s/x)+(.001+v*v/2)*t)/(v*sqrt(t)) d2 = d1-v*sqrt(t) return (s*cnd(d1)-x*exp(-.001*t)*cnd(d2)) i not think matters question, bs2 calls this: cumulative normal distribution function def cnd(x): (a1,a2,a3,a4,a5) = (0.31938153, -0.356563782, 1.781477937, -1.821255978, 1.330274429) l = abs(x) k = 1.0 / (1.0 + 0.2316419 * l) w = 1.0 - 1.0 / sqrt(2*pi)*exp(-l*l/2.) * (a1*k + a2*k*k + a3*pow(k,3) + a4*pow(k,4) + a5*pow(k,5)) if x<0: w = 1.0-w return w i tried modify working bs function accept data df seem have done wrong: def bs(df): d1 = (log(s/x)+(.001+v*v/2)*t)/(v*sqrt(t)) d2 = d1-v*sqrt(t) return pd.series((s*cnd(d1)-x*exp(-.001*t)*cnd(d2))) my data straight forward: in [13]: df out[1...

facebook og:title not working, facebook scraper does not see anything -

this html: <html> <head> <meta property="og:title" content="this title" /> <meta property="og:description" content="this content" /> </head> <body> test </body> </html> now facebook-debug-tool tells me 'og:title' of type 'string' not provided. clicking on "see our scraper sees" returns blank page. "test" within body not displayed. have disabled gzip content type proposed in answer... i down-vote own question.. the problem had rewrite-rules in place targeted @ google-crawler. long story short: facebook-crawler got hooked rewrite-rules, too. after removing rewrite rules worked chram.

javascript - Clicking a button does something similar to "forward" in table -

i have code in content script traverses table finding cell , wraps button around cell. created jquery click command: $(this).click(function(){ (var = 0 ; <result.length; i++) { window.open(result[i].url) }; }); which open url on click. now, when click button in table url/urls open in new tab, but, change current frame this: not found requested url /ban2p/bwskfreg.p_altpin1 not found. which happens when right clicking webpage , clicking "forward". does know going on? have no clue fix this. can provide more information if it's necessary. this because not appending rest of url. check demo you trying open /ban2p/bwskfreg.p_altpin1 not valid url because missing domain name. try http://www.yourdomainname.com/ban2p/bwskfreg.p_altpin1

firefox - How to use HTTP/2 connection instead of session cookies? -

is possible use http/2 connection (tcp session) session tracking, instead of session cookies (this when cookies disabled)? http/2 published 2015-05-14 ( rfc 7540 ) http/2 enabled default in ff 2015-01-13 ( v35 ). list of http/2-server implementations ( http2-katana , etc) http/2 connections long lived, not persistent; h2 connection can go away , die @ time. , internet, tcp connections can torn down no apparent reasons :-). if requirements http session handling can deal that, yeah, can use (one) h2 connection session "cookie". unreliable , unpredictable @ best.

mysqli - MySql count all before max(date) of row that meets certain criteria -

i'm trying last recorded loss, count number of wins after calculate win streak. begin set @maxdate:=(select max(date) game_scores user_score<opponent_score , user_id=1); select @maxdate last_loss, count(*) streak game_scores user_score>opponent_score , date>@maxdate , user_id=1; end but keep getting syntax errors @ set @maxdate line. close? you can in single shot if join query last loss date. also note that, if you've located user's last loss date, of records after wins second query doesn't need check user score against opponent score. select last_recorded_loss.maxdate last_loss, count(*) streak game_scores inner join ( select max(date) maxdate game_scores user_score < opponent_score , user_id = 1 ) last_recorded_loss on game_scores.date > last_recorded_loss.maxdate , game_scores.user_id = 1

c - Is there a meaningful distinction between freestanding and hosted implementations? -

the question have related section four, paragraph six . the 2 forms of conforming implementation hosted , freestanding. conforming hosted implementation shall accept strictly conforming program. as understand, constitutes typical application environment, filesystems, allocated memory , threads... a conforming freestanding implementation shall accept strictly conforming program in use of features specified in library clause (clause 7) confined contents of standard headers <float.h> , <iso646.h> , <limits.h> , <stdalign.h> , <stdarg.h> , <stdbool.h> , <stddef.h> , <stdint.h> , , <stdnoreturn.h> . ... , constitutes typical kernel and/or embedded, bare minimum environment doesn't have standard filesystems, allocated memory or threads (among other things). a conforming implementation may have extensions (including additional library functions), provided not alter behavior of strictly conforming program. i...

intellij idea - How to prohibit whole file reformatting, but allow reformatting of the selected text? -

Image
sometimes want reformat specific parts of files, never want accidentally reformat whole file. with intellij idea "reformat code" action, if configure "reformat selection", reformat selection if selected text, still reformat whole file if none of text selected. may forget , hit "reformat code" not selecting text, , when time commit find out reformatted file didn't want reformat. how can disable reformatting whole file when none of text selected, still able reformat text explicitly selected? set in reformat file dialog - ctrl + shift + alt + l

scala - Finding the implicit value for Json in play -

when use following code: import jsonimpl.graphformat val js = json.tojson(g)(graphformat) my code compiles , works fine when doesn't work , says: "no json serializer found type sgraph. try implement implicit writes or format type." import jsonimpl.graphformat val js = json.tojson(g) jsonimpl is: object jsonimpl{ implicit val graphformat = json.format[sgraph] } i don't want use companion object sgraph class. problem , why cannot find implicit value? for sake of completeness: json.format macro, , when you're dealing macros it's idea make sure you're getting appropriately statically typed: object jsonimpl{ implicit val graphformat: format[sgraph] = json.format[sgraph] } in fact idea whenever you're dealing implicit values, , it'll save lot of confusion (sometimes because you've done wrong, , because compiler has).

c++ - How Do I Debug A Notepad++ DLL Plugin? -

i trying write plugin notepad++ using visual studio community 2013 the dll builds fine solution , if copy notepad++/plugins directory can test out functionality. however, want debug , can't launch debugger. tried following paint.net guide still error unable start program .....dll on project properties under configuration properties - debugging have following set: command = c:\tools\notepad++\notepad++.exe working directory = c:\tools\notepad++ configuration properties - build events - post-build event have: command line = copy "$(targetpath)" "c:\tools\notepad++\plugins" nb: path outside program files avoid uac issues when copying. what other options causing issue? make sure have debug build of dll built symbols enabled, , use debug -> attach process menu command attach notepad++ process once it's running.

ios - Array types are now written with the brackets around the element type -

here's code (taskmanager.swift): import uikit var taskmgr: taskmanager = taskmanager () struct task { var name = "untitled" var desc = "none" } class taskmanager: nsobject { var tasks = task[]() func addtask (name: string, desc: string) { tasks.append (task (name: name, desc: desc)) } } then got this /users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/taskmanager.swift:11:21: array types written brackets around element type it says fix-it: insert "[" i clicked it, line (line 11) turned this: var tasks = [task[]() and got these errors /users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/taskmanager.swift:11:26: expected ']' in container literal expression /users/david/documents/360drive/xcode/try/randomtries/todolist/todolist/taskmanager.swift:11:26: expected ',' separator /users/david/documents/360drive/xcode/try/randomtries/todol...

uitableview - UITablieview with constantly changing values -

is possible use uitableview in such way it's cells update content indepedantly cellforrowatindexpath method? example: showing cells timer includes milliseconds. refreshing table view every (say) 10 milliseconds in order update timer's display value each cell surely not work, well... tricky if use re-usable cells. if know don't have many rows, sub-class uitableviewcell , whatever wanted to....

ios - Xcode compiler keeps crashing on a class that has a dictionary with a lot of elements -

compiler keeps crashing "segmentation fault 11" on class has dictionary on 40 thousand value pairs defined. if reduce amount of lines works. there no duplicate keys. i understand it's xcode bug, perhaps there known workaround? class rates { let array:[int:double] = [ 99502:0.1730, 99503:0.1730, 99504:0.1730, // 42000 lines, defining other value pairs here 83414:0.0837 ] subscript(index: int) -> double? { return self.array[index] } }

java - How to parse/unzip/unpack Maven repository indexes generated by Nexus -

i have downloaded indexes generated maven central http://mirrors.ibiblio.org/pub/mirrors/maven2/dot-index/nexus-maven-repository-index.gz i list artifacts information these index files (groupid, artifactid, version example). have read there high level api that. seems have use following maven dependency. however, don't know entry point use (which class?) , how use access files: <dependency> <groupid>org.sonatype.nexus</groupid> <artifactid>nexus-indexer</artifactid> <version>3.0.4</version> </dependency> take peek @ https://github.com/cstamas/maven-indexer-examples project. in short: dont need download gz/zip (new/legacy format) manually, indexer take care of doing (moreover, handle incremental updates too, if possible). gz "new" format, independent of lucene index-format (hence, independent of lucene version) containing data only, while zip "old" format, plain lucene 2.4.x index zi...

rust - Global feature gates in Cargo -

i enable feature gate entire cargo project. example, #![feature(non_ascii_idents)] added every source file. there place list them in cargo.toml ? no, though don't add feature gates every source file; crate attributes . is, set them on crate, not on every module.

swift2 - Swift 2: Invalid conversion from throwing function of type to non-throwing function -

Image
i have (ugly) self-written code ported swift2 , got error message in lambda function: what didn't understand is, handle whole code error throwing function jsonobjectwithdata , catch error. throw nothing in code. nevertheless compiler means throwing error. i need understand behavior. please kind because know have improve code make full use of new error handling concept in swift2. thank in advance. this fast. have figured solution problem out little of article: http://www.hackingwithswift.com/new-syntax-swift-2-error-handling-try-catch you have put general catch clause @ end of code because catch of nserror alone not sufficient. catch let error nserror { failure(error: error) return } // important --> catch { }

ruby - TicTacToe invalid move method issue -

below take tictactoe game. far works, it's not perfect. i'm having issue 1 of methods - game#invalid_move_check? after game asked "where to:"once choose new destination , game change symbol if new turn .in fact not , suppose keep same player symbol until next turn. p.s code need refactoring. i'm in learning phase. class game def initialize(symbol) @board = array.new(3){array.new(3)} # [0,1,2] # [3,4,5] # [6,7,8] @symbol = ["x", "o"] end winning_combo = [ # horizontal wins: [0, 1, 2], [3, 4, 5], [6, 7, 8], # vertical wins: [0, 3, 6], [1, 4, 7], [2, 5, 8], # diagonal wins: [0, 4, 8], [2, 4, 6] ] def create_players # create both players @names = [] print "please enter name of first player: " @player_1 =gets.chomp @names << @player_1 print "please enter name of second player: " @player_2 = gets.chomp @names << @player_2 puts "...

c++ - Can't create QList with custom class -

i'm trying create qlist of custom class objects, got error: error: c2923: 'qlist' : 'read' not valid template type argument parameter 't' my code (user header): #ifndef user_h #define user_h #include <qstring> #include <qlist> #include "read.h" class user { protected: int id; qstring username; qstring password; qlist<read> readbooks; bool accountdeleted; bool admin; public: user(); user(int id, qstring username, qstring password, qlist<read> readbooks, bool accountdeleted, bool admin); ~user(); const int getid(); void setid(int id); const qstring getusername(); void setusername(qstring username); const qstring getpassword(); void setpassword(qstring password); const qlist<read> getreadbooks(); void setreadbooks(qlist<read> readbooks); const bool isaccountdeleted(); void setaccountdeleted(bool accountdeleted); ...

c# - Is there a way to access a private property in a where clause? -

i'm trying directly map domain model ef. end introduced private property in model so: private icollection<tag> tagsinternal { get; set; } public article(guid id, ... , ienumerable<tag> tags) : base(id) { ... this.tagsinternal = new list<tag>(tags.where(i => != null)); } public ienumerable<tag> tags { { return this.tagsinternal.asenumerable(); } } in order access ef 'backing property' added handful of extension methods: public static class fluentapiextensions { public static manynavigationpropertyconfiguration<tentitytype, ttargetentitytype> hasmany<tentitytype, ttargetentitytype>(this entitytypeconfiguration<tentitytype> mapper, string propertyname) tentitytype : class ttargetentitytype : class { var lambda = getlambdaexpression<tentitytype>(propertyname); return mapper .hasmany((expression<func<tentitytype, icollection<ttargetentitytype>>...

Android WebView ajax request interception -

i intercept ajax call webview, add data url, , continue request usual: for example: change http://localhost:5000/dosomething to http://localhost:5000/dosomething?secret=my_secret and pass request web server. i didn't succeeded doing shouldinterceptrequest

mongodb - Check for existing user doesn't go along -

as waterline's unique attribute is ignored mongodb , take decision make check existing model entry in code: var username = req.param('username'); var email = req.param('email'); var asd = ""; // check if user exists user.findone({username: username}, function (err, user) { asd = "invalid username"; console.log(asd); if(err){ return res.servererror('error creating user' + err); } if(user){ asd = "invalid username"; console.log(asd); return res.json({status: "invalid_username"}); } }); user.findone({email: email}, function (err, user) { asd = "invalid email"; console.log(asd); if(err){ return res.servererror('error creating user' + err); } if(us...

c# - Refresh progress bar -

i want refresh progess bar in c# wpf. this question sounds easy , should able google it. solutions have seen unsatisfy me. assuming have run long algorithm e.g. 5 different steps. don't know how long take calculate different steps. know have programmed use profiler check how time cpu uses each step (in % of total time steps). this times e.g.: method1() takes 3s method2() takes 5s method3() takes 1s this approaches: the "easy" approach: progressbar pb = new progressbar() { // total duration of methods maximum = 9 }; method1(); // + 3 3 seconds pb.value += timeformethod1; method2(); // + 5 5 seconds pb.value += timeformethod2; method3(); // + 1 1 second pb.value += timeformethod3; this pretty easy. has problem. blocks ui thread 9 seconds wich horrible (because user think programm has crashed). so seems obvious use thread.. the "thread" approac...

regex - Extract numbers from a string in java -

i want extract numbers string like: str="good_mor9ni13ng_23guys "; the output should array [9,13,23] . how should proceed? you this: list<string> matches = new arraylist<string>(); matcher m = pattern.compile("[0-9]+").matcher("good_mor9ni13ng_23guys"); while (m.find()) { matches.add(m.group()); }

Using spring cloud namespace and two DataSources -

i have spring integration war component i'm updating run in private pcf. have 2 datasources , rabbitmq connection factory defined in application. i see article thomas risberg on using cloud namespace , handling multiple services of same time - https://spring.io/blog/2011/11/09/using-cloud-foundry-services-with-spring-part-3-the-cloud-namespace . handled using @autowired , @qualifier annotations. i'm wondering how can achieved though when we're not @autowired , @qualifier annotations, e.g. wiring datasource jdbctemplate. here not have ability specify @qualifier annotation. my application spring xml config based. have ability use @autowired , @qualifier annotations on 1 of datasources, other jpa entity manager. see code snippet. any appreciated. <bean id="entitymanagerfactory" class="org.springframework.orm.jpa.localcontainerentitymanagerfactorybean"> <property name="datasource" ref="datasource...

loops - Javascript how to start script on exact time -

script start on exact time (ex: 2015:06:15:00:00) if on time, alert hello every 1 second. setinterval(function () {alert("hello")}, 1000); could please me how make on up? i'd use gettime object in js i believe have time set right in jsfiddle var d = new date(); var year = d.getfullyear(); // month 0 = january | month 11 = december | changed vallues +one var month = d.getmonth() + 1; var day = d.getdate(); var hour = d.gethours(); var minute = d.getminutes(); var second = d.getseconds(); var overall = year.tostring() + month.tostring() + day.tostring() + hour.tostring() + minute.tostring() + second.tostring(); alert(overall); var checkdate = function () { if(overall==="20156150000") { setinterval(function(){ alert("hello"); }, 1000); }; }; window.setinterval(checkdate(), 1000);

javascript - Using 'Google Maps API' in a Web Worker -

i'm trying load google maps api in javascript web worker, fails load maps library. web worker code looks follows: importscripts('http://maps.googleapis.com/maps/api/js?libraries=geometry&key=myapikey&sensor=false'); this fails simple script error. in chrome when try load worker. i assume in maps library tries access dom. guess. has solution? edit: opened link above , tried extract+modify it's contents. webworker.js looks this: var window = {google: {}}; var google = {maps: {}}; (function() { function getscript(src) { importscripts(src); //document.write('<' + 'script src="' + src + '"><' + '/script>'); } var modules = google.maps.modules = {}; google.maps.__gjsload__ = function(name, text) { modules[name] = text; }; google.maps.load = function(apiload) { delete google.maps.load; apiload([0.009999999776482582,[[["http://mt0.googleapis.com/vt?lyrs=m@...