Posts

Showing posts from July, 2011

javascript - Jasmine object “has no method 'andReturn'” -

beginner jasmine, first attempt jasmine spies. thought mimicking format displayed here (search: "andreturn"), i'm getting error can't work out: typeerror: object function () { calltracker.track({ object: this, args: array.prototype.slice.apply(arguments) }); return spystrategy.exec.apply(this, arguments); } has no method 'andreturn' no clue i'm doing wrong. here's spec: describe('die', function() { it('returns value when roll it', function() { var die = object.create(die); spyon(math, 'random').andreturn(1); expect(die.roll()).toequal(6); }); }); and corresponding js: var die = { roll: function() { return math.floor(math.random() * 5 + 1); } } thanks help!!! jasmine 2.0 changed of spy syntax. jasmine 2.0 docs spyon(math, 'random').and.returnvalue(1);

java - solr response in xml format -

i trying query solr using fields , want response in xml format. somehow not able response in xml format though have set parser xmlresponseparser . please check code , let me know wrong in here: httpsolrserver solr = new httpsolrserver(urlstring); string querystring ="*:*"; solrquery query = new solrquery(querystring); query.setquery(querystring); query.setfields("type", "typestring"); query.addfilterquery("id"); query.setstart(0); query.setrows(100); solr.setparser(new xmlresponseparser()); queryresponse resp = solr.query(query); solrdocumentlist results = resp.getresults(); (int = 0; < results.size(); ++i) { // need results in xml format system.out.println(results.get(i)); } your code using solrj solr client. it's precisely done avoid dealing xml responses, , provides clean way solr results in code objects. if want raw xml response, pick java http client, build request , send solr . you'll nice xm

rest - vb.net saving a web binary to a file -

i have web rest service trying extract image (or wav file) from. can image (jpg) via memory stream , display picture box, , save picture box file. want eliminate intermediate step of using picture box , save memory stream straight file. however, resultant file not seem jpg file. when opening throws corrupted file error. the code have follows: dim msguri string msguri = "http://192.168.0.1/attachment/12345/0" dim pic new picturebox() dim web_client new webclient() web_client.credentials = new networkcredential("xx", "xx") dim image_stream new memorystream(web_client.downloaddata(msguri)) pic.image = image.fromstream(image_stream) dim bm bitmap = pic.image dim filename string = "c:\temp\test.jpg" bm.save(filename, imaging.imageformat.jpeg) and works fine. however when use following bypass bitmap , picturebox: using file new filestream(filename

php - How to reference an object from inside a private function -

i using mixpanel 's php api , want call mp->track . in case, mp->track defined object in mixpanel library, called via require(mixpanel.php) . typically, work fine: require ('mixpanel-php/lib/mixpanel.php'); $mp = mixpanel::getinstance("xxx"); $mp->track('session'); however, want call mp->track() within private function, following gives object not defined error: require ('mixpanel-php/lib/mixpanel.php'); $mp = mixpanel::getinstance("xxx") private function startsession() { $mp->track('session'); } this approach; if define $mp = mixpanel::getinstance("xxx"); somewhere in class; should use as $this->mp->track('session'); so code should <?php require ('mixpanel-php/lib/mixpanel.php'); class myclass { protected $mp; public function __construct() { $this->mp = mixpanel::getinstance("xxx"); } private function s

python - Weird OpenCV .read() hangs with no error -

i have website allows users upload videos. during process there script automatically creates thumbnail. here code using accomplish this: f = request.files['video'] f_temp = open('/path/to/video/dir/' + f.name, 'wb+') chunk in f.chunks(): f_temp.write(chunk) f_temp.close() cap = cv2.videocapture('/path/to/video/dir/' + f.name) nothing, img = cap.read() cv2.imwrite('/path/to/thumbnail/dir/' + f.name.split('.')[0] + '.png', img) currently, video saved properly. however, when creating thumbnail, script hangs @ cap.read() , never throws error. now here's weird part - if remeve last 3 lines upload video , doesn't create thumbnail, can ssh server , run last 3 lines directly , works should. script hangs when running live on website ... i have no clue why happen when code called through web request. i tried switching cap.read() cap.grab() img = cap.retrieve() , hangs on .retrieve() instead. solved

sqlite3 - SQLite updating ONE record is very (relatively) slow -

i know sqlite's 'problem' when inserting/updating many rows, that's not case here. i'm updating 1 field in 1 row, indexed pk, in table ~ 250 records. query takes ~ 200 ms. sounds little, it's huge. why 1 simple update query take 200 ms?? reads blazing fast. i've tried: begin , commit -- no change, because it's 1 statement pragma journal_mode=persist -- no change, apparently disk io isn't problem? removing update statement -- works wonderfully time!, it's not persistent to compare mysql on same system: 0.6ms in similar database. i don't need transactional security (acid?) or whatever call that. if computer crashes during query, i'm fine losing all changes. mysql (innodb) has option this: innodb_flush_log_at_trx_commit . sqlite have that? i'm using sqlite-3.7.9, if matters. yes, sqlite has option mysql's innodb_flush_log_at_trx_commit : pragma synchronous=off and works charm. no acid, yes sp

javascript - JScript Check if element exists and remove it -

i'm trying write simple function in javascript check if element exists in dom , if remove, , if doesn't, append page, far i've got this if document.contains(document.getelementbyid("submitbutton") { document.getelementbyid("submitbutton").remove(); } else { lastdiv.appendchild(submitbutton); } (lastdiv div want append div 'submitbutton' to) yet i'm getting error "uncaught referenceerror: myfunction not defined" any help? i'm aware newbie question, sorry that there syntax error in code, if statements require parens if (document.contains(document.getelementbyid("submitbutton"))) { document.getelementbyid("submitbutton").remove(); } else { lastdiv.appendchild(submitbutton); }

c# - How to configure a WCF client using basicHttpBinding and Username authentication over https -

i'm trying consume web service provided group within our company. service written in java , java test client functions properly. however, cannot .net4.0 or .net 4.5 based wcf client talk it. require https transport , since java i'm using basichttpbinding. require username/password. in java, saying username/password @ binding level , when looking @ message captured test code, there no evidence of username or password being sent. can connect service cannot authenticated because not seeing username & password. username , password being set in code. testing against dev server using self signed cert. our endpoints physically 1500 miles apart connect via internal corporate (secure) network. i need know proper config settings "binding", "behavior", , "endpoint" use @ client. can post settings misleading i've tried 100's of them , none give desired result. any can give useful long doesn't involve changes on (or knowledge o

R - How to work with and plot time data -

Image
i have following data (of following small sample): times <- c("02:45:00", "02:45:07", "02:45:10", "02:45:20", "02:45:25", "02:45:27", "02:45:27", "02:45:30", "02:45:32", "02:45:37") i plot these times , able have them in time variable format if possible. in graph, want able have different time bands in order create histogram of different distribution of times. you strptime familiar base time format. then, might started: hist(strptime(times,"%h:%m:%s"), "secs", freq = true, xlab="seconds")

python - Comparing a list of lists with a list to find similar numbers -

here tried: my_tickets = [ [ 7, 17, 37, 19, 23, 43], [ 7, 2, 13, 41, 31, 43], [ 2, 5, 7, 11, 13, 17], [13, 17, 37, 19, 23, 43] ] def lotto_matches(xs, my_tickets): xi = 0 # used pick specific things lists yi = 0 # used pick specific things lists result = [] in my_tickets: # list of lists x in xs: # picks if my_tickets[i] == xs[x]: #not sure if statement suppose result.append() # don't know goes in parenthesis print (result) return (result) lotto_matches([42,4,7,11,1,13], my_tickets) i trying write function takes list of tickets , draw, , returns list telling how many picks correct on each ticket. it supposed return [1,2,3,1] output wrong. how can this? you can use map , intersection this: def lotto_matches(pick, my_tickets): result = map(lambda x: len(set(x).intersection(pick)), my_tickets) return result print lotto_matches([42,4,7,11,1,13], my_tickets) where pick

java - Client socket doesn't take any input from cmd -

i create program server sends list of files client client can request check contents. sends list of files client doesn't take input console. server program import java.util.*; import java.io.*; import java.net.*; class tcpserver{ public static void main(string args[]) throws exception{ serversocket server = new serversocket(4888); while(true){ socket client = server.accept(); system.out.println(client); dataoutputstream out = new dataoutputstream(client.getoutputstream()); file path = new file("c://testjava"); string[] files = path.list(); string send = ""; for(string file:files){ send = send + file + "\n"; } out.writebytes(send); bufferedreader in = new bufferedreader(new inputstreamreader(client.getinputstream ())); string search_file = in.readline(); string searching = ""; for(string file:files){ if (file.equals(search_file)){ searching = searc

asp.net - Removing comments from web.config on build -

is possible remove commented lines web.config on build? xml transform fine remove elements couldn't find syntax clean comments file. we using tfs 2010 build server our builds. it's not possible xml transformation. but can own console app or msbuild task. see example code here remove xml comments using visual studio 2010 web config transformation

javascript - Refused to get unsafe header "Content-Length" / reading ID3 tags from external mp3's -

i trying write script loads id3 tags .mp3 file. after searching hours, found one script had small size , did wanted, can't work cross-domain .mp3 files. have tried using csp headers bypass this, without luck. is there way around this, downloading file in backgrond , showing progress bar, or can bypass way? the error when loading external file: refused unsafe header "content-length" it's connected .getresponseheader(); far remember.

html - Python mechanize not recognizing form -

i'm trying login @ this page . br = mechanize.browser(factory=mechanize.robustfactory()) br.set_cookiejar(cj) current_page = br.open(login_url) soup = beautifulsoup(current_page.get_data()) current_page.set_data(soup.prettify()) br.set_response(current_page) print soup.findall('form') assert br.viewing_html() f in br.forms(): print f.name but prints none forms though beautifulsoup finding form perfectly. have ideas? something work: bs4 import beautifulsoup import mechanize import cookielib br = mechanize.browser() cj = cookielib.lwpcookiejar() br.set_cookiejar(cj) host = 'https://order.papajohns.com/secure/signin/frame.html?destination=http%3a%2f%2forder.papajohns.com%2findex.html%3fsite%3dweb%26dclid%3d%2525n-2543611-4121096-71899047-246709315-0%26esvt%3d336192-gouse339376223%26esvq%3dpapa%2520johns%26esvadt%3d999999-0-3934985-1%26esvcrea%3d41751468573%26esvplace%26esvd%3dc%26esvaid%3d30536%26gclid%3dci2ps

python - regex, matching optional dot before \b -

i have bunch of street names, , trying clean street names "st augustine" , "st. augustine" can replace them "saint augustine" trying match either "st" or "st.", , tried using following, doesn't seem match dot. using python. \bst\.?\b python docs say: in python’s string literals, \b backspace character, ascii value 8. if you’re not using raw strings, python convert \b backspace, , re won’t match expect to. so im guessing (because lack of information post) solution problem r'\bst\.?\b' (raw string, otherwise \b means backspace).

ios - Make only part of a sentence a link (add selector) -

so trying implement following. have view, has sentence. part of sentence links view. looks like: i cat. learn more the learn more link (blue in color), when clicked open view. currently using uilabel write "i cat". realize best way add selectors use button, "learn more" should button? is there way write sentence out without using 2 different uicomponents? if not, how make uilabel , uibutton horizontally aligned each other? the following code label in -layoutsubviews: cgsize labelsize = [_label.text sizewithfont:_label.font constrainedtosize:bounds.size linebreakmode:_label.linebreakmode]; _label.frame = cgrectmake(0, 0, bounds.size.width - kmarginfortext, labelsize.height); _label.center = cgpointmake(horizontalcenter, cgrectgetmaxy(_previouslabel.frame) + kdistancebetweenpreviousandcurrentlabel); and code label itself. _label = [[uilabel alloc] initwithframe:cgrectzero]; _label.text = "i cat"; _label.font = [uifont sy

node.js - How to use variable mongoose query? -

data schema id: string, item: { possess: { jewel: [number] } code var temp = 1 db.collection.update({"id":"sample"},{"$set":{"item.possess.jewel.1":888}) how use variable temp in "item.possess.jewel.1" ? "item.possess.jewel.temp" doesn't work you have build $set object programmatically: var temp = 1; var set = {$set: {}}; set.$set["item.possess.jewel." + temp] = 888; db.collection.update({"id":"sample"}, set);

I thought that "git pull" includes merge, seems not, what am not understanding? -

i have 2 branches sw-dev , make . have file variables.mk changed locally in make branch. in meantime, file changed in origin sw-dev repository include line blk := pl/blocks . when >git pull origin sw-dev i expect there either silent or conflict merge. no, nothing happens, date. missing?? >git checkout origin/sw-dev head @ 4f391d3... merge branch 'sw-dev' of ssh://(...)/tools/git/xdk sw-dev >grep blk variables.mk blk := pl/blocks >git checkout make switched branch 'make' >git pull origin sw-dev /tools/git/xdk * branch sw-dev -> fetch_head up-to-date. >grep blk variables.mk >git status variables.mk # on branch make nothing commit, working directory clean you not missing anything, pull fetch branch , merges current one. telling branch make contains commit hashes in origin/sw-dev. have had include commit 4f391d3 make branch @ point. do git log in make , hash 4f391d3 verify it. do git reflog check last comm

java - How to check a List whether it contains all the elements as NULL string? -

i having linkedlist - list<string> tables = new linkedlist<string>(); sometimes, tables list like, meaning have null string values inside - [null, null] is there direct way of identifying if tables list has elements null string, return true, otherwise return false. one way can think of keep on iterating , see whether has null string or not , return true or false accordingly. update:- public static void main(string[] args) { string table_1 = null; string table_2 = "hello"; list<string> tables = new linkedlist<string>(); tables.add(table_1); tables.add(table_2); boolean ss = isallnull(tables); system.out.println(ss); } public static boolean isallnull(iterable<?> list) { (object obj : list) { if (obj != null) return false; } return true; } yes thinking good, better if make part of utility class public static boolean isallnull(iterable<?> list){ for(object obj : list){ if(obj != null)

java - Sorting of an array without using array.sort -

i not getting output of code dont understand error in code can help? using ide , error shows not understandable me .i pasting code below know class sort_basic { public static void main (string[] args) { int[] myint=new int[]{20,100,69,4}; for(int a=0;a<myint.length;a++) { for(int b=a;b<myint.length;b++) { if(myint[a]>myint[b]) { int temp; temp=myint[a]; myint[a]=myint[b]; myint[b]=temp; } } } system.out.println("sorted array is:"); for(int i=0;i<myint.length;i++) { system.out.println(myint[a]); } } } for more understanding pasting o/p here: 24: error: cannot find symbol system.out.println(myint

php - Page to display online users with photos -

i attempting create social network far have got far registration form passing valid data database, have 2 tables.... member table - firstname - lastname - mobilenumber (pk) - postcode - city members details etc.. user table - userid (pk) auto increment - username - password - profilepic - accounttype in web site attempting have page users can browse other users , can select page show online users along profile picture , username. wondering how go or if 1 has done similar types of webpages give me tips, @ moment can see counters display online users integer. doing project php mate, plan before execute. :) please ask specific question if have trouble in getting things done. try homework , ask questions here if have problem or error post questions. there youtube tutorials can find help. please post codes, show have tried , you.

c++ - Processing command line arguments, allowing for any order -

ok creating program allows user input in order. term -1 or -2 used indicate operating mode. while argument -c precedes filename. here loop have written allow these entered in order user wishes. int main(int argc, char *argv[]) { string qcolors_name; string inputfilename; pmode_t mode = run_process2; // perform command line argument checking if(argc < 2){ cerr << "not enough arguments" << endl; return 0; } for(int = 1; < argc - 1; i++){ if(argv[i] == "-1"){ mode = run_process1; cout << "mode 1" << endl; }else if(argv[i] == "-2"){ mode = run_process2; }else if(argv[i] == "-c"){ qcolors_name = argv[i+1]; cout << qcolors_name << endl; i++; }else if(argc-1 == i){ break; }else{ cout << argv[i] <<endl;

Python indexing a list -

i have list below: how do index in python. want fetch value "os"? please let me know. [{'username': 'd699a1f25d9a3', 'browserversion': none, 'passwordminlength': 0, 'systemautolock': 0, 'os': 'windows 7 6.1 build 7601 : service pack 1 64bit'}] mylist = [{'username': 'd699a1f25d9a3', 'browserversion': none, 'passwordminlength': 0, 'systemautolock': 0, 'os': 'windows 7 6.1 build 7601 : service pack 1 64bit'}] os = mylist[0]['os'] print os

java - Customize text inside Edittext for chatting -

i want customize text inside edittext of chatting app. want bold username , normal font message. example; usernamejay: hi jay. how you? also make 1 space reply after message of usernamejay. want change font color of username. if possible put message balloon every message. example: usernamejay: hi jay. how you? usernameclark: i'm fine. can call meeting? can me how. code java import java.io.unsupportedencodingexception; import com.example.healthhelpv2.*; import android.app.activity; import android.app.alertdialog; import android.app.dialog; import android.app.notificationmanager; import android.content.broadcastreceiver; import android.content.componentname; import android.content.context; import android.content.dialoginterface; import android.content.intent; import android.content.intentfilter; import android.content.serviceconnection; import android.database.cursor; import android.os.bundle; import android.os.handler; import android.os.ibinder; import android

matlab - Save data as modified input file name -

i have program loads data .txt file , performs curve fitting. input file name example experiment09.txt . after processing want save variable same input filename appended _fit . saved workspace variable in case experiment09_fit.txt . i have gotten far in matlab: buf = length(filename) savename = filename(1:buf-7) which gives me savename of experiment09 @ loss how add chosen string on end make experiment09_fit . once have valid save name call save(savename, 'fittedvalue', '-ascii'); help appreciated. what this: filename = 'experiment09.txt'; [pathstr, basename, ext] = fileparts(filename); outname = [basename, '_fit', ext]; % give 'experiment09_fit.txt'

Is there a way to get external data in javascript? -

i have minimal knowlege of javascript please kind. have created basic javascript show random quote politician, said it, when, , provides link source of quote. looks that: /the quote var n_text = new array (); /the link var n_lnkk = new array (); /the party member said , when var n_part = new array (); n_text [1]="blah"; n_text [2]="blah blah"; n_text [3]="blah blah blah"; etc n_lnkk [1]="http://..."; n_lnkk [2]="http://..."; n_lnkk [3]="http://..."; etc n_part [1]="whosaidit1"; n_part [2]="whosaidit2"; n_part [3]="whosaidit3"; etc then use math.random , document.write show random quote , show twitter button people can tweet it, , refresh button show random quote this: blah blah http://... whosaidit , when i know document.write not best way have tried other methods , didn't work twitter button have wait untill find solution not question have right now. the problem script has be

c# - Error Linq to Entities Datetime -

i have following code var dates = query.select( x => datetime.parseexact(x.date, "yyyy-mm", cultureinfo.invariantculture)); var mindate = dates.min(x => x); but when execute that, exception system.data.entity.dll not handled in user code additional information: linq entities not recognize method 'system.datetime parseexact(system.string, system.string, system.iformatprovider)' method, , method cannot translated store expression. what doing wrong? , how can fix that? well, error quite clear. there no translation in linq entities of parseexact sql. remember, entity framework, under covers, converts query sql command or set of commands. if ef doesn't know how translate something, throws error. one possible solution, while not terribly efficient, convert iqueryable ienumerable, allow execute statement. var dates = query.tolist().select( x => datetime.parseexact(x.date, "yyyy-mm&q

Retrieving data using PHP cURL while logged in -

i complete n00b @ using curl , trying simple retrieval using $_post. think problem may url using, https. have suggestion on how can handle this. here code: formy.php <pre> <form name="test" method="post" action="formy.php"> <input type="text" name="name" size="40" /> <input type="submit" name="submit" value="submit" /> </form> </pre> curl.php $h = curl_init(); curl_setopt($h, curlopt_url, "https://path/to/formy.php"; curl_setopt($h, curlopt_post, true); curl_setopt($h, curlopt_postfields, array( 'name' => 'yes', 'submit' => 'submit' )); curl_setopt($h, curlopt_header, false); curl_setopt($h, curlopt_returntransfer, 1); $result = curl_exec($h); echo "test" . $result; just add following option before curl_exec curl_setopt($h, curlopt_ssl_verifypeer, false);

jquery - Excel Export: How to export JSON data to Excel from javascript? -

i have developed web project in asp.net mvc 4 registered user can generate reports based on transaction. report generation using jqgrid. currently reports generating , want add feature 'export excel' in project. since generated report large dont want send entire date server again generating excel.so planning generate excel client side. so have done research in web , found 1 javascript library here . added library in project , s working fine.but found 1 problem here ,it wont work in ie(any version). is there other javascript lib available can export report data excel. any appreciated. farther down in page you'll see this: supported browsers: chrome, supported in versions firefox, supported in versions opera, supported since 7.2 safari, supported in versions internet explorer, not compatible. this because plugin (battatech_excelexport) uses data uris. http://caniuse.com/datauri

mysql - Cascade Not Working -

i have couple tables weakly connected , delete work across both of them when delete main table. table 1: create table car( cid integer, color varchar(10), primary key (cid) ); create table tags( tid integer, expdate varchar(10), cid integer, primary key (tid, cid), foreign key (cid) references car(cid) on delete cascade ); but when delete car car table, not deleted tags table. i've tried adding constraint after table creation same result. set sql_mode="no_auto_value_on_zero"; set time_zone = "+00:00"; -- -------------------------------------------------------- -- -- table structure table `car` -- create table if not exists `car` ( `cid` int(11) not null auto_increment, `color` varchar(10) default null, primary key (`cid`) ) engine=innodb default charset=latin1 auto_increment=5 ; -- -- dumping data table `car` -- insert `car` (`cid`, `color`) values (2, 'b'), (4, 'a'); -- ------------------------------------------

haskell - Indices of all matches of a regex -

i trying match occurrences of regex , indices result. example real world haskell says can do string =~ regex :: [(int, int)] however, broken since regex library has been updated since publication of rwh. (see all matches of regex in haskell , "=~" raise "no instance (regexcontext regex [char] [string])" ). correct way this? update: i found matchall might give me want. have no idea how use it, though. the key using matchall using type annotation :: regex when creating regexs: import text.regex import text.regex.base re = makeregex "[^aeiou]" :: regex test = matchall re "the quick brown fox" this returns list of arrays. list of (offset,length) pairs, access first element of each array: import data.array ((!)) matches = map (!0) $ matchall re "the quick brown fox" -- [(0,1),(1,1),(3,1),(4,1),(7,1),(8,1),(9,1),(10,1),(11,1),(13,1),(14,1),(15,1),(16,1),(18,1)] to use =~ operator, things may have changed s

html - Only one External css not loading in website -

i facing weird problem external css files. creating jsp website have 3 external css files mobile, tablet , desktop respectively. css files loading fine in local development environment. include statments below. <link rel="stylesheet" type="text/css" href="<c:out value="${pagecontext.request.contextpath}"/>/css/style_eng.css" /> <link rel="stylesheet" type="text/css" href="<c:out value="${pagecontext.request.contextpath}"/>/css/mobile_eng.css" media="only screen , (max-width:480px)"> <link rel="stylesheet" type="text/css" href="<c:out value="${pagecontext.request.contextpath}"/>/css/tablet_eng.css" media="only screen , (min-width:481px) , (max-width:768px)"> <link rel="stylesheet" type="text/css" href="<c:out value="${pagecontext.request.contextpath}"/>/css/st

How do i open a .dump file format in ubuntu without using Wireshark? -

i have dos attack downloaded datasets in dump format i.e lldos.dump . it opens using wireshark in ubuntu need modify , apply support vector machine classifier. can tell me how open .dump file reading , writing other using wireshark. thank . take @ libpcap library (which used wireshark , tcpdump) if don't mind writing own code parse files.

ios - How to read sub elements of a plist file -

Image
i having plist file want access 3 elements( item 0, item 1, item 2 ) under under 5k , want store in array. how can ? if 1 know solution please me solve issue. if not clear please post comments replay it. thanks in advance. expended form. the code have used -(void)selectlevel { plistpath = [[nsbundle mainbundle] pathforresource:@"planlist" oftype:@"plist"]; nsmutabledictionary * plist = [[nsmutabledictionary alloc] initwithcontentsoffile:plistpath]; nsmutabledictionary * specific; nsarray * leveldata = [plist objectforkey:@"5k"]; nsarray *complexity = [leveldata objectatindex:1]; nslog(@"++++++++%@",complexity); (int i=0; i<3; i++) { specific =(nsmutabledictionary *)[leveldata objectatindex:i]; nslog(@"-------%@",specific); } nslog(@"=======-%@",[specific allkeys]); } out put getting

c# - how to show a message box with ok and cancel button -

i building app windows phone 7 need show message box both ok , cancel button. when ok button pressed want navigate new page while when cancel button pressed want stay in same page: the code wrote is: public donate() { initializecomponent(); messageboxresult result = messagebox.show("this take out of app , forward our contribution website!", "", messageboxbutton.okcancel); if (result == messageboxresult.ok) { donation.source = new uri("http://mobiledonation.vzons.com/arvindkejriwal", urikind.absolute); donation.loaded += (object sender, routedeventargs e) => { donation.navigate(new uri("http://mobiledonation.vzons.com/arvindkejriwal", urikind.absolute)); }; } else navigationservice.navigate(new uri("/aap.xaml", urikind.relative)); } now here problem when cancel bu

Running jobs on a cluster submitted via qsub from Python. Does it make sense? -

i have situation doing computation in python, , based on outcomes have list of target files candidates passed 2nd program. for example, have 50,000 files contain ~2000 items each. want filter items , call command line program calculation on of those. this program #2 can used via shell command line, requires lengthy set of arguments. because of performance reasons have run program #2 on cluster. right now, running program #2 via ' subprocess.call("...", shell=true) i'd run via qsub in future. have not experience of how done in reasonably efficient manner. would make sense write temporary 'qsub' files , run them via subprocess() directly python script? there better, maybe more pythonic solution? any ideas , suggestions welcome! it makes perfect sense, although go solution. as far understand, have programme #1 determines of 50,000 files needs computed programme #2. both programme #1 , #2 written in python. excellent choice. incid

android - isApplicationBroughtToBackground security feature misbehaves often -

i using implement security feature displays locking screen if app regains focus after coming different app. now, problem security feature shown twice. after digging around bit noticed topactivity activitymanager.getrunningtasks(1) still activity returned from. in case, offending lingering apps com.android.mms , com.google.android.apps.maps. i have calling facility within application not misbehaving. i baffled behavior. this problematic case android. try following worked me: have base class activities. in it: @override protected void onpause() { utils.wentinbackground(this); super.onpause(); } @override protected void onresume() { utils.wentinforeground(this); super.onresume(); } then in static utilities class have this: public static void wentinbackground(final activity which) { inbackground = true; lastpaused = which.getclass().getsimplename(); final powermanager powermanager = (powermanager) which.getsystemservice(power_servi

c# 4.0 - showing ListView error -

am not able insert update delete , clear operatopns on listview in winforms here's code: private void form1_load(object sender, eventargs e) { showdata(); } private void showdata() { sqlconnection con = new sqlconnection("user id=sa;password=sql@123;database=arvind;server=ashok-pc"); con.open(); sqlcommand cmd = new sqlcommand("select * login_1",con); datatable dt = new datatable(); sqldataadapter da = new sqldataadapter(cmd); da.fill(dt); listview1.datacontext = dt.defaultview; } i got error in datacontext system.windows.forms.listview not contain definition datacontext , no extension method accepting first argument of type system.windows.forms.listview found. you appear trying follow code example made wpf when you're using windows forms. winforms listview indeed not have such property , in fact doesn;t support data-binding. do favour , use datagridvi

sending email in android application -

i want send email in android application, had tried below code: btnfeedbacksubmit.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub intent email = new intent(intent.action_send); email.settype("text/email"); email.putextra(intent.extra_email, new string[] { "abc@gmail.com" }); email.putextra(intent.extra_subject, "feedback"); email.putextra(intent.extra_text, "hi"); startactivity(intent.createchooser(email, "sending feedback:")); } }); but shows me error "no apps can perform this" what more should have do??? try code: intent emailintent = new intent(intent.action_sendto, uri.fromparts( "mailto","abc@gmail.com", null)); emailintent.putextra(intent.extra

c# - To get total marks into a textbox -

my code is: protected void txttotal_textchanged(object sender, eventargs e) { int = convert.toint32(txtmaths.text); int b = convert.toint32(txtsci.text); int c = convert.toint32(txtenglish.text); int tot = + b + c; txttotal.text = convert.tostring(tot); } i trying total marks textbox, not working.can me please? you trying change text in same textbox text changing, sure want do? wouldn't want change total when maths,sci , english values change? if @ following. protected void txtmaths_textchanged(object sender, eventargs e) { updatetotals(); } protected void txtsci_textchanged(object sender, eventargs e) { updatetotals(); } protected void txtenglish_textchanged(object sender, eventargs e) { updatetotals(); } protected void updatetotals() { int = convert.toint32(txtmaths.text); int b = convert.toint32(txtsci.text); int c = convert.toint32(txtenglish.text); int tot = + b + c; txttotal.text = tot.tostring(

Which editor/plugin to use if I want control over the html tags surrounding the text inside a wysiwyg textarea? -

for instance, want able like: <p style="text-indent: 0">this first paragraph</p> <p style="text-indent: 2.4em">this first paragraph</p> <p style="text-indent: 2.4em">this first paragraph</p> any suggestions? perhaps tinymce . or if you'd rather go markdown route, try hallo

Adding Sequence to a Table in SQL Server 2012 -

sorry asking kind of noob question , reading. i need small clarification on adding sequence value column. if execute following code statement gets executed create table execsqlorg_employee( emp_id int not null constraint df_emp_id default next value seq, emp_name varchar(100), emp_gender bit, emp_salary money, emp_shift bit) go or if define table first , execute alter command, statement gets executed alter table exec_employee add constraint df_app_id default next value seq app_id so far good!! once if try add sequence columns following code error create table execsqlorg_employee ( emp_id int not null constraint df_emp_id default next value seq, emp_name varchar(100), emp_gender bit, emp_salary money, emp_shift bit constraint pk_app_id primary key (emp_id), constraint df_app_id default next value seq emp_id ) go when execute above code following error incorrect syntax near 'for'. just create table without sequence. , run query.. creat

c++ - How to make use of structure in another class? -

okay hello guys, have problem current assignment i have 2 classes, namely employee class, , gm class. in employee class, there structure used, namely struct einfo { char username [80]; char password [80]; int eid; }; however, in gm class, have functions rely on struct in employee class. example, void addemployee(fstream&, int, einfo&); void delemployee(fstream&, int, einfo&); void editemployee(fstream&, int, einfo&); how suppose make use of that? what have tried redeclaring struct einfo { char username [80]; char password [80]; int eid; }; inside gm class. not work well. no syntax error, when im using fstream afile; afile.open("employeeinfo.dat", ios::in | ios::out | ios::binary); the file turns out empty itself. any idea how fix ?? if struct einfo declared inside employe should refer employe::einfo when outside employe . if redeclare inside gm compiler consider employe::einfo , gm:

Service broker - conversation handle not found messages in SQL Server error log -

many threads opened on topic, none seem have answer problem going give try.. system : windows server 2012 sql server 2012 enterprise edition problem : using sqldependency enable use of query notification in our application means creates own service , queue , procedure. question 1: looking in stored procedure see receive top 0. mean top 0? now real problem.. , error log filled following messages (to point when cant open it) : query notification delivery not send message on dialog 'x'.... because of following error in service broker: 'the conversation handle x not found. messages appear same conversation_handle or 3 different most. when query conversation sys.conversation_endpoints , see , marked is_system = 1 (started_outbound). i've added alert on error 9245 try , identify why happens when happens. in message 'during last time interval x query notification errors suppressed' , x enormous , more 10,000. guess number related retrials because d

PHP MYSQL select query strip spaces from column -

i have query mysql_query("select * codes code='222 '"); i want strip spaces in column in query should mysql_query("select * codes code=strippedstring('222 ')" what best way this try $value=trim('222 '); mysql_query("select * codes code=$value" note:- stop using mysql_* deprecated learn trim()

mysql - Does InnoDB have static tables? -

i reading mysql documentation , wondering whether myisam's "static" table format applies on innodb or not? gain performance, if use char instead of varchar when real lengths varies between 0 , 100 characters or using varchar(100) better? innodb have fixed-width rows , there can advantage declaring columns in table fixed-width. main benefit "holes" in page can reused insertion, since rows same length. makes space re-use more efficient. not try force fixed-width strings on few dozen bytes though, cost of storing data per page (and fewer rows per page) overwhelm savings/gains you'd more efficient space re-usage. however, having fixed-width rows not allow optimization of row-scanning (like myisam) whatsoever. innodb's row storage page-based , uses b+tree doubly-linked lists of pages, , singly-linked records within page. row traversal using these structures , can't done other way.

On every children add 1 (+1) Umbraco Razor -

in code below need add (+1) on every children on data-slide-index="0". starting @ 0 , 1,2,3,4,5 it should this: data-slide-index="0" data-slide-index="1" data-slide-index="2" i thinking this. int thecount = 0; thecount += 1; // adds 1 count but dont know how use correctly in code. @foreach (var image in @model.children) { foreach (dynamic d in image.imagedampsingle) { <a data-slide-index="0" href="@damp_helper.getimagecropperurl(d, "projectsingle")"><img src="@damp_helper.getimagecropperurl(d, "projectsinglethumb")" title="@model.captiontext" alt="@d.image.nodename" /></a> or there easier / way this? thanks in advance! //rené razor view engine, using c# code in there logic operation. recursive methods algorithmic operations have capability call until condition satisfied. can use helper in case achieve that. example case: @hel

Modify and Redirect URL using .htaccess -

i want modify , redirect url: localhost:8080/backend/tb/?r=premium/site/testresponse?order_id=122113&status=success from testresponse?order_id" "testresponse&order_id need please :) this rule should work in document_root/.htaccess file: rewriteengine on rewritecond %{the_request} \s/+(.+?/testresponse)\?(order_id=122113)(&.*)\s [nc] rewriterule ^ /%1&%2%3 [l,r=301]

angularjs e2e - how to test if a string DON'T match using protractor -

i'm migrating karma-ng-scenario tests suite protractor. // karma-ng-scenario expect(element('legend').text()).not().tobe("login_connect"); in protractor way. seems there isn't not() function. i'm using angular-translate bind longin_connect string multiple languages , want test if string translated. more globally, there a way test if different ? ... don't have class, don't exists on page, not selected, ... it worth looking @ api docs . have these open pretty time. there lots of web driver functions can use isenabled() , isdisplayed() , isselected() etc. protractor uses jasmine syntax can use '.tobe(false)' assert things false. check classes, can like: expect(myelement.getattribute('class')).tocontain('my-class-name'); to compare strings , assert not match use .not . jasmine docs say: every matcher's criteria can inverted prepending .not: expect(x).not.toequal(y); compares objects

symbolic math - How to compare sym variable from vpa in matlab? -

assume have 2 variables 300 digits of precision: a = vpa(sqrt(2),300); b = vpa(sqrt(3),300); i want know whether (b-a) > (1e-15) true or false. should do? i think looking this: double(b-a)>(1e-15)

angularjs - How to access the $scope where the factory was injected? -

say have factory named myfactory , inject several controllers. how can access controllers scope inside factory? the way think of on how follows: app.factory('myfactory', function() { return function($scope) { mypublicfunc: function() { $scope.$on('$destroy', function() { ... }); } } }); app.controller('mycontroller1', ['$scope', myfactory', function($scope, myfactory) { var factory = new myfactory($scope); factory.mypublicfunc(); }); but there other way can return { } instead of function($scope) { } in myfactory , use factory directly ( myfactory.mypublicfunc ) instead of having create new instance new keyword and still access each controller's $scope ? if use .service instead of .factory have singleton instance in controller once inject via di and can example module.service('myservice', function() { return { mypublicfn: function() {} } }); and

android - Auto Exposure doesn't work after autoFocus -

i have sony experia l , android 4.2.2. camera auto exposure doesn't work after set autofocus. but properties have value: getexposurecompensation = 0; getautoexposurelock = false; how can fix auto-exposure? believe there way because commercial camera applications working on phone well. thanks.

termios - Cursor moving erratically (C) -

i'm having trouble doing nim game program. far have program show pyramid of pipes. looks "start position" pyramid on picture. http://www.mathsisfun.com/puzzles/images/b-nim.gif anyways, i'm having trouble moving around this, whenever try moving around, cursor move in erratic ways. thid make game totally unplayable. i'm not sure if problem counting variables or smaller thing i'm totally missing, anyways here's have: #include <stdlib.h> int nim() { char *tab; if ((tab = malloc(sizeof(char) * 20 + 4)) == null) return (-1); tab = " | \n ||| \n ||||| \n |||||||\n"; /* indeed nasty way :p */ putstr(tab); } int move_normally() { char bffr[10]; int x; int y; x = 0; y = 0; while (42 && x <= 6 && y <= 3) { read(0, bffr, 10); putstr(tgoto(tgetstr("cm", null), x, y); if (bffr[2]

Monkey patching use_ssl= method works for Net:HTTP but not for OpenURI in Ruby 1.9.3? -

background: ruby 1.9.3 rails 3.2.16 windows 7 x64 issue i'm trying fix infamous ssl_connect returned=1 errno=0 state=sslv3 read server certificate b: certificate verify failed error including certificates in each http request perform. monkey patch net::http#use_ssl= : # lib/gem_ext/net_http.rb require 'open-uri' require 'net/https' module net class http alias_method :original_use_ssl=, :use_ssl= def use_ssl=(flag) store = openssl::x509::store.new store.set_default_paths # auto-include system cas. dir[rails.root + 'config/certificates/*'].each |cert| puts "adding cert: #{cert}" store.add_cert(openssl::x509::certificate.new(file.read(cert))) end self.cert_store = store self.verify_mode = openssl::ssl::verify_peer self.original_use_ssl = flag end end end now, requests performed using net::http , example: > uri = uri.parse('https://internal-app/

Android animation and move view out of its layout -

i have gridview, want move 1 of imageview inside 1 of item of gridview, want move on screen using translateanimation , put in corner of screen example. i'm fine animation, problem view can't moved out of layout without disappearing. totally normal. my question is: best way animate view wherever want on screen ? should add the main layout of activity , move it? or there way similar ios cliptobounds ? thanks! okay found android:clipchildren="false" , , works

linux - Executing processes with python by subprocess library -

i've created software in python should schedule several commands shell. (ps: i'm working on linux) way, i've created following function launch processes: def exec_command(cmd): process = subprocess.popen(cmd, stdout=subprocess.pipe, shell=true, preexec_fn=os.setsid) pid = process.pid print '----------launched process pid: ', pid return pid after use pid check if process goes on zombie's state , in case kill it. sometime works fine there case in process launched doesn't anything. process i'm talking is: sh /home/ubuntu/programs/data-integration/kitchen.sh -file=/home/ubuntu/trasformazioneavm/jobavm.kjb -level=basic -param:processname=avm if launch shell works if function can see process on system monitor (or shell "top" command) nothing appens (i check memory usage , cpu usage high not in case). body has ideas ? stdout=subprocess.pipe here culprit. you're redirecting child process output pipe, aren't reading pip

Could not connect to amazon my sql rds using php -

i connecting amazon rds make web services using php not connect servers here code <?php try{ $dbhost = 'myrds.cjahuqpumuov.us-east-1.rds.amazonaws.com:3306'; $username = 'myname'; $password = 'mypassword'; $dbname = 'mydb'; $link = mysql_connect($dbhost, $username, $password, $dbname); mysql_select_db($dbname); } catch(exception e){ echo e } ?> parse error: syntax error, unexpected t_string, expecting t_variable in /home/content/i/h/u/ihus235/html/cs/pah_brd_v1/productivo/selecttest.php on line 17 error trace warning: mysql_connect() [function.mysql-connect]: lost connection mysql server @ 'reading initial communication packet', system error: 110 in /home/content/i/h/u/ihus235/html/cs/pah_brd_v1/productivo/selecttest.php on line 12 warning: mysql_select_db() [function.mysql-select-db]: can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/i/h/u/ihus235/html/cs/pah_b

Is there a way to move plugins in django-cms from one page to another? -

i have had closer django-cms. seems there no way manage plugins page-independently. i love have admin page move, copy, edit , categorize plugins without having create new ones each page. what appropriate way implement this, e.g. creating new cmsplugin? we have in mind... , cal presets. the idea follows: you can create plugin preset out of existing plugin , saved in plugin preset admin. then can drag , drop sidebar page list of such presets. this still needs implementation though.