Posts

Showing posts from June, 2010

java - Managing thread from a mouseclick -

may basic question. i'm little confused it. in design i've thread started mouse click. method looks this: runnable r = new runnable(){ public void run(){ a.firstmethod(); a.secondmethod(); b.firstmethod(); b.secondmethod(); b.thirdmethod(); } }; new thread(r).start(); here b.firstmethod(), b.secondmethod(), b.thirdmethod(); accessing same variables , database operations during execution (i.e. locking, reading, writing etc.). but, if mouse clicked during execution or before finishing tasks error message database. how can handle such type of situations. here cannot force user wait simple progressbar. to handle such situation, can disable button once thread has started execution, , enable again once thread going finish execution. code following: runnable r = new runnable() { public void run() { button.setenabled(false); a.firstmethod(); a.secondmethod(); b.firstmethod(); b.secondmethod(); b.thirdmethod(); button.setenabled(tr...

angular ui - AngularUI for AngularJS counting the "uniqe" filter results -

i'm using angularui 'unique' filter show list of unique items. question how can count of number of items in each unique result? e.g. set is: colors = [ {name:'black', shade:'dark'}, {name:'white', shade:'light'}, {name:'red', shade:'dark'}, {name:'red', shade:'dark'}, {name:'yellow', shade:'light'} ] and in view: <li ng-repeat="color in colors | unique:'name'">{{color.name}}</li> gives: <li>black</li> <li>white</li> <li>red</li> <li>yellow</li> i wish show in view black count 1, red 2, etc.. thanks i dont think filter can change base structure way. you'l have preproccess collection in controller with lodash example collection = [{name:'a'},{name:'b'},{name:'a'},{name:'c'}]; _.mapvalues(_.groupby(collection, 'name'), function(r) { return r.l...

.net - How to suppress default browser from opening while VB.NET WebBrowser encounter SSL error (proxies) ? -

i have small issue. have application using latest installed ie engine. might encounter issue , when it's happen .net opens default browser error (that ssl has enabled connect server, i'm using proxies). i want suppress external browsers showing because of application. i know can start browser using process.start , stop. how recognise new process started application (is there parent of process or tree ?) ok, here's how can retreive ppid (parent process id) of given process via wmi wrapper system.management first you'll have add reference system.management obviously. then you'll have query process in question: dim pid int32 = process.getcurrentprocess.id dim query selectquery = new selectquery(string.format("select * win32_process processid = {0}", pid)) next need feed query managementobjectsearcher , put results managementobjectcollection dim mobjsearcher managementobjectsearcher = new managementobjectsearcher(query) dim mob...

Does python have an "error" module? -

does python have error module? when wrote 'import error' in python 2.7.6, returns "no module named error.' 'import error' part of program in textbook?should doult in textbook? it's custom module. python standard library not have error module. maybe missed in textbook error module created.

spring - ResultHandler.print() undefined -

how come resulthandler.print() undefined? spring version 3.2.5.release . i using as this.mockmvc.perform()...anddo(print()); print() defined on mockmvcresulthandlers not on resulthandler from documentation: * static imports: mockmvcrequestbuilders.*, mockmvcresulthandlers.* * * mockmvc.perform(get("/form")).anddo(print());

recurring ambiguous column name _id sqlite error in android -

i have tried editing code according suggestion found on site,but nothing seems work..i still keep getting following logcat error: 03-24 11:44:27.037: e/androidruntime(1809): caused by: android.database.sqlite.sqliteexception: ambiguous column name: _id (code 1): , while compiling: create view customerview select _id _id, fname, lname, customermeterid, customermeternumber, customerplotnumber, _id customers customers inner join meters meters on customermeterid =_id the class referenced above in logcat: public class viewcustomers { public static final string table_customer_view = "customerview"; public static final string customer_view_id = customertabledetails.key_customer_id; public static final string customer_view_firstname = customertabledetails.key_first_name; public static final string customer_view_lastname = customertabledetails.key_last_name; public static final string customer_view_meter = customertabledetails.key_meter_number; public static final ...

python - Calling a method with an event handler -

why, if put "normal" call method button1click() in bind call, program not start? removing parenthesis problem solved. i'm using program reference: thinking in tkinter also, why should add event argument button1click() method? from tkinter import * class myapp: def __init__(self, parent): self.myparent = parent self.mycontainer1 = frame(parent) self.mycontainer1.pack() self.button1 = button(self.mycontainer1) self.button1.configure(text="ok", background= "green") self.button1.pack(side=left) self.button1.bind("<button-1>", self.button1click) # <--- no () ! def button1click(self, event): self.button2 = button(self.mycontainer1, text="lol") self.button2.bind("<button-1>", self.button1click) self.button2.pack() root = tk() myapp = myapp(root) root.mainloop() bind() expects callable , expects argument...

Python readlines string issue -

import os fname = "input1.txt" if os.path.isfile(fname): f = open("input1.txt", "r") row in f.readlines(): if "logging failed" in row: print "the file 'logging failed' in it" else: print "the file doesn\'t 'logging failed' in it" my input1.txt says logging failedtest how can make notice "test" should printout logging failed if text doesnt have additional characters? edit: sorry bad english, meant is: if input1.txt has "logging failed", should print out 'file it'. if has other characters (for example 'logging faaaailed' or 'logging failed1', should print out 'it doesnt logging failed'. reads there logging failed , ignores other characters in input1.txt maybe i'm missing something, why can't explicitly compare row string "logging failed" ? e...

QT - QTimer with multiple QGLWidgets -

i have application 2 qglwidgets updated same timer, running @ 60hz. strangely, maximum fps reach 30hz. if add third qglwidget (note third 1 updated additional timer) achieve 20 fps maximum on each widget. cpu load of main thread far 100%. seems me there dependency on number of qglwidgets , refresh rate of monitor number of used widgets multiplied max. fps equals refresh rate (60hz)... anyone knows going on?

c - How does conversion specifier work? -

can check understanding of scanf? int a; scanf("%d",&a); if input 13, conversion specifier convert 13 binary , stored in a ? if input 13.3, convert decimal fraction 13.3 binary , store in a? i don't know knowledge in c, how data stores in c important , interesting topic. whenever data stores in variable in binary format, not possible see binary data in simple c language can see binary in embedded c. pass data in port or program providing data internally , sending output port connected led. suppose if passed -1 in port , port sending output led connected can see leds connected glow. in c can observe char c=-1; printf("%u",c); output=255 %u used unsigned integer not error can check it. int , char store in same fashion means if try store char think it's ascii value 65 stored in binary way. char ch='a'; printf("%d",ch); output 65 same int i=65; printf("%c",i); output a; float stored different ...

ios - Can I set maximum alpha for CATransition? -

is possible adjust maximum alpha (opacity) in catransition when views fade in , out? what want looks modal segue. compared default modal segue, transition given catransition «dramatic». say have 2 views. a: view want transition from. b: view want transition to. i want b come moving in bottom on a. use kcatransitionmovein type, subtype kcatransitionfromtop (which weird because b moving bottom, not top). in default modal segue, works fine, , greyed out little. catransition , totally black @ towards end of transition when b has moved 70% on a. code: uistoryboard *loginboard = [uistoryboard storyboardwithname:@"login" bundle:nil]; uiviewcontroller *vc = [loginboard instantiateinitialviewcontroller]; uiwindow *keywindow = [[[uiapplication sharedapplication] delegate] window]; [keywindow insertsubview:vc.view belowsubview:keywindow.rootviewcontroller.view]; catransition *transition = [catransition animation]; transition.duration = 0.5; transition.type = kcatr...

android - Gcm unregistration -

i working on gcm in android. done registration of device gcm using following code registers device asynchronously. private void registerinbackground() { new asynctask<void, void, string>() { @override protected string doinbackground(void... params) { string msg = ""; try { if (gcm == null) { gcm = googlecloudmessaging.getinstance(context); } regid = gcm.register(sender_id); msg = "device registered, registration id=" + regid; storeregistrationid(context, regid); msg="registration success. regid: "+regid; } catch (ioexception ex) { msg = "error :" + ex.getmessage(); // if there error, don't keep trying register. // require user click button again, or ...

ruby - What algorithm can be used for alerting unusual trends? -

Image
i looking algorithm detect when stream of data showing usual trend. for example: logging bookings, , on last couple of weeks have been stable usual ups , downs. payment provider stops working, , within hours bookings decline drastically. catch minimise false alerts, , solution should adapt long term decline. what statistical approach problem? what name of such algorithm? i think might interested in unsupervised anomaly detection algorithms. a quick google search found tutorial . if have time, register machine learning course on coursera.

transactions - Bug in PostgreSQL locking mechanism or misunderstanding of the mechanism -

we encountered issue postgresql 9.0.12 locking mechanism. this our minimal code reproduce issue: scenario transaction 1 transaction 2 begin begin ...... select trees update; update apples; --passes update apples; -- stuck! reproduce code: if want try in postgresql - here code can copy/paste. i have following db schema: create table trees ( id integer primary key ); create table apples ( id integer primary key, tree_id integer references trees(id) ); insert trees values(1); insert apples values(1,1); open 2 psql shells: on shell 1: begin; select id trees id = 1 update; on shell 2: begin; update apples set id = id id = 1; update apples set id = id id = 1; the second update of apples stuck , seems porcess of shell 2 wating on transaction of shell 1 finish. relname |transactionid|procpid|mode |substr | age ...

javascript - Bouncing image balls with KineticJS -

i'm starting out kineticjs library , been playing creating shapes etc.. however, i'm struggling create custom circle own image in it. have tried using fillpattern doesn't scale/centre correctly @ all. meant use own circle image or rectangle image , let kineticjs take care of things? just give bit of background: want 3 balls bouncing in , settling in place. any advice welcome. sorted it... needed offset values var ball = new image(); ball.src = 'ball2.jpg'; ball.height = 230; ball.width = 230; var stage = new kinetic.stage({ container: 'container', width: 1000, height: 1000 }); var circle = new kinetic.circle({ x: 300, y: 300, radius: 115, fillpatternimage: ball, fillpatternoffset :{ x: -115, ...

ios7 - SQLCipher, encrypted-core-data and iOS - are two .sqlite-files normal? -

i'm using sqlcipher encrypt database there's sensitive information. seems work, i'm irritated because i've got 2 .sqlite-files right now: ~/library/application support/mydata.sqlite ~/library/application support/myapp/mydata.sqlite ~/library/application support/myapp/mydata.sqlite-shm ~/library/application support/myapp/mydata.sqlite-wal the first 1 encrypted, second isn't - doesn't contain information. seems work there's no way information, wanted ensure correct. you'll need turn off write ahead logging feature of sqlite. in core data, need set pragma option on store. can see how set flag related stackoverflow question

Facebook acc which using yahoo can't login to android app -

in application, can't login yahoo facebook account(such xxxxx@yahoo.com).another mails(such xxxx@gmail.com) avaliable. when login button clicked,it goes facebook login page .after fill mail , password, can't go page... don't know, going on? here code facts , put page.... private class idrequestlistener implements requestlistener { @override public void oncomplete(string response, object state) { log.d("profile", response); string json = response; final string email; try { jsonobject profile = new jsonobject(json); final string name = profile.getstring("name"); if( profile.getstring("email").equals("")|| profile.getstring("email").equals(null)){ email = ""; }else{ email = profile.getstring("email"); } f...

Multiple ADODB.Connection in vbScript -

i have array of database servers, , want execute same query of them in loop. after first iteration following error : - error number: 3704 - description: operation not allowed when object closed the code i've implemented is: dim username dim password dim serverlist(4) serverlist(0) = "serveraddress0" serverlist(1) = "serveraddress1" serverlist(2) = "serveraddress2" serverlist(3) = "serveraddress3" 'username , password set counter = 0 ubound(serverlist)-1 set connobj = createobject("adodb.connection") set rsobj = createobject("adodb.recordset") connstring = .......... connobj.open connstring, username, password 'error comes here, in second iteration. sqlscript = "select * ......" rsobj.open sqlscript, connobj while not rsobj.eof 'record set fetched..... rsobj.moven...

android - Using Intent filter for inter process communication -

i want enable application called different applications using urls or sort of rest enablement, such different actions in application can performed different clients. for e.g. there action "a" helps user navigate particular screen in application. i planning use using urls can custom schemes or http. have read debates between custom schemes , http schemes :). so e.g if client calls mysite.com://a?queryparam=1&queryparam=2 depending on action "a" , query params navigating particular screen. i using intent filters here inter process communication. write url handler depending on type of action. action type can derived last path segment of query. .fetching of query parameters can done through uri.getqueryparameters . using intent filter , uri apis right kind of scenarios ?. i had read aidl can used inter process communication, tightly bound , client has know lot of information provider or application. somehow want rest type enablement of application. ...

No cached version of com.android.tools.build:gradle:0.9.1 available for offline mode -

i got error message while building new hello world project in android studio. failure: build failed exception. what went wrong: problem occurred configuring root project myapplication2 . could not resolve dependencies configuration ':classpath'. not resolve com.android.tools.build:gradle:0.9.1. required by: :myapplication2:unspecified no cached version of com.android.tools.build:gradle:0.9.1 available offline mode. build failed android studio version : 0.5.2 gradle version : 0.9.1 i'm using proxy connection internet. please can give solution problem. have searched internet above problem, couldn't proper solution issue. had same error after updating android studio today. me, wasn't matter of proxy settings: uncheck "offline work" in android studio 0.6.0: file->settings->gradle->global gradle settings or in osx: preferences->gradle->global gradle setting or in more recent versions: file->setting...

c# - How to send email from windows phone 7 application -

in windows phone 7 application want send e-mail message body should contain data previous page. private void email_send(object sender, routedeventargs e) { emailcomposetask emailcomposetask = new emailcomposetask(); emailcomposetask.subject = "message subject"; emailcomposetask.body = "message body"; emailcomposetask.to = "recipient@example.com"; emailcomposetask.cc = "cc@example.com"; emailcomposetask.bcc = "bcc@example.com"; emailcomposetask.show(); } now in body part want data previous page. how this? if (this.navigationcontext.querystring.containskey("school_name")) { //if available, parameter value school = navigationcontext.querystring["school_name"]; school.text = date; } please tell me how pass value try this private void email_send(object sender, routedeventargs e) { string previousvalue = string.empty; if (navigationcontext.querystring.containskey("school_name")) pre...

ios - Cannot get correct UIColor in rectangle -

all, i have piece of code : - (void)drawrect:(cgrect)rect { cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetfillcolorwithcolor(context, [uicolor redcolor].cgcolor); cgcontextfillrect(context, cgrectmake(0, 440, 320, 30)); and call : _rectangeview = [[popuprectangle alloc] initwithframe:cgrectmake(0, 538, 320, 30)]; but black! anyone advice why ? change colouring rect this... cgcontextfillrect(context, cgrectmake(0, 0, 320, 30)); use 0, 0 origins not 0, 440. that should work. inside drawrect dealing in vector space of view not superview. 0, 0 top left of rectangleview .

android - IBM Worklight 6.1 [Application Error] There was a network error (file:///android_asset/www/index.html) -

on android: app gives [application error] there network error (file:///android_asset/www/index.html). searched in others answers not worked. below appname.js in path: android/native/src/common/appname/appname.java public class appname extends wldroidgap { @override public void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); } /** * onwlinitcompleted called when worklight runtime framework initialization complete */ @override public void onwlinitcompleted(bundle savedinstancestate){ super.loadurl(getwebmainfilepath()); // add custom initialization code after line } } how can achieve this? what both index.html , appname.java/js? in worklight 6.1.0.x, new application given index.html , main.js/main.css/appname.java did rename of project files? value mainfile in application-descriptor.xml? make sure "index.html".

html - Responsive height to a div? -

http://shrineweb.in/other-files/clients/markalves21/responsive/html/index.html in link above, blue navigation responsive in width, not in height. don't know doing wrong, have set min-height. here markup: <div id="menu"> <!--the navigation/menu--> <nav> <ul><!--un-ordered list list items , child list items if menuis have drop down--> <li><a href="index.html">home</a></li> <li><a href="aboutus.html">about us</a> <ul> <li><a href="location.html">location</a></li><!--child menu--> </ul> </li> <li><a href="contactus.html">contact us</a></li> <li>news <ul> <li><a href="clubnews.html">club news</a></li> </ul> </li> <li>the pitch <ul> ...

php - Why is sql only showing the most recent record? -

i'm total newbie sql. i'm trying pull through records correspond shop code, reason sql showing me recent. there code i'm using is $currentshopid = 467; $sql = 'select events.shopid shopid, events.eventid eventid db1.events events events.shopid in ('.$currentshopid.')'; there 10 records shopid 467 showing recent one? update: here code function function loadsomeotherstuff($sids) { $currentshopid = implode(',', $sids); $sql = 'select events.shopid shopid, events.eventid eventid db1.events events events.centreid in (' . $currentshopid . ')'; $this->_db->setquery($sql); $event = $this->_db->loadassoclist(); if (is_null($event)) { throw new exception($this->_db->geterrormsg()); } foreach($event $row) { $this->_databysid[$row['shopid']]['events']['shop code'] = $row['shopid']; $th...

duplicate javascript actions on jQuery ajax get script -

hello problem after ajax response want reload script. in response there te same buttons in original content. managed load script again 1 more ajax request script, functions script duplicated. ex. $('button#go').bind('click',function(){ $.ajax({ url: "go.php", cache: false, context: document.body, type: "post", data: { data:'test'}, beforesend: function() { $('button').attr('disabled',true);$('#loading').show(0); } }) .done(function( html ) { $('button').attr('disabled',false); $('#loading').hide(0); $( "#ajaxreply" ).html( html ); $.ajax({ type: "get", url: "script.js", datatype: "script" }); }); }); how can prevent duplicating functions, or refresh script after ajax response ?

javascript - How to use callback in sandbox in firefox add-on on android? -

i want execute sided javascript code in firefox add-on program on android. how call method of main page's script sided js code? main code: function execjavascript(awindow, itemid, password) { var xmlhttppost = new awindow.xmlhttprequest(); if (xmlhttppost.overridemimetype) xmlhttppost.overridemimetype('text/html'); xmlhttppost.open( 'post', 'http://localhost:'+port+'/home.html?msgfill='+itemid+'msgpasswd='+password, false); xmlhttppost.setrequestheader('content-type', 'application/x-www-form-urlencoded'); xmlhttppost.send('msg=hello'); // execute received javascript var javascript = xmlhttppost.responsetext; try { // try execute received javascript evalinsandbox(awindow, javascript); } catch(e) { showtoast(awindow, e.message); } } function callbackfromloadedjs(string result) { console.log("callback result = " + result); }...

c# - WCF Data services SaveChanges not firing WritingEntity event -

i using wcf data services (5.6 now) , since enums not supported (and other reasons), have additional properties added client side classes intend remove during savechanges using writingentity event following example in http://blogs.msdn.com/b/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx my constructor attaches event find event fires , other times (more often) doesn't. public mydatacontext(system.uri serviceroot, bool ignoreproperties) : this(serviceroot) { if (ignoreproperties) this.writingentity += edicontext_writingentity; this.sendingrequest2+=onsendingrequest; } to save changes db.attachto("maps", map, "*"); db.updateobject(map); processmapcoordinates(db, map); processmodifiers(map, db); db.savechanges(); the sendingrequest2 event fire, use attach header information request in order support multiple data private void onsendingrequest(object sender, sendin...

Engineering Format of y-axis values in AChartEngine for Android -

i working on project need plotting data. use android studio 5.2.0 , achartengine 1.2.0 on windows 7 64 bits pc. interested in engineering formatting of y-labels, e.g. 2.3e6.. have studied without success. wish 1, 3, 0, 1 , 1 min no. of integer digits, max no. of integer digits, min no. of fraction digits, max no. of fraction digits , no. of digits in exponent part, respectively. in addition exponent must muliple of 3. here linegraph class: public class linegraph { public intent getintent(context context) { int size = ( int ) math.pow(2, 10); double start = 0; double end = 2 * math.pi; double inc = (end - start) / (size - 1); double[] x = new double[size]; double[] y = new double[size]; xymultipleseriesdataset dataset = new xymultipleseriesdataset(); timeseries series = new timeseries("sin * cos"); ( int = 0; < size; i++ ) { x[i] = start + * inc; y[i] = 1...

internet explorer - Sitecatalyst's custom-link request not sends in IE -

i have problems tracking sitecatalyst custom-link analytics in ie. if open page in ie , click on link ( href=# ) analytics - s.tl(...) method called , analytics sent. after clicking on link second time (without reloading page) - s.tl(...) called analytics not sent. in firefox , chrome ok - analytics sent every time link clicked. has faced problem? i'm using h.24.2 version of sitecatalyst , ie9. link coded next way html: <a class="web-analytics-custom-link" href="/content/en/customer-service/contact-us.html" data-custom-link="{'linkname':'footer_contact us', 'vars' : 'prop1,pagename'}"> contact </a> js: function recordcustomlink(params) { if (s != null) { if (params.customvars) { jquery.each(json.parse(json.stringify(params.customvars)), function(i, val) { s[i] = val; }); } var eventscopy = s.events; ...

Fixing iOS Safari Javascript 'deviceorientation' event irregularity? -

i've been using 'deviceorientation' my project , when testing on iphone/ipad, behaves in landscape mode, has irregularity in portrait mode. here steps repeat: open jsfiddle on ipad/iphone in portrait mode - move device though looking through camera , panning looking @ feet, looking @ horizon, looking @ sky event.beta go 0 -> +/-90 -> 0 notice how event.gamma jumps when device reaches horizon, around when event.beta = 90 q1: how can adjust behaviour? q2: there way definitive value (eg. 0-180) movement in direction, ground sky? html <b>e.alpha :</b> <span id='alpha'></span><br/> <b>e.beta :</b> <span id='beta'></span><br/> <b>e.gamma :</b> <span id='gamma'></span><br/> js function deviceorientationhandler(e){ var = document.getelementbyid('alpha'); var b = document.getelementbyid('beta'); var g = document....

c# - Keep URL encoded while using URI class for Linkedin API -

i trying make request linkedin using public url. problem url encoding has been documented many times before on site, in this post . windows phone developers cannot use workarounds documented far, because: config files - not relevant phone projects. reflection - permission problems. has windows phone developer found way across barrier?

jquery - combine javascript progress bar with another javascript -

i have javascript progressbar: <script> $(function() { $( "#progressbar" ).progressbar({ value: 37 }); }); </script> i have javascript automaticaly gets value file: <script> var time = 0; setinterval(function() { $.ajax({ type: "post", data: {time : time}, url: "fileupdate.php", success: function (data) { var result = $.parsejson(data) if (result.content) { $('#file_content') .html(result.content); } time = result.time; } }); }, 1000); </script> how can add js progress bar script value progress bar can automaticaly update? thanks in advance. you calling request every second.. want? stack request if not finished on , over.. what should probally do, per a.wolff's suggestion call function every...

Remove box-shadow of input from Javascript -

i want remove box-shadow of input elements javascript. have tried not work. document.getelementsbytagname('input').style.boxshadow = ''; array.prototype.foreach.call(document.getelementsbytagname('input'), function(el) { el.style.boxshadow = ''; }); getelementsbytagname returns nodelist , sort of array ; has length property, , enumerable, has no other goodies. and here's alternative should prefer: var elements = document.getelementsbytagname('input'); var len = elements.length; for(var = 0; < len; ++i) { elements[i].style.boxshadow = ''; } but if you, i'd invest time learning jquery, because of this: $("input").css("boxshadow", "none");

c++ - How to create an out of source tree project with Visual Studio? -

i use show files feature in solution explorer displays project files in folder structure mirrors file system, instead of using visual studio's filters. goal create visual studio project outside of source tree still lists files in directory structure. what did far create empty solution , project in directory structure shown below. selected 3 folders inside src directory , dragged them project. got added project show as plain list in solution explorer, not in native directory structure. repository ├─ src │ ├─ types │ │ ├─ *.h │ │ └─ *.cpp │ ├─ managers │ │ ├─ *.h │ │ └─ *.cpp │ └─ modules │ ├─ *.h │ └─ *.cpp └─ project ├─ *.sln └─ *.vcxproj how can create project located out of source tree without breaking mentioned file system view? i couldn't find out how out of source tree projects in visual studio think not supported. solve problem, added file names visual studio uses our .gitignore . lists provided on internet, example github . ...

c# - Asp.Net WebApi run MongoDB query/save async -

i trying figure out when use task.run , when not. in project i'm using webapi combined mongodb store account information. so following sample code, better of using submit or sumbitasync method client call? public class testcontroller : apicontroller { [httppost] public void submit() { dosave(); } public async task submitasync() { await task.run(() => dosave()); } private void dosave() { mymongodbcollection.save(new testentity()); } } the mongodb c# driver not support async methods. there's no point in using task.run here. the point of using async i/o in asp.net free thread, can handle other requests, until i/o has completed. meanwhile, no thread blocked. when i/o operation has finished, i/o completion port signaled , method resume. using task.run , you're deferring threadpool thread, , making that thread block waiting i/o. in other words, if client doesn't support async i/...

c# - MultiValueConverter - NotifyPropertyChanged -

have little annoying problem requirements , hope possible solve. lets assume have following classes: public class foo { public string name { get; set; } public list<foob> foobs { get; set; } } public class foob { public int id1 { get; set; } public int id2 { get; set; } public decimal sum { get; set; } } now foo class has list of foob given id1 , id2 values , sum value gets calculated. in wpf user interface, have 2 comboboxes , 1 datagrid . 1 combobox hold information id1 , other id2 . now in datagrid, have list of foo displayed 2 columns 1 name, other gives me headache right now. the second column should display sum property of "correct" foob class. the correct foob class determined 2 comboboxes in ui , there selecteditem. what have done far create 2 properties in codebehind: (notice have backingfields , propertychanged specified reduced code main problem) public int selectedid1 { get; set; } public int selectedid2 {...

django - JavaScript is not loaded site change with jQuery Mobile -

i have mobile website builded django backend (should irrelevant in case). when page changes javascript not loaded on next page. have wrapped javascript inside following clause: $("#mypage").on('pagecreate', function() { var duration_minute = 1; $("#min_knob").val(duration_minute); {# $(function() { #} var minute_min = 0; var minute_max = duration_minute; var second_min = 0; var second_max = 60; $("#min_knob").knob({ 'min': minute_min, 'max':minute_max, 'readonly':true, 'thickness':0.2, 'width': '100', 'height': '100', 'fgcolor':'#34495e', draw: function () { $(this.i).val(this.cv + 'm') }, }); $("#sek_knob").knob({ 'min': second_min,...

Inheritance between two classes in c++ using the same data members and functions -

i'm new c++ programming , want create 2 classes have exact same data members , functions. possible create 2 inherited classes have same data members/functions instead of making several duplicate methods each class. i'm making c++ game based on zork , want create 2 items, weapons , fruits. both take in name string , value double. create header file below: #ifndef item_h_ #define item_h_ #include <map> #include <string> #include <iostream> using namespace std; class item { private: string description; string longdescription; float value; public: item (string description, float invalue); item (string description); string getshortdescription(); string getlongdescription(); float getvalue(); void setvalue(float value); }; class weapon:: public item{ }; class fruit:: public item { }; #endif /*item_h_*/ how no go creating meth...

c# - EF primitive properties not mapped even though are persisted in DB -

i have following class: public class mymodel { public guid id { get; set; } public datetime timestamp { get; set; } public string address { get; set; } public string name { get; set; } public string city { get; set; } public string state { get; set; } } and following context: public class applicationdbcontext : dbcontext<mymodel> { public applicationdbcontext() : base("defaultconnection") { } public virtual dbset<mymodel> mymodels { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { base.onmodelcreating(modelbuilder); modelbuilder.entity<mymodel>().totable("mymodels"); } } when saving in db, assign fields timestamp, address, name , rest of fields update them later (city, state): var model = new mymodel(){timestamp = datetime.now, address = "...

android - Handing over Facebook data via Intent -

i trying pass facebook data 1 activity another. the logs in activity 1 show data received (name, age etc.). however, when try work data in activity 2, nothing happens. none of logs @ bottom show up. idea i'm doing wrong? protected void handlefacebookdata() { intent intent = getintent(); name = (string) intent.getserializableextra(const.name); log.d(profile.class.getsimplename(), "got fb name"); age = (string) intent.getserializableextra(const.age); log.d(profile.class.getsimplename(), "got fb age"); imgurl = (string) intent.getserializableextra(const.pic); x = bitmapfactory.decodefile(imgurl); log.d(profile.class.getsimplename(), "got fb picture"); facebookdata = true; } final intent intent = new intent( mainactivity.this, profile.class); intent.putextra(const.name, ...

javascript - `[$injector:nomod] Module 'google-maps' is not available` -

i'm using angular-google-maps handle google maps @ angular application. this, have add angular-google-maps.js to project. page works without error, if add script in following way: <script type="text/javascript" src="http://www.directiv.es/application/html/js/nlaplante/angular-google-maps/angular-google-maps.js"></script> but not work, if use local copy, this: <script type="text/javascript" src="js/libs/directiv.es/angular-google-maps.js"></script> looking @ firebug, see angular-google-maps.js file loaded, in case, following error occurs: uncaught error: [$injector:modulerr] failed instantiate module mapsapp due to: error: [$injector:modulerr] failed instantiate module google-maps due to: error: [$injector:nomod] module 'google-maps' not available! either misspelled the...<omitted>...1) searching web hours did not find reason or solution. maybe have idea or hint, how fin...

sftp - PHP and PHPSec trying to make a connection and getting errors -

i'm trying find easiest way test sftp connection in php. don't intend upload/download files. want open connection, confirm ok, close it. i came across 'phpsec' seems want, except, can't make work. my script far is: <?php require_once '../lib/phpsec/bootstrap.php'; require_once 'splclassloader.php'; $classloader = new splclassloader('phpsec', '../generic/lib'); $classloader->register(); $server = "123.456.789.012"; $port = "22"; $username = "xxx"; $password = "xxx"; set_include_path(get_include_path() . path_separator . 'c:\apache\htdocs\phpseclib'); define('net_ssh2_logging', 2); include 'phpseclib/net/sftp.php'; define('net_sftp_logging', net_sftp_log_complex); $sftp = new net_sftp($server); // check sftp connection if (!$sftp->login($username, $password)) { echo 'login failed.'; print "</br>...

javascript - Enter keypress function in Form doesn't work -

i did form calculate shippings: <div class="container-frete"> <div class="title-frete"> simulação de entrega:<br> <div class="label-frete"> digite seu cep<br> </div> <input id="cep" type="text"/> <input id="botao" type="button" class="button-frete" value="<?php echo $this->__('calcular'); ?>"/> </div> <div id="content-frete"> </div> but don't know how make enter keypress work on it: <script> event.observe('botao', 'click', function(event) { new ajax.updater('content-frete', '/freteproduto?cep='+$('cep').getvalue()+'&productid=<?php echo $produto->getid();?>', { method: 'get' }); }); </script> i make new 1 in jquery jquery.noconflict(); // inside input "cep" ...

c# - Nhibernate using SQL query to select items -

i trying set out nhibernate , got work. second step use costum sql select objects ive tried following: var query = "select * " + "from dage_i_ks dato in (:orderyear));"; var session = mysessionfactory.opensession(); var result = session.createsqlquery(query) .addentity(typeof(dage_i_ks)) .setstring("orderyear", "2012") .list<dage_i_ks>(); but getting sql error: could not execute query [ select * dage_i_ks dato in (?)); ] name:orderyear - value:2012 [sql: select * dage_i_ks dato in (?));] i not sure problem following works fine: using (mysession.begintransaction()) { icriteria criteria = mysession.createcriteria<dage_i_ks>(); ilist<dage_i_ks> list = criteria.list<dage_i_ks>(); mysession.transaction.commit(); }

php - New vhost with Apache2 + Vagrant -

i'm trying create new vhost in apache2. runs in vm through vagrant. i have placed directory wp installation in /vagrant/ (/vagrant/example/). consequently, create new vhost apache2 way: sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/example.com sudo nano /etc/apache2/sites-available/example.com inside example.com, have this. aware i've changed port 80 2345, access localhost:2345: <virtualhost *:2345> serveradmin webmaster@localhost documentroot /vagrant/example/ <directory /> options followsymlinks allowoverride none </directory> <directory /www/var/> options indexes followsymlinks multiviews allowoverride none order allow,deny allow </directory> scriptalias /cgi-bin/ /usr/lib/cgi-bin/ <directory "/usr/lib/cgi-bin"> allowoverride none options +execcgi -multiviews +sy...

css - Why is inline style being overridden -

i trying put border around div. <div style="border-color: yellow; border-style: dotted; border: 5px;"> <p> test. </p> </div> yet when run this, browser shows actual style being applied: <div style="border: 5px currentcolor;">...</div> the result no border shown @ all. this makes no sense me why border styles being overridden. can imagine bootstrap has set !important override somewhere, have been unable trace this. change order in applying inline styling. can add 3 styling in border style border:5px dotted yellow; . if still want go way did, change order. first add border style , specify other styles this. <div style="border: 5px; border-color: yellow; border-style: dotted;"> <p> test. </p> </div>

save - SVG file looks different in webbrowser than in Illustrator -

Image
i've been doing stuff in illustrator , have problem saving project in svg file open in webbrowser, looks different. and hapens in svg, if save pdf or png looks how should. doing wrong? that's how looks in ai that's how looks in webbrowser here's a link download rar file .ai , .svg have. since browsers render same way, seem bug in ai svg export filter. to me looks applying blend mode ("overlay" perhaps?) white parts on top of image. effect ought reproducible using svg filters, perhaps ai's exporter doesn't support yet. if using "odd" blend mode, try changing it, or reproducing effect way.

android - Keyboard is not showing on single click -

i trying show keyboard onclick not showing automatically (keyboard in hidden state in manifest) working on double click... here source. search.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { search_friends.setvisibility(view.visible); //my_friends.setvisibility(view.gone); search_friends.requestfocus(); if(search_friends.hasfocus()) { getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_state_visible); } else { getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_state_hidden); } } }); i want on single click... this method, made util class, use in every project , works: /** * hide ed == null <br/> * show ed !=null * * @param context * activity * @param ed * edittext...