Posts

Showing posts from January, 2015

java - Can I call from one ejb3 session bean method to other method in same session bean ? -

can call 1 ejb3 session bean (statless/statefull) method other method in same session bean ? state of members save between calls ? yes, can. use @resource sessioncontext inject instance, , use getbusinessobject (or getejbobject or getejblocalobject depending on view want); see javadoc methods. for stateless beans, invocation on new bean instance. depending on you're trying do, can simpler use @ejb yourinterface directly inject proxy rather using sessioncontext. for stateful beans, state of bean "preserved" because you'll invoking same underlying bean instance.

regex - How to totally compare a string with regular expression in objective C -

i trying see via reg ex if user gave correct input(user should give complex number), , dependent on input program should give action. so far have 3 reg expressions comparison: @"([-]?[1-9][0-9]*[+|-][1-9][0-9]*i)+" @"([-]?[1-9][0-9]*)+" @"([-]?[1-9][0-9]*[i])+" in case want see if complex number given correctly, use first reg ex. if not given correctly want use other 2 expressions see if user used abbreviations input. the problem if user gives 3i in program real number, because of reg ex. reg ex testing if part of string correct, , want know if entire string correct. for example if type 3i3 , if use third expression, result true, , want true 3i. if want make regex matches entire string, add ^ , $ anchors it: @"^([-]?[1-9][0-9]*[+|-][1-9][0-9]*i)+$" @"^([-]?[1-9][0-9]*)+$" @"^([-]?[1-9][0-9]*[i])+$" ^ @ beginning means match must start @ beginning of input string $ @ end means there must no ch...

jquery - Django: accept AJAX call and render response? -

here's javascript code: function getcookie(name) { var cookievalue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); (var = 0; < cookies.length; i++) { var cookie = jquery.trim(cookies[i]); // cookie string begin name want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookievalue = decodeuricomponent(cookie.substring(name.length + 1)); break; } } } return cookievalue; }; var csrftoken = getcookie('csrftoken'); //ajax call function csrfsafemethod(method) { // these http methods not require csrf protection return (/^(get|head|options|trace)$/.test(method)); } $.ajaxsetup({ crossdomain: false, // obviates need sameorigin test befores...

RegEx multiple optional characters in group -

how define optional characters in group? i trying match following... kg kilo kilos kilogram kilograms g gram grams i know can put them individually in group, wondering if fancy this... (kg|kilo?g?ram?s?) problem match s? or none of second alternation match 0 length. i start enumerating of possible match conditions , paring down there see if there more efficient solution: kg|kilo|kilos|kilogram|kilograms|g|gram|grams the plural 's' obvious redundancy: kg|kilos?|kilograms?|g|grams? g , kg can collapsed: k?g|kilos?|kilograms?|grams? we can collapse units kilograms: k?g|kilo(?:s|grams?)?|grams? are ok 6 character duplication of "grams?" :)

java - HashMap's Iterator to prevent concurrent modification -

this question has answer here: iterating on , removing map 12 answers the following piece of code, while executed single thread, throws concurrentmodificationexception on line 4: map<string, string> map = new hashmap<string, string>(); map.put("key1", "value1"); map.put("key2", "value2"); (string key : map.keyset()) { // here map.remove(key); } i couldn't find map.iterator() or map.mapiterator() method on hashmap javadoc . should do? as guessed, need iterator removing items during iteration. way map iterate entryset() (or, alternatively, keyset() , if need evaluate key): iterator<map.entry<string, string>> entryiter = map.entryset().iterator(); while (iter.hasnext()) { map.entry<string, string> entry = iter.next(); iter.remove(); // guard condition? }

How to use a certificate for encryption in java se -

i've code app in java let user write text , use certificate encrypt string , show (encrypted) in textfield. coded graphical interface i've searched how use certificate encrypt/decrypt variable in java , didn't find case ! help. your certificate can exported file (eg.: "mycert.cer"). use api provided jca (java cryptography architecture) manipulate it. for instance, read certificate, use fileinputstream fis = new fileinputstream("mycert.cer"); certificatefactory cf = certificatefactory.getinstance("x509"); x509certificate crt = (x509certificate) cf.generatecertificate(fis); from public key of x509certificate object, encrypt text. need here , here .

c++ - Using .size() vs const variable for loops -

i have vector : vector<body*> bodies; and contains pointers body objects have defined. i have unsigned int const contains number of body objects wish have in bodies . unsigned int const numparticles = 1000; i have populated bodies with numparticles amount of body objects. now if wish iterate through loop, example invoking each of body 's update() functions in bodies , have 2 choices on can do: first: for (unsigned int = 0; < numparticles; i++) { bodies.at(i)->update(); } or second: for (unsigned int = 0; < bodies.size(); i++) { bodies.at(i)->update(); } there pro's , con's of each. know 1 (if either) better practice, in terms of safety, readability , convention. i suggest use .size() function instead of defining new constant. why? safety : since .size() not throw exceptions, safe use .size() . readability : imho, bodies.size() conveys size of vector bodies more numparticles . convention : according ...

javascript - set css image from current folder using jquery script page -

i have external javascript page located under ../scripts/cbox/ folder parent. there image located in same folder. want set background-image control using jquery there. when use code, sets background-image path localhost:7905/ddl_arrow.png localhost:7905 asp.net development server. function createautocbox(boxctrl) { $(boxctrl).css('background-image', 'url("ddl_arrow.png")'); $(boxctrl).css('background-repeat', 'no-repeat'); $(boxctrl).css('background-position-x', '99%'); $(boxctrl).css('background-position-y', '-2px'); $(boxctrl).mousemove(jqautocompletemousemove); $(boxctrl).keyup(jqautocompletekeyup); $(boxctrl).mousedown(jqautocompletemousedown); } there no way "get current script's path on server", since js done on client-side. there no easy way thinking of. there ways work around this, , of them based on same principle: organise files - each...

variables - The params of c++ function -

this question has answer here: what differences between pointer variable , reference variable in c++? 30 answers the c function param such : void test(int fp, int &pos){ //do something... } but don't understand "int &pos" meant . thank help it means pos made reference variable variable being passed during function call(their address becomes same).ie, change in pos reflects in calling variable.for example : if function call test(f,p); changes made pos reflect in p.

javascript - Value to configure without having to submit a form with change function -

i have checkout page trying configure tax with. simple tax amount. if lives in ohio value 1.065 , if in other state in nothing. i'm not best @ using javascript php, may why having difficulties. trying configure without submitting form. when customer has click drop down box select state, want configure then. not submitting form until later in page , want them see value right away. i start having list of arrays of states this.. $taxvalue['ohio'] = 1.065; $taxvalue['wyoming'] = 1; then making variable tax amounts: $taxed_state = 1.065; $untaxed_state = 1; then i'm checking if state set , adding taxed variable it. if(isset($taxvalue['ohio'])){ $taxed_state; } else { $untaxed_state; } this how i'm going configure total tax. $base_price = 0; foreach($_session['shopping_cart'] $id => $product) { $product_id = $product['product_id']; $base_...

web services - Sending POST request to a WebService from Excel -

we have scenario requires send post requests excel web service. sample request api: http://localhost/api/createticket?name=mark&rownumber=65 the parameters (name & rownumber) should taken excel cells. how can achieved? in end took steps detailed in microsoft's article. msdn article - consuming web services in excel 2007

java - Square with minimum area enclosing K points among given N points -

this question asked me in online test. there n points given in cartesian plane. integer k given. aim find area of square (minimum) enclosing @ least k points. sides of square should parallel axis.the vertices of square should integers. points lying on sides not considered inside square. i solve k=n (i.e. points lie in square). my solution - static int minarea(int[] x, int[] y, int k) { //find max y int maxval = integer.min_value; for(int : y){ if(i > maxval){ maxval = i; } } //find min y int minval = integer.max_value; for(int : x){ if(i < minval){ minval = i; } } int ylength = (maxval-minval)+2; //find max x maxval = integer.min_value; for(int : x){ if(i > maxval){ maxval = i; } } //find min x minval = integer.max_value; for(int : x){ if(i < minval){ minval = i; } } int xleng...

asp.net mvc - In Javascript in a MVC Razor, replace a keyword with a value from the model -

when have javascript on mvc razor view possible model variable replacement in middle of multipart statement. to clarify have code <script> function drawchart() { $.post('@url.content("~/home/getdataassets")', function (d) { ... var chart = new google.visualization.linechart(document.getelementbyid('chart_div')); chart.draw(data, options); }); }; where want type of graph displayed come model. chart line have var chart = new google.visualization.@model.charttype(document.getelementbyid('chart_div')); where linechart has been replaced @model.charttype this gives error charttype being used method is there way make substitution? as @stephen-muecke said razor code parsed on server side , javascript code on client side . if model.charttype returns string, i.e. linechart , need output paranthesis , content of (...) text. to have add @{<text> ... </text>} output plain...

asp.net - Error after migrating AjaxControlToolkit 1.x to 3.5 -

i'm getting error after migrated ajaxcontroltoolkit 1.0... 3.5 recently: extender control 'alwaysvisibleloading' cannot extend 'updateprogress1'. extender controls of type 'ajaxcontroltoolkit.alwaysvisiblecontrolextender' cannot extend controls of type 'system.web.ui.updateprogress' couldn't helpful references on far. anyone?

Retrieve the data from three different tables based two parameters in php mysql -

this tried : select a.cs_id, a.class, b.sec_id, b.cs_id, b.cs_name, c.stud_id, c.stud_class, c.stud_section, c.stud_adm_no, c.stud_full_name class_section inner join section_name b on a.cs_id=b.cs_id inner join student_detail c on c.stud_class=b.sec_id a.cs_id=1 it's retrieving higher order variable only select a.cs_id, a.class, b.sec_id, b.cs_name, c.stud_id, c.stud_class, c.stud_section, c.stud_adm_no, c.stud_full_name class_section inner join section_name b on a.cs_id=b.cs_id inner join student_detail c on c.stud_class=b.sec_id a.cs_id=1 may alias problem b should b c should c

java - Importing text into a JTable is not displaying -

i have created program can input data in jtextfield , on hitting save button use jfilechooser save data in .txt file each jtextfield in new line. created button pops jfilechooser browse file , populate corresponding cells. i new guis, code wrote not working. tried different variations , cannot seem it. can point me in right direction please. the input is john doe st. jude 100 here code import javax.swing.*; import javax.swing.filechooser.filenameextensionfilter; import javax.swing.table.defaulttablemodel; import java.util.scanner import java.util.vector; import java.awt.event.*; import java.awt.*; import java.text.decimalformat; import java.io.*; //import javax.swing.filechooser; import javax.swing.filechooser.filefilter; public class charity { @suppresswarnings("deprecation") public static void main(string[] args) { jframe frame = new jframe("learning team charity program"); container cp = frame.getcontentpane(); frame.setdefaultclo...

vb.net - My data type in MS Access is Date and Time my error is mis match data type -

my data type in database date/time my error data type mis match please tnx... dim try3 string cmd1 = "select count(new) cnew sheet empname = '" & try3 & "' , new not null" cmd2 = "select count(rev1) crev1 sheet empname = '" & try3 & "' , rev1 <> '" & try2 & "' " cmd3 = "select count(rev2) crev2 sheet empname = '" & try3 & "' , rev2 <> '" & try2 & "' " cmd4 = "select count(rev3) crev3 sheet empname = '" & try3 & "' , rev3 <> '" & try2 & "' " cmd5 = "select count(rev4) crev4 sheet empname = '" & try3 & "' , rev4 <> '" & try2 & "' " cmd6 = "select count(rev5) crev5 sheet empname = ...

geometry - Sort list of coordinates -

i have following problem: have list of x, y coordinates of polygon's points. need sort them in such way obtain points in clockwise order. currently have 6 coordinates draw polygon not in order. does know how accomplish that? input coordinates : coordinate: 506.6609866568262, 673.970398950142 coordinate: 505.34898334317376, 682.8179210498581 coordinate: 502.0723751660178, 680.523615304454 coordinate: 534.3026433431738, 682.736131049858 coordinate: 535.6146466568263, 673.8886089501419 coordinate: 538.8912548339822, 676.1829146955461 output coordinates : coordinate: 506.6609866568262, 673.970398950142 coordinate: 502.0723751660178, 680.523615304454 coordinate: 505.34898334317376, 682.8179210498581 coordinate: 534.3026433431738, 682.736131049858 coordinate: 538.8912548339822, 676.1829146955461 coordinate: 535.6146466568263, 673.8886089501419 thanks in advance, use polar coordinates: find internal point polygon reference, (c,d); use ata...

jdbc - error : "java.sql.SQLException: No value specified for parameter 1 " -

public class verestoque extends jframe { connection conexao; preparedstatement pst; resultset rs; public void adicionar() { string sql = "insert produtos (nome, marca, loja, estoque ,valordevenda) values (?,?,?,?,?)"; try { pst = conexao.preparestatement(sql); pst.setstring(1,textnome.gettext()); pst.setstring(2,textmarca.gettext()); pst.setstring(3,textloja.gettext()); pst.setstring(4,textestoque.gettext()); pst.setstring(5,textvalordevenda.gettext()); pst.execute(); joptionpane.showmessagedialog(null,"produto adicionado com sucesso!", "cadastrado com sucesso", joptionpane.information_message); listarprodutos(); } catch(sqlexception error) { joptionpane.showmessagedialog(null,"erro ao adicionar o produto!"); } } public void listarprodutos(){ string sql = "select *from produtos"; try{ pst = conexao.pre...

rx java - RxJava Can subscribe() on an Observable.empty() call onComplete() before the onSubscribe() returns a Subscription causing a NullPointerException? -

i writing logic merges 2 observables can make sure both run , complete whole. this, have used observable.mergedelayerror() seen below. however, when writing unit tests, sometimes, nullpointerexception when trying call mrefreshsubscription.unsubscribe() mrefreshsubscription null. question: possible resulting merged observable, because can double empty, proceed call oncomplete() faster subscribe() returns subscription? observable observa = observable.empty(); observable observb = observable.empty(); mrefreshsubscription = observable.mergedelayerror(observa, observb) .subscribeon(schedulers.io()) .observeon(schedulers.io()) .subscribe(getrefreshobserver()); private observer getrefreshobserver() { if (mrefreshobserver == null) { mrefreshobserver = new observer() { @override public void oncompleted() { mrefreshsubscription.unsubscribe(); } @override ...

javascript - Column Charts with stripes -

Image
can this? i have 2 categories here. (first 5 relevant , last 2 or not, why last 2 in gray color.) in first category, if value below 6, should 1 color, if between 6 , 8, should have other color , greater 8, should have 2 colors, 8 1 color, , >8 color. know whether can provide stripes well? i have used highcharts , amcharts before, built small library around also. did not able achieve functionality. appreciated in either of these libraries while not doable out-of-the-box, can implemented using amcharts little custom code. the complete working code below, general idea this. when chart loads (using addinithandler )we these steps: check chart config custom properties setting thresholds , colors; set graph's negativebase , negativefillcolors properties, chart handle coloring of columns above or below value threshold; iterate through data , see if there columns on threshold (8 in example). if there are, create 2 additional values in our data use later pu...

css - Bootstrap - fill remaining vertical space -

Image
this question has answer here: make div fill height of remaining screen space 30 answers i'm trying design layout using bootstrap. put logo , navbar but have insert remaining div. need extend div (with question mark) remaining space of page (with margin picture). don't know logo or navbar percentage height. edit: post code (source page of yii framework) <a href="index.html"><img width="150" src="images/logo.png"/></a> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <button class="navbar-toggle btn btn-default" data-toggle="collapse" data-target="#yii_booster_collapse_yw0" id="yw1" name="yt0" type="button"> <span class...

Import github project into preexisting git project -

Image
i'm working on flask app in local git repo. i've come across python script import project root github. i'm not sure how "pull in/import" script local repo, without affecting pre-existing code. can advise me here. simple git clone https://github.com/xxx/yyy.git ( don't want try fear of messing local repo ) you can add additional remote branch repo: git remote add <yyy> https://github.com/xxx/yyy.git once that's done, can pull directly new remote with: git pull <yyy> master this automatically attempt merge code remote repo local repo.

django - mportError: PILKit was unable to import the Python Imaging Library. Please confirm it`s installed and available on your current Python path -

everyone. home problem. have django project. project use django-imagekit. if run app command: python3 manage.py runserver - works! but! if use mod_wsgi it: root@twingo:/home/evgen/twingo/build/env/lib/python3.4/site-packages# tail /var/log/apache2/error.log [fri jun 19 21:13:25.268235 2015] [wsgi:error] [pid 20907] [remote 91.238.231.242:65535] .registry import register [fri jun 19 21:13:25.268259 2015] [wsgi:error] [pid 20907] [remote 91.238.231.242:65535] file "/home/evgen/twingo/build/env/lib/python3.4/site-packages/imagekit/registry.py", line 3, in <module> [fri jun 19 21:13:25.268388 2015] [wsgi:error] [pid 20907] [remote 91.238.231.242:65535] .utils import autodiscover, call_strategy_method [fri jun 19 21:13:25.268414 2015] [wsgi:error] [pid 20907] [remote 91.238.231.242:65535] file "/home/evgen/twingo/build/env/lib/python3.4/site-packages/imagekit/utils.py", line 14, in <module> [fri jun 19 21:13:25.268550 2015] [wsgi:error] [pi...

android - Diagnose alarm failure on HTC One / lollipop -

i developing alarm app works on every device i've tried except htc 1 android lollipop. app ui works expected, when alarm due ring, nothing happens, no sound , no "stop" button. unfortunately htc 1 not mine, have infrequent , brief access it, can't connect pc view logs. have genymotion, has emulation of htc 1 android 4.4. alarm worked on that. i've tried both xperia z , galaxy siii both lollipop, , worked fine on those. worked of variety of other devices earlier versions of android. so hoping possible explanations, or possible mechanisms diagnosing problem. or perhaps alternative device available in genymotion has key features in common htc. edit: fyi phone not rebooted between setting of alarm , time alarm ring. indeed test setting alarm go off in 1 minute. edit: app old unfinished project resurrecting. have been using beta version own personal alarm (not wake-up, meetings on specific dates, , count-down timer too). has worked reliably me on year wi...

JScript using Excel TextToColumns -

i've been trying make little snippet work i've been failing miserably. script seems work alright, thing is: need third column (the 1 numbers) converted text. looking @ page in excel seems "array(3, 2)" part make possible trying lot of combinations of number , arguments on function couldn't make work. any problem? var app = new activexobject("excel.application"); app.visible = true; var xls = app.workbooks.add(); app.cells(1, 1).value = "olympia, wa, 123"; app.cells(2, 1).value = "salem, or, 3434"; app.cells(3, 1).value = "boise, id, 342"; app.cells(4, 1).value = "sacramento, ca, 3"; app.range("a1").entirecolumn.texttocolumns(app.range("b1"),1,1,false,false,false,true,false,false,array(3, 2)); there 2 issues here. the first issue format using fieldinfo parameter incorrect. parameter should array-of-arrays. jscript format such array like: // 2 = xltex...

php - json_decode is returning a null value instead of an array -

i trying search keyword email in decoded data. not able array type json_decode. here code $curl = curl_init(); curl_setopt_array($curl, array( curlopt_returntransfer => true, curlopt_url => $url, curlopt_useragent => 'mozilla/5.0 (macintosh; intel mac os x 10_9_2) applewebkit/537.36 (khtml, gecko) chrome/43.0.2357.81 safari/537.36' )); $resp = json_decode(curl_exec($curl), true); if(is_array($resp) && array_key_exists("email", $resp)) { echo $data_arr[0] . "email: "; $content = $resp["email"]; fwrite($fp,$content); } the exact error is: array_key_exists() expects parameter 2 array, null given in index.php on line 34 edit: figured out error somewhat. curl execution fails due error ( url malformed). still not able figure out how url malformed in case. url extracted such. $data = fgets($fp); $data_arr = split(",", $data); $token_arr = isset($data_arr[1]) ? split('"', $da...

android - How to implement an action bar like google maps -

Image
i've been looking around can't seem find out how implement action bar looks 1 in google maps , google now. can give me link documentation/tutorial or @ least name of type of action bar? edit:i've attached picture of want action bar like okay i've solved myself. hid default actionbar , used xml create custom actionbar(using linearlayout, edittext , buttons).

google app engine - GAE Managed VMs: Possible to use C-based Python libraries with standard runtime? -

i'm building background module app in python 2.7, needs use c-based external libraries such opencv. while gae "directly" supports pure python libraries, understand using managed vm removes constraint. i'm not quite clear on, after reading the documentation , whether need use custom runtime, or whether standard python runtime (for there's ready-made docker file , built-in api support datastore, task queue, etc.) sufficient. thanks in advance insight! the standard runtime fine, need add dependencies dockerfile gets created. the tutorial in docs (specifically step 6) shows example of building python app uses c-extension.

Alternate way to read a file as json using python -

i have file contains information similar example shown below. know if there way read file using python , use json. aware of how open , process text there way? example: key={{name='foo', etc..},{},{},{}} if want content treated json need have valid json syntax: {"key":[{"name": "foo"},{},{},{}]} then can use json library convert dictionary: >>> import json >>> json.loads('{"key":[{"name": "foo"},{},{},{}]}') {u'key': [{u'name': u'foo'}, {}, {}, {}]} additionally, if file content cannot changed correct json syntax, need develop parser specific case.

Can anyone guide me on coding an email that Siri and Google Now will pick up Schema.org markup from? -

microsoft have provided interesting documentation on passing data cortana, in example flight schedule using schema.org : https://msdn.microsoft.com/en-us/library/dn632191.aspx does know if same method true ios , android platforms? if not can point me in right direction? i reviewed documentation , you've posted. yes, can integrate google in similar way. can find supported google schemas in link below. you'll find microdata/json examples: https://developers.google.com/schemas/now/cards you can start testing gmail schemas below apps script quickstart tutorial personal gmail account. when from: , to: fields match each other, actions displayed. however, if try send gmail account, actions not appear. https://developers.google.com/schemas/tutorials/apps-script-tutorial note, if copy , paste examples in apps script, please use current date in order trigger card. example today's date: "departuretime": "2015-06-22t20:15:00-08:00" "ar...

Ruby C gem memory pollution between runs -

i wrote gem in c appears keeping polluted memory between runs. i noticed in past, have discovered how reproduce consistently calling gem in rspec spring. when running single rspec example after restarting spring, example passes. subsequent runs without restarting spring result in garbage data. further subsequent runs result in same garbage data. example: $ spring stop spring stopped. $ spring rspec ..._spec.rb:122 ... 1 example, 0 failures $ spring rspec ..._spec.rb:122 ... failures: ... expected collection contained: [7] actual collection contained: [1333155159] $ spring rspec ..._spec.rb:122 ... failures: ... expected collection contained: [7] actual collection contained: [1333155159] $ spring stop spring stopped. $ spring rspec ..._spec.rb:122 ... 1 example, 0 failures $ spring rspec ..._spec.rb:122 ... failures: ... expected collection contained: [7] actual collection contained: [117372691] $ spring rspec ..._spec....

arrays - php how to send this data threw curl -

i have send data threw curl: -d '{"payer": { "default_payment_instrument":"bank_account", "allowed_payment_instruments":["bank_account"], "default_swift":"fiobczpp", "contact":{"first_name":"first", "last_name":"last", "email":"first.last@example.com" } }, }' how supposed save data fields variable? $fields = { "payer": { "default_payment_instrument":"bank_account", "allowed_payment_instruments":["bank_account"], "default_swift":"fiobczpp", "contact":{"first_name":"first", "last_name":"last", "email":"first.last@example.com" } }, ...

c# - Migrating to Async: Repository -

i have large codebase using repositories implement irespository , i'm implementing async versions of methods: t find(id); task<t> findasync(id); ...etc... there several kinds of repository. simplest based on immutable collection universe of entities small enough merit loading them @ once db. load happens first time calls of irepository methods. find(4), example, trigger load if hasn't happened already. i've implemented lazy < t >. handy , has been working years. i can't go cold-turkey on async have add async alongside sync versions. problem is, don't know called first - sync or async method on repository. i don't know how declare lazy - if i've done it, lazy<mycollection<t>> then loading won't async when findasync() called first. on other hand, if go lazy<task<mycollection<t>>> this great findasync() how synchronous method trigger initial load w/o running afoul of mr. cleary's warnings ...

java - Variable callables with different return types -

the problem have in hand methods one(), two(), three(), four() have different return types say, a, b, c, d , need spawn variable numbers of threads (one each method depending on use case. means want call subset of methods @ time.) now, using cachedthreadpool submit these callables. code below: public class dispatcher { public void dispatch(list<methodnames> methodnames) { //now going iterate through list of methodnames //and submit each method `executorservice` for(methodnames m : methodnames) { switch(m) { case one: //submit one() //wait , future future<a> future = cachepool.submit(new callable<a>() { @override public call() { return one(); }); response = future.get(); break; .... } } } } public enum methodnames { one, two, three, 4 } //example methods: publi...

javascript - HTML PHP google single sign on signout will throw "Cannot read property 'getAuthInstance' of undefined" -

i have created google single sign on following steps mentioned in https://developers.google.com/identity/sign-in/web/sign-in the sign in works charm when try integrate sign out per article in link i following javascript error in console uncaught typeerror: cannot read property 'getauthinstance' of undefined and signout function looks like <script> function signout() { var auth2 = gapi.auth2.getauthinstance(); auth2.signout().then(function () { console.log('user signed out.'); }); } </script> and sign in looks function onsignin(googleuser) { var profile = googleuser.getbasicprofile(); console.log('id: ' + profile.getid()); console.log('name: ' + profile.getname()); console.log('image url: ' + profile.getimageurl()); console.log('email: ' + profile.getemail()); } are signin , signout used on same page? div g-signin2 loads , inits gap...

python - OperationalError: No such table - but there is such a table -

while developing website locally, didn't have problems, when put on server, got following error upon trying access had database: operational error @ appname_modelname no such table: appname_modelname this happens apps , models, including admin model. using sqlite3 database. thing is, when ./manage.py shell following code runs fine: from appname.models import * print model.objects.all() it list 2 dummy objects have in table. in other words, have migrated everything, , data can read table in context. furthermore, able serve webpages , static files without issues. tried changing permissions on db.sqlite3 file 755 , no avail. using django 1.8.1, running on apache server inside virtual environment.

javascript - Send event to client, from server, and then disconnect the socket (from server) -

i want send event client, in socket.io, , after disconnect client. problem calling socket.emit() not emit anything... know, or stepped kind of problem? my code this: - on server: usercredentialscheck: function (socket, next, callback) { applogsys.info('check cookie!'); ..... var handshake = socket.request; ..... parsecookie(handshake, null, function (err, data) { sessionsrv.get(handshake, function (err, session) { if (err) { applogsys.error(err.message); next(new error(err.message)); } else { ...... socket.emit('na', 'error checking session! bye!'); socket.disconnect(); } }) }) }; on client: appsocket.on('na', function(d){ console.log('error: '+d); console.log('now, redirect!'); //redirect! var delay = 1000; //your ...

php - Append inline scripts inside Twig layout block -

i have layout looks this: <html> <body> <!-- omitted --> <div class="content"> {% block body %}{% endblock %} </div> <script src="js/vendor.js"></script> {% block javascripts %} <!-- want able inject inline scripts sub-templates here --> {% endblock %} </body> </html> then have register_content.html.twig template overridden fosuserbundle , in trying inject script "javascripts" block so: {% block javascripts %} <script> // inline js </script> {% endblock %} the problem having inline script seems injected @ end of "body" block , not in "scripts" block. this output getting: <!-- should below js/vendor.js scripts --> <script> // inline js </script> </div> </div> <script src="js/vendor.js"></script> what doing wrong? problem lie fosu...

python - argparse -- requiring either 2 values or none for an optional argument -

i'm trying make optional argument script can either take no values or 2 values, nothing else. can accomplish using argparse? # desired output: # ./script.py -a --> works # ./script.py -a val1 --> error # ./script.py -a val1 val2 --> works version 1 -- accepts 0 or 1 values: parser = argparse.argumentparser() parser.add_argument("-a", "--action", nargs="?", const=true, action="store", help="do action") args = parser.parse_args() # output: # ./script.py -a --> works # ./script.py -a val1 --> works # ./script.py -a val1 val2 --> error version 2 - accepts 2 values: parser = argparse.argumentparser() parser.add_argument("-a", "--action", nargs=2, action="store", help="do action") args = parser.parse_args() # output: # ./script.py -a --> error # ./script.py -a val1 --> error # ./script.py -a val1 val2 --> works how combine these 2 different versions sc...

java - Make all Spring beans of a certain type request scoped -

i have class , want objects of type request scoped. in spring xml, i'm creating list of such objects. it's tedious , error-prone have set scope , proxy mode each 1 of these beans, there way make beans of type request scoped automatically? i tried annotating class @scope(value = webapplicationcontext.scope_request, proxymode = scopedproxymode.target_class) didn't seem work. maybe annotation ignored when bean created via xml? here's have far in xml: <util:list> <bean class="com.test.myclass" scope="request"> <aop:scoped-proxy/> <constructor-arg> <bean value="hello"/> </constructor-arg> </bean> <bean class="com.test.myclass" scope="request"> <aop:scoped-proxy/> <constructor-arg> <bean value="friend"/> </constructor-arg> </bean> </util:li...

c# - How to make Exists with Dynamic Linq -

how make exists dynamic linq? i'm trying create sql clause dynamic linq. researched lot of , not found satisfactory answer. i try convert sql query follows: sql select * documento exists( select 1 titulo documento.coddocumento = titulo.coddocumento , documento.codempresa = titulo.codempresadocumento , titulo.codfluxoconta = 'somevalue' , titulo.codempresafluxoconta = 'stringnumerical') in common linq did follows: var subquery2 = t in db.titulos t.codfluxoconta == "somevalue" && t.codempresafluxoconta == "stringnumerical" select new { coddoc = (int?)t.coddocumento, codemp = (string)t.codempresadocumento }; var query2 = d in db.documentos subquery2.contains(new { coddoc = (int?)d.coddocumento, codemp = (string)d.codempresa }) select new{ d.coddocumento, d.codempresa }; or var query4 = db.documentos.where(d => (db.titulos.where(t => t.c...

remote access - Using Powershell to verify registry entries remotely -

i'm trying write script checks print server users on our network connecting to. that, i'm attempting check registry values listed under printer\connections. on local machine following 2 methods both work: 1) get-childitem hkcu:\printers\connections output: hive: hkey_current_user\printers\connections name property ----- -------- ,,printserver,printername guidprinter : {guid} server : \\printserver.domain provider : win32spl.dll localconnection : 1 2) >> get-childitem hkcu:\printers\connections | foreach-object {get-itemproperty $_.pspath} and output of command is: guidprinter : {guid} server : \\printserver.domain provider : win32spl.dll localconnection : 1 pspath : microsoft.powershell.core\registry::hkey_current_u...