Posts

Showing posts from June, 2013

C - able to read an EVP encrypted file but when I store it in a char array, everything disappears -

i have evp encrypted file want send on socket. however, realised nothing being sent because seems nothing stored in array read file into, sure there stored since able decrypt after reading file. the code snippet below part boggling me. file *fp; long lsize; fp = fopen ( evp_file , "rb" ); fseek(fp, 0l, seek_end); int fsize = ftell(fp); fseek(fp, 0l, seek_set); unsigned char *indata = malloc(fsize); fread(indata,sizeof(char),fsize, fp); printf("%s\n", indata); // printing indata returns me nothing @ //then decryption //decrypting indata works! , want. as commented, no output when print indata. there doing wrong here? need store in array can send on socket. ps. when use plain text file, works fine. thanks in advance!! if it's text data ( ascii characters, perhaps utf-8, not binary ) need nul terminate buffer, add 1 byte malloc() ed size , then indata[fsize] = '\0';

lftp not able to resolve alias value defined in .lftprc file -

i have defined aliases in config file .lftprc below- alias ftp_server_x 99.999.999.999 from command prompt when run lftp -e "open -u user,password 99.999.999.999" it connects server. but when try use alias name in command lftp -e "open -u user,password ftp_server_x" i error 'open: ftp_server_x: name or service not known' need in resolving error. lftp aliases commands, not host names. try bookmarks instead: bookmark add ftp_server_x 99.99.99.99

Draw Line chart in jQuery using data from an AJAX request -

Image
i trying generate line chart in jquery. here ajax request code: var querystring = window.location.search; $.ajax({ url: '/turnover/drawlinechart'+ querystring, cache: false, type: 'post', datatype: 'json', success: function (response) { ????????? }, } }); here data in response: how can draw line chart using data? here x-axis data static (jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec). in response have y-axis data. please me. thank you.

Changing INSTALLDIR from registry (working with InstallShield) -

i'm working installshield , creating installation addon. must read registry program x has been installed , add necessary files found location. problem : on 32bit computer registry found under hkeylm\software\x. on 64bit computer registry found under hkeylm\software\wow6432node\x. so how can read registry correct registry value , set found value installdir? firstly find if target machine 64 or 32 bit machine.you can use sysinfo.biswow64 similar commands. once found run reg commands thru if loop , achieve goal.

excel - Angle of rotation for a data label along a line on a chart -

i have chart plots flow vs power. want adjust rotation of data label sits on top of line on chart match slope of line. first point plotted @ 25000, 87000; second point plotted @ 53000, 182000. if manually count gridlines , tangent(theta) = opposite / adj answer makes sense ~22º if use actual data graph angle wrong. eyeballing graph, looks 22º using plot data gives me 73º. it seems confusing opposite , adj. 73º right answer these data. you have 2 points p1 = (x1, y1) , p2 = (x2, y2) . segment p1p2 has slope angle (in radians) a = atan2(y2 - y1, x2 - x1) (i don't know exactly, whether atan2 or arctan2 function exists in vba math library - a discussion found)

algorithm - How to effectively distribute points on plane -

i have plane (screen) width , height (monitor resolution, not square). , i'd distribute points on plane (approximately) same distance each other. for example: 1 point in middle, 2 points in middle of y axis, , x axis divided 3 3 points may triangle, if sceen wide enough, thay can alighned in same y 4 second part of above, or rectangle.. etc 8 points max is there algorithm this? thank time! edit: same distance each other , plane border edit2: compute centers of mass groups of objects on behavior simulate on plane. depending on precision want: you can stochasticaly correct answer poisson disk sampling. specifically, poisson disk sampling random sampling such no points closer specified radius. such thing can efficiently (linear time) implemented in high dimension - e.g. : c++ code robert bridson : http://www.cs.ubc.ca/~rbridson/download/curlnoise.tar.gz implementing paper http://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph07-poissondisk.pdf you

c# - how to read data from the ViewModel -

i unit_price , quantity actionresult index. any appreciated model product public class product { public product() { productsdetails = new hashset<productdetails>;(); } [key]//[required] public int id_product { get; set; } [required] public int id_subcategory { get; set; } [required] public int id_category { get; set; } // [stringlength(50)] public string product_name { get; set; } //public byte photo_products { get; set; } // id_subcategory //public virtual productdetails productdetails { get; set; } [foreignkey("id_subcategory")] public subcategory subcategories { get; set; } [foreignkey("id_category")] public virtual category categories { get; set; } public virtual icollection<productdetails> productsdetails { get; set; } public virtual icollection<orderdetails> ordersdetails { get; set; } } model productdetails [table("product_details&qu

graphics - How to create Lines connecting two points in R -

Image
is there way create lines in r connecting 2 points? aware of lines(), function, creates line segment looking infinite length line. here's example of martha's suggestion: set.seed(1) x <- runif(2) y <- runif(2) # function segmentinf <- function(xs, ys){ fit <- lm(ys~xs) abline(fit) } plot(x,y) segmentinf(x,y)

java - Q: Simple Loop Tracing -

i'm not sure happens "num2", "num1" times every number 1-4 times every number 1-4 have no idea "num2" int num1 = 0; int num2 = 0: (var = 0; <= 4; i++){ num1 = * i; num2 += num1; system.out.println(num1 + " "); } system.out.println(num2); so question trace "num2"? appreciated! in case, following true: num1 equal whatever index is, multiplied itself. therefore run on 0, 1, 2, 3 , 4 starts 0 , runs until less or equal 4. therefore, num1 be: 1) 0 * 0 = 0 2) 1 * 1 = 1 3) 2 * 2 = 4 4) 3 * 3 = 9 5) 4 * 4 = 16 then num2 calculates sum of each of these, be: 0 + 1 + 4 + 9 + 16 = 30 this broken into: before loop: num2 = 0 1) num2 = 0 + 0 = 0 2) num2 = 0 + 1 = 1 3) num2 = 1 + 4 = 5 4) num2 = 5 + 9 = 14 5) num2 = 14 + 16 = 30 it adding whatever num1 total far. hope clarifes bit. edit: as sharonbn has mentioned, var not valid type in java, should 'int'. also, hav

Crystal reports selecting record that contain empty strings or "null" -

i have report field called jobno there records have "null" the cell value , have empty string "". there field called accntno im selecting in same selection formula. this have tried without success in selection formula crystal reports. {accnt.accno} = "7015" , {accnt.jobno} = "" or {accnt.jobno} isnull any apreciated selection formula doesn't work expected, sometimes. i suppose work {accnt.accno} = "7015" , ( isnull({accnt.jobno}) or {accnt.jobno} = "" ) first of put parenthesis on 'or' clause. but, strangest thing, isnull clause must evaluated before other comparison clauses .

php - How can I efficiently deliver large number of assets (images)? -

i have single web page responsible delivery on 500 images browser. sizes vary between 50kb , 80kb. the server being used nginx , there varnish proxy being used. now, how can make process efficient can possibly be? i have 2 thoughts , imput experienced people here. my thoughts are: set multiple subdomains , serve batches these. believe best number of subdomains use 12. use ajax load batches browser when needed user scrolls down. i think option 2 here doesn't solve problem; gets around it. focus on making process efficient , fastest can possibly be. you're loading 1 page 500*50kb ~ 25mb of data, that's insane pagesize! no matter that's gonna feel slow compared average pagesisze of around 1 mb currently . loading of dynamically via ajax when needed makes way more sense. alternatively split multiple plages. if you're set on 1 giant non-dynamic page then: make sure have cache headers set allow caching (won't hep first load) the m

Can not add the same measure twice on Python unit test report -

after upgrade following versions: sonar 5.2 sonar runner 2.4 python plugin 1.5 my test reports not being processed correctly when have more 1 test file in same package, example: test-notas_leitores.tests.notasleitoresmodelstest-20160107114942.xml test-notas_leitores.tests.paginanotasleitorestest-20160107114942.xml i error: error: sonar during error runner execution error: unable run sonar error: caused by: can not add same measure twice on org.sonar.api.resources.file@b497091[key=notas_leitores/tests.py,path=notas_leitores/tests.py,filename=tests.py,language=python]: org.sonar.api.measures.measure@27d4561[metrickey=skipped_tests,metric=metric[id=<null>,key=skipped_tests,description=number of skipped unit tests, type = int, direction = -1, domain = tests, name = skipped unit tests,qualitative=true,usermanaged=false,enabled=true,worstvalue=<null>,bestvalue=0.0,optimizedbestvalue=true,hidden=false,deletehistoricaldata=false],value=0.0,data=<null>,descripti

java - find path between root and multiple of 5 -

i facing hard time implement program finding path node b-tree root multiple of 5. example: 12 / \ 4 7 /\ /\ 5 3 4 10 consider tree. program should print 12 -> 4 -> 5 12 -> 7 -> 10 edit: yes have tried , following algo following: traverse in-order , compare values multiple of 5. if is, start adding nodes in linkedlist , return list back. approach works if have 1 multiple of 5. if there more multiples, fails. following have tried: linkedlist<integer> getpaths(node parent, int multiple){ if(parent == null) return null; linkedlist list = new linkedlist(); list = getpaths(parent.getleftchild(), 5); if(parent.getsid() % multiple == 0){ list.add(parent.getsid()); return list; } list = getpaths(parent.getrightchild(),5); if(list != null) list.add(parent.getsid()); return list; } the problem is, when do: list = getpaths(parent.getrightchild(), 5);

ios - Why does my GitHub CocoaPod project list the build as invalid -

i've released first cocoapod see 1 , can't build "build invalid" - how show build passing? [![enter image description here][2]][2] click on "build invalid" box see specific error. me, getting "repository not found" error travis ci , did not have .travis.yml file.

java - Restart jar with root privileges on most (if not all) Linux distributions -

i developing java application requires root/administrator privileges function properly. if user not start application such privileges, notify user , restart program these privileges. have figured out how on windows , os x cannot find way on linux systems. on windows, found program elevates command pass it, on os x possible through running simple applescript on linux, there no portable way it. my plan use gksu discovered not installed default on linux systems , neither debian cannot install either. there portable way restart application root privileges on most, if not all, linux distros , flavours in java? edit: able check if program running administrator on platforms. you're not going able cleanly on linux** because idea of escalating privileges doesn't exist in linux. sudo de facto answer privileged execution, that's doing running single command root, conceptually distinct running command same user escalated privileges. consider fact baseline sudo (no

javascript - Setting the style.maxWidth from a variable -

my cod this: <img src="img.png"> <dd id="123">comment</dd> <script> var img = new image(); img.onload = function () { alert(this.width); } img.src = 'img.png'; </script> this alerts window width of img.png. question is: how set width value element need. something like: document.getelementbyid('123').style.maxwidth = this.width; instead of: alert(this.width); the width dom property of image going number. the css max-width property accepts length value. you need add units number. = this.width + "px";

ios - APNS Feedback Service - is it still alive? -

when googleing ios device token expiration topic you'll find many notices apple feedback service . it's polling of device token expiration when feedback service told particular device token expired means there no chance deliver push-notification device token . should mark them expired . now couldn't find feedback service mention in actual apple docs. service deprecated? if so, why pushsharp , pushd libraries still use it? , if so, next? read send status on google , microsoft platforms?

java - Dragging BufferedImage in JPanel -

Image
i have jpanel inside jframe , there more 1 bufferedimages in jpanel this. now question how can move bufferedimages inside jpanel? more how add mouseeventhandler buffered images?. though can drag jpanel code below can't figure out how drag buffered images inside jpanel. help. i have 3 classes this mainwindow.java public class mainwindow extends jframe { public static void main(string[] args) { eventqueue.invokelater(new runnable() { public void run() { try { mainwindow window = new mainwindow(); window.frame.setvisible(true); } catch (exception e) { } } }); } public mainwindow() { jframe frame = new jframe(); .... // other code of jframe jpanel panel_3 = new jpanel(); .... // other code of jpanel

How can I disable Chrome paste menu on touch? -

i developing app run in chrome (47.0.2526.106 m) , use 3rd party keyboard. chrome presents small paste menu when touch text field. know how can disabled? thanks! you can add html attribute each input solve problem. if don't solution, can use javascript achieve looking for.

clearcase - view-extended path example for another windows machine in the domain -

assume there 2 windows client machine running clearcase dynamic view , connected same domain , logged in same domain account. windows machine 1 has view1 windows machine 2 has view2 using view-extended pathname possible access files/directories of view2 machine1? if yes, how? thank you. not know of: dynamic views using mvfs (multiversion filesystem) not shareable on network. can map view drive letter, surprised if drive shared windows. mentioned in " about dynamic views on windows ": all dynamic views started on windows client available local mvfs drive, default m drive. the alternative start view2 on machine1 note extended pathname , can indeed access version referenced view2 view1. won't able access private elements , checked out elements (stored in view2 view storage).

compare data in 2 excel spreadsheets and then highlight common data in one excel -

i have excel sheet 2 tabs . in each tab there text written. i need compare values in column_1 in sheet 1 values in column_2 of sheet2 , in case similar values present need highlight text in sheet1. also, suppose copy data sheet1 sheet2 (column_2) shee1(column_1) need highlighted. note : 1. should work via conditional formatting or other formulas. cannot use macro don't mention copy sheet1 , sheet2 in 1 sheet , apply formula. don't want use approach select column_1 in sheet 1 , home > styles - conditional formatting, new rule..., use formula determine cells format , format values formula true: : =countif(sheet2!$b:$b,a1) format... , select colour fill (highlight) of choice, ok , ok . when copying column_1 in sheet 1 sheet2 formatting may transferred unless choice made not to.

java - Split string delimited by comma without respect to commas in brackets -

i've got string like s="abc, 3rncd (23uh, sdfuh), 32h(q23q)89 (as), dwe8h, edt (1,wer,345,rtz,tr t), nope"; and want split string string[] parts={"abc", "3rncd (23uh, sdfuh)", "32h(q23q)89 (as)", "dwe8h", "edt (1,wer,345,rtz,tr t)", "nope"}; if call s.split(",") after trimming different result because in of string, example "3rncd (23uh, sdfuh)" there still comma. don't want commas in brackets. there elegant way solve problem? assuming ( , ) not nested , unescaped. can use split using: string[] arr = input.split(",(?![^()]*\\))\\s*"); regex demo ,(?![^()]*\)) match comma if not followed non-parentheses text , ) , ignoring commas inside ( , ) .

linux - redis-cli do a ttl command with a pattern -

i want display ttl of keys have in redis @ once redis-cli shell. i tried things redis-cli keys * | xargs redis-cli ttl but it's not working, keep getting error: (error) err wrong number of arguments 'ttl' command if you're using bash, careful globbing on "*". also, xargs need replace-string this: redis-cli keys '*' | xargs -i{} redis-cli ttl {}

How to read swift headers -

when cmd click split function in xcode, takes me header file. reads public func split(maxsplit: int = default, allowemptyslices: bool = default, @noescape isseparator: (self.generator.element) throws -> bool) rethrows -> [self.subsequence] how following implementation work above declaration? somestring.characters.split { $0 == "." } let's break down: public func split(maxsplit: int = default, allowemptyslices: bool = default, @noescape isseparator: (self.generator.element) throws -> bool) rethrows -> [self.subsequence] maxsplit : first parameter, maxsplit , allows specify maximum number of pieces sequence split into. default int.max . allowemptyslices : second parameter, allowemptyslices specifies whether or not 2 consecutive separators in sequence should lead empty slice. default false . example if had string, "a..b" , , split on . character, end either 2 ( ["a", "b"] ) or 3 ( ["a", "&quo

ember.js - How to know whether a method is a call made by me thgh code or its from observer -

i have method in view following. testmethod : function() { //run code }.observes('property1') this method can either trigerred directly calling or triggered property1 observer. possible know inside method, way call getting triggered. thanks when observer called, receives 2 arguments: controller object, , observed property has changed , triggered observer. so can check this: testmethod : function() { if(arguments.length === 2 && arguments[1] === 'property1'){ // you're triggered property observer } else { // triggered directly } }.observes('property1') this, of course, can spoofed caller..

javascript - Vue JS and model binding in tables -

why not possible bind model via v-model within table this: <table class="table"> <thead> <th>select</th> <th>responder id</th> <th>heading 2</th> </thead> <tbody> <tr v-for="responder in responders"> <td v-model="selected" @click="selectresponder(responder)"><span class="glyphicon glyphicon-bullhorn"></span></td> <td>@{{ responder.userreference }}</td> </tr> </tbody> </table> i want achieve, when user clicks glyphicon in table row, selected element bind variable in javascript. v-model used bind variable type of form input, , doesn't apply <td> element. @click method can describing though: //in vue instance ... methods:{ selectresponder(responder){ //either... responder.selected = true; //or ma

SQL Server Delete Trigger is Firing When Transaction Rolled Back -

i have strange situation. in .net wrapping number of table inserts in transaction using transactionscope. have triggers each of insert, delete, update log history in table. expected, if exception occurs, transaction rolled , inserts removed. strange thing causing delete trigger run, , of delete log records in history table. should happening , there way avoid it?

tomcat - Subdomain to html -

first of want i'm new workings of dns , server behavior. now purchased domain name, redirect vps ip adress. on linux vps have 2 folders html files: /var/www/html/home (containing): home.html /var/www/html/admin (containing): admin.html since on dns can type in ip adress don't know how redirect following: admin.domain.nl -> html/admin/admin.html domain.nl -> html/home/home.html i want have working before launching java ee application. you don't type of routing using dns. dns maps hostname ip addresses, dns configuration (using made-up ip addresses): domain.nl 123.45.67.89 admin.domain.nl cname domain.nl. then configure web server (apache?) serve different content based on hostname included in http request. called " virtual hosts " in apache. how set off-topic stackoverflow

Android Stuido is not fitting the screen -

Image
i updated drivers of pc. tried resolutions, still problem exists. not able access buttons bellow. please help. here screen shot, trying create new project. this bug has plagued android studio users months running on lower resolutions, such 1366 x 768 . window in question cannot resized. to progress next screen, press enter . edit : i can experience bug exists in version 1.3, can't confirm if exists in 1.4.

actionscript 3 - Toggling one button to adjust two values -

i'm designing virtual simulation of physical machine controller has few face buttons. i'm trying arrow buttons scroll through menu , modify selected value when enter button clicked. right now, functions want to, when toggles menu control , scroll through, next value on menu (i.e. temperature 1,2,3 ) overwritten previous. snippet of code controls selected/unselected functionality, in enter frame event listener: screenshot //--switches between scroll , edit--// if (changerswitch == true) { changermenu = changer; minvalue = menumin; maxvalue = menumax; screenmain.selectedshade.visible = false; screensmall.selectedshade.visible = false; } else { changervalue = changer; minvalue = valuemin; maxvalue = valuemax; screenmain.selectedshade.visible = true; screensmall.selectedshade.visible = true; } switch(mainmenuindex) { case 0: break; case 1: temperature1 = changervalue; break; case 2: temperature2 = changervalue;

r - Select groups which have more than one variable in them -

this question has answer here: remove ids occur x times r 2 answers simple question. let's have dataframe looks this: data.frame (species=c(a,a,b,c,c,d),dbh=c(5,4,7,1,3,6)) and want exclude species b , d because occur once, how can that? this can done using either base r or using other packages. data.table , convert 'data.frame' data.table ( setdt(df1) ), grouped 'species', if number of rows greater 1 ( .n>1 ) , subset of data.table ( .sd ) library(data.table) setdt(df1)[, if(.n>1) .sd, species] or dplyr , use filter after grouping. library(dplyr) df1 %>% group_by(species) %>% filter(n()>1) the base r function ave can used well. group 'species', length , convert logical vector , subset dataset. df1[with(df1, ave(dbh, species, fun=length)>1),] or can use table frequency o

Going out of memory for python dictionary when the numbers are integer -

i have python code suppose read large files dictionary in memory , operations. puzzles me in 1 case goes out of memory: when values in file integer... the structure of file this: string value_1 .... value_n the files have varies in size 2g 40g. have 50g memory try read file in. when have this: string 0.001334 0.001473 -0.001277 -0.001093 0.000456 0.001007 0.000314 ... n=100 , number of rows equal 10m, i'll able read memory relatively fast. file size 10g. however, when have string 4 -2 3 1 1 1 ... same dimension (n=100) , same number of rows, i'm not able read memory. for line in f: tokens = line.strip().split() if len(tokens) <= 5: #ignore w2v first line continue word = tokens[0] number_of_columns = len(tokens)-1 features = {} dim, val in enumerate(tokens[1:]): val = float(val) features[dim] = val matrix[word] = features this result killed in second case while work in first case. i know not answer que

.NET/C# Interop to Python -

my backend written in .net/c#, have requirement need execute python scripts passing context .net side of house. these queued in background task engine called hangfire running windows service. i did little digging , found ironpython , however, after implementing failed support many of pypi python packages need execute inside script. secondly, looked @ python.net embedded interpreter embeds or extends cpython. cpython can run scripts/etc needed, however, found opening/closing python interpreter time can create quite few memory leaks , there threading constraints there too. see docs of details. i'm wondering if interopt , embedding python in .net idea. i'm wondering if making python own execution engine using celery , marshalling data between 2 using protobufs better solution? adds more complexity , additional task engine stack too. i wondering if else had ideas/feedback/experiences trying accomplishing similar? thanks! i argue pythonnet best option: e

UIBarButtons disappeared in iOS 9.2 -

i have upgraded 1 of apps under development ios 9.2 , have found navigationbar uibarbuttons have disappeared , not shown on navigation bar. btw: i'm using uibarbutton custom class called bbbadgebarbuttonitem here update 1 here snippet code used add uibarbuttonitem // add search button uiimage* searchbtnimg = [uiimage imagenamed:@"searchbarbutton"]; searchbtnimg = [self ipmaskedimage:searchbtnimg color:[uicolor pddappselectediconcolor]]; cgrect frame = cgrectmake(0, 0,searchbtnimg.size.width,searchbtnimg.size.height); uibutton* searchbtn = [[uibutton alloc] initwithframe:frame]; [searchbtn setbackgroundimage:searchbtnimg forstate:uicontrolstatenormal]; [searchbtn addtarget:self action:@selector(_searchcontent) forcontrolevents:uicontroleventtouchdown]; self.searchbarbuttonitem = [[bbbadgebarbuttonitem alloc] initwithcustomuibutton:searchbtn]; self.searchbarbuttonitem.shouldhidebadgeatzero = yes; self.searchbarbuttonitem.badgevalue = @"0"; self.navi

database - Teradata SQL : insert random data for testing into Table -

i trying create random data , insert table. right thinking what'd efficient approaches done. e.g. create volatile table mytb , no fallback, no journal ( c1 integer not null c2 varchar (50) not null , c3 d1 date not null, c4 d2 date not null ) data primary index ( c1) on commit preserve rows; what want insert value randomly x iterations specific list or range of each column value . e.g. c1 range between 30 , 3000000 c2 list ( 'approved','pending','unknown','disputed','wip','processed','pre-processed','denied' ) etc c3 date between 01-01-1999 12-31-2015 etc 1 million iterations i'd insert random values these columns , create skew values- there should abundance of these values vs rest. has had dig @ before . best way - recursive q logic ? i use random produce test data: select random(30,3000000) c1, case random(1,8) when 1 'approved' when 2 'pending'

android - Connect to specific network, disable WiFi if the network doesn't exist (My issue in the second part) -

i'm trying add connect specific network, i've made editbox, user enter network wannna connect to, after pressing done, save in sharedpreference, , string , store it. code deleted, use code in answer . if initial case connecting network if exist, have boolean , check after while loop see if need disable wifi. like: list<wificonfiguration> list = wifimanager.getconfigurednetworks(); boolean connected = false; for( wificonfiguration : list ) { if(i.ssid != null && i.ssid.equalsignorecase("\"" + desiredssid + "\"")) { log.d("in", "in!"); wifimanager.disconnect(); wifimanager.enablenetwork(i.networkid, true); wifimanager.reconnect(); connected = true; break; } if(!connected){wifimanager.setwifienabled(false);}

c++ - parsing 3 floats for glm::vec3 using boost::spirit::qi (error_invalid_expression) -

i can parse 1 float , print it. ( test1 , test2 ) somehow unable build rule parses 3 floats. final goal parse 3 floats , save them glm::vec3 . my rule seems incorrect: qi::lexeme[qi::float_ << ' ' << qi::float_ << ' ' << qi::float_] i not sure if using boost_fusion_adapt_struct correctly here source show came far: #include <iostream> #include <string> #include <glm\glm.hpp> #include <boost\spirit\include\qi.hpp> #include <boost\fusion\include\adapt_struct.hpp> namespace qi = boost::spirit::qi; void test1() { std::string test = "1.2"; auto = test.begin(); if (qi::phrase_parse(it, test.end(), qi::float_, qi::space) && (it == test.end())) std::cout << "test 1 ok" << std::endl; else std::cout << "test 1 not ok" << std::endl; } void test2() { std::string test = "1.2"; auto = test.begin();

javascript - Protractor - Wait for multiple elements -

i trying wait multiple elements on page, don't know how many there there @ least one. understand waiting single element using following, works fine. var ec = protractor.expectedconditions; browser.wait(ec.presenceof(element(by.css("h3[title='test form']"))), 10000); expect(element(by.css("h3[title='test form']")).ispresent()).tobetruthy(); i wanted change wait multiple elements , tried below (adding .all element). var ec = protractor.expectedconditions; browser.wait(ec.presenceof(element.all(by.css("h3[title='test form']"))), 10000); expect(element.all(by.css("h3[title='test form']")).ispresent()).tobetruthy(); unfortunately when try cannot read property 'bind' of undefined any on appreciated. p.s. newbie protracor , quirks. presenceof expects single element ( elementfinder ) passed in. you need custom expected condition wait for. if understand correctly,

excel - Error Resetting not working -

i writing macro renumber points , lines. in following code, err.number not resetting , code breaks @ 2nd instance of error. how fix this? s = 0 ss = 0 surfaces = y ss = ss + 1 handler: s = s + 1 on error goto handler set hybridbodyshape1 = hybridbodyshapes1.item("line_extract_" & s) hybridbodyshape1.name = "line_extract_" & ss set hybridbodyshape1 = hybridbodyshapes1.item("point_extract_" & s) hybridbodyshape1.name = "point_extract_" & ss on error goto 0 loop until s = surfaces - 1 i don't know expect loop (or error "handler") do, should change implementation this: on error resume next if err.number = 0 ss = ss + 1 err.clear s = s + 1 set hybridbodyshape1 = hybridbodyshapes1.item("line_extract_" & s) hybridbodyshape1.name = "line_extract_" & ss if err.number = 0 set hybridbodyshape1 = hybridbodyshapes1

r - How to center an image in a shiny app? -

i playing app: http://shiny.rstudio.com/gallery/plot-plus-three-columns.html i inserting picture on top row inserting beneath 'title' list(img(src="nfl_header.jpg", width = 400, align = "center")), but left justified, align doesn't seem anything. how specify center justification image? from yihui himself: the align attribute of <img /> not need. different thing ( http://www.w3schools.com/tags/att_img_align.asp ). can use style="display: block; margin-left: auto; margin-right: auto;" center image. or div(img(...), style="text-align: center;") .

html - Getting actions from WebBrowser control in C# -

is possible - example, have form webbrowser control , local html page has elements in it. when user clicks on button in web page, form (for example, close application). there way connect dom actions form events , how? yes, can use webbrowser.objectforscripting property set object exposed javascript window.external . within javascript can call methods on object. if need first inject javascript page hook stuff in html page didn't write, webbrowser.documentcompleted event, can inject javascript webbrowser.document so: private void webbrowser_documentcompleted(object sender, webbrowserdocumentcompletedeventargs e) { try { maindoc = webbrowser.document; if (maindoc != null) { htmlelementcollection heads = maindoc.getelementsbytagname("head"); htmlelement scriptel = maindoc.createelement("script"); ihtmlscriptelement el = (ihtmlscriptelement)scriptel.domelement; el.text

c++ - C++11 atomic memory ordering - is this a correct usage of relaxed (release-consume) ordering? -

i have made port c++11 using std::atomic of triple buffer used concurrency sync mechanism. idea behind thread sync approach producer-consumer situation have producer running faster consumer, triple buffering can give benefits since producer thread won't "slowed" down having wait consumer. in case, have physics thread updated @ ~120fps, , render thread running @ ~60fps. obviously, want render thread gets recent state possible, know skipping lot of frames physics thread, because of difference in rates. on other hand, want physics thread maintain constant update rate , not limited slower render thread locking data. the original c code made remis-thoughts , full explanation in blog . encourage interested in reading further understanding of original implementation. my implementation can found here . the basic idea have array 3 positions (buffers) , atomic flag compare-and-swapped define array elements correspond state, @ given time. way, 1 atomic variable used model

tomcat - Can plain Java object utilize/capture/include JSP output? -

i need send emails formatted html. seems html email counts "view" element makes sense render using jsp. however, emailer task written in pure java. how can jsp output java? i.e. envision: emailbody.jsp: <c:out var="invoicebody"> <lots of html> ${invoice.price} etc... </c:out> emailsend.java: setup db connection setup email call emailbody.jsp email.body = invoicebody email.send etc... something that... right scraping through http server seems wrong. what best way format html emails? using tomcat 7, servlet 3.0... thanks you can use scripting language mvel populate html file want send out email. check mvel 2.0 templating guide i hope puts in right direction. there other alternatives szymon biliński pointed out.listing them below freemarker velocity

ruby on rails - DRYing out the path.rb -

i'm new cucumber, , i'd ask how dry out code (which not contain errors): when /^the user page$/ users_path when /^the review page$/ reviews_path i tried use regexp like when /^the (.+) page$/ $1.to_s+'s_path' but apparently wrong. in advance! solution (based on answer aledalgrande ): when /^the (.+) page$/ send("#{$1}s_path") this should work: when /^the "(.+)" page$/ |destination| send("#{destination}s_path") end

python - Keyerror in reading csv file -

i trying write script pass file name argument shell script python script , python script processes script. it giving me keyerror if run same script hardcoding file name works fine. #!/bin/sh lockfile=./test.txt if [ -e ${lockfile} ] && kill -0 `cat ${lockfile}`; echo "already running" exit fi trap "rm -f ${lockfile}; exit" int term exit echo $$ > ${lockfile} # stuff files=/home/sugoi/script/csv/* file in $files python ./csvtest.py $file #mv $file ./archive done rm -f ${lockfile} exit python: from pymongo import mongoclient import csv import json import sys client = mongoclient() db = client.test arg in sys.argv: try: csvfile = open(arg, 'r')#if hardcode file name here works fine except ioerror e: #write error log sys.exit(100) reader = csv.dictreader(csvfile) header=reader.next() each in reader: row={} field in header: row[field]=each[field] db.test.update({&q

ruby - Sum integers between two numbers with a recursive method -

i want sum integers between , including min , max recursive method. example: min = 1, max= 5, sum = 1 + 2 + 3 + 4 + 5 my issue can't find how stop "loop" created recursivity: def sum_recursive(min, max) return min if #i don't know how stop min += (min + 1) sum_recursive(min, max) end i have used counter, need create variable reset original value each time function calls itself. is there way ? or different way organize method ? this should give correct answer: def sum_recursive(min, max) return min if min == max min + sum_recursive(min + 1, max) end the process simple enough: sum_recursive(1, 3) → 1 + sum_recursive(2, 3) → 1 + (2 + sum_recursive(3, 3)) → 1 + (2 + (3))

jquery masonry - Disable isotope filter preloading? -

i using http://isotope.metafizzy.co/ - filter portfolio on website. because getting bit heavy on loading (plenty of images) want disable pre-loading of filters (categories) , make them load when each category clicked. ideas on how that? example: right images categories preloaded, when navigate 1 category other there no wait, want change per description above.

Projectile bouncing off curved surface - Pygame, Python 3 -

Image
i working on (top-down) game requires code bounce projectile off of circular surface. the way work when projectile hits surface a hypothetical line drawn center of circle which used normal calculate angle of reflection of new trajectory. physics (such gravity) unnecessary. there more or less simple way of doing that? reflect line segment off circle. this reflexed line segment off circle. length of reflected line segment , incoming line segment circle intercept equal length of original line segment. if want reflected ray stop calculations when reflected vector has been worked out. assumes incoming line segment starts outside circle. if line starts inside line fails. can check if line starts inside circle getting distance circle center line start if less circle radius line starts inside circle. this in pseudo code don't php. sqrt() function sqrt of number. the incoming ray line segment. line.x1, line.y1 start , x2,y2 end line x1,y1,x2,y2 the circle x,y

javascript - HTC One X KeyCode always returns zero -

i have need validate text entered textbox using javascript before it's sent off third party acted upon. to this, i'm using browserevent.keycode parameter keycode sent browser on key-up event, validating code whether it's allowed in textbox or not. this works fine across devices i've tested, apart chrome on htc 1 x. i've found annoying differences between various android , ios devices, return can work with. htc 1 x, however, returns 0 every key press apart backspace , enter keys, return 8 , 13 respectively. i've tried event.keycode , event.charcode , event.which browserevent.keycode , browserevent.charcode and browserevent.which codes, , returned 0 . basically, i'm stuck. have idea why keycode returned 0 on device, , how can detect keycode ? although doesn't answer immediate question, used of ideas lukas knuth gave me solve it. the process keycode of 0 caught , handed function runs contents of input box through

javascript - How to have a single textfield for exp-month and exp-year -

i'm using stripe cc processing , used stripe example form , js code. form has 2 separate fields expiration month , year. each has data-stripe="exp-month" , data-stripe="exp-year" i'd use 1 textfield month , year , have user enter input like: 10/2020 question since stripe reads data based on data-stripe attribute. there way can parse input 10/2020 1 textfield , programmatically set data-stripe attributes? i'm not sure how glued , being sent, have hidden input fields data-stripe="exp-month/year" attributes , split visible input value on / , set hidden values. here rather basic jsbin can see month , year in console output.

javascript - table elements not showing in IE -

i'm new javascript , i'm having strange issue. javascript generated table elements not working in ie, worked fine in every other browser i've tried. managed isolate issue adding child elements in js: var table = document.createelement("table"); var tabler = document.createelement("tr"); var tab = document.createelement("td"); var node = document.createtextnode('test'); textdiv.appendchild(table); table.appendchild(tabler); tabler.appendchild(tab); tab.appendchild(node); the above creates table single text element in chrome, in ie blank. i did experimenting , found code: var table = document.createelement("table"); var tabler = document.createelement("tr"); var tab = document.createelement("td"); var node = document.createtextnode('test'); textdiv.appendchild(table.appendchild(tabler.appendchild(tab.appendchild(node)))); does work in both ie , chrome, table being formatted align center,

c# - how to compare ImageVerifier text with the textbox value using comparevalidator in asp.net? -

i using passwordrecoverycontrol in asp.net , have placed imageverifier in question template of control has captcha image. want compare imageverifier text , text user enters in textbox below image using comparevalidator. cannot in code behind because lot of methods run once page loads , want avoid if text doesn't match. please check below link http://www.dotnetfunda.com/articles/show/2019/passwordrecovery-with-captcha cheers, vijay

ios - Sort NSMutableArray with custom objects -

i have ios app nsmutablearray contains many rows worth of data (split 3 segments) - shown below: [pfuser object, stringdata, floatvalue] . . 4.3 . . 5.9 . . 1.1 . . 9.32 . . 0.024 the above diagram shows how array split , data types stored in array. data types not keys or anything. can't valueforkey . an example of array looks like: @[@[userobject, @"hello", @234.1441], @[userobject, @"sdfsg", @94.33], @[userobject, @"wrfdo", @24.897] ]; so example above can see have arrays in arrays. i sort array reading 3 segment contains float values. how can this? have looked online , read lot using nssortdescriptor problem have examples seem use simple strings or array numbers only. is there way use nssortdescriptor in array custom objects mine? you can use sortusingcomparator: [array sort

plsql - Oracle: Pipe Query Results Without Knowing The Column Types -

i know possible: sql> create or replace type tp_asset object (assetid number, asset_name varchar2(100), asset_val number) 2 / type created sql> create or replace type tp_tab_asset table of tp_asset; 2 / type created sql> create or replace function fnc_assetattributebytype(p_num in number) return tp_tab_asset pipelined 2 v_tp_asset tp_asset; 3 begin 4 in 1 .. 3 5 loop 6 v_tp_asset := tp_asset(i, 'abc', * 3); 7 pipe row (v_tp_asset); 8 end loop; 9 return; 10 end; 11 / function created but seems incredibly stupid. why want maintain list of columns in 2 places? i'm translating t-sql oracle , i'd following: create or replace function fnc_assetattributebytype( p_attributetypeid in number) return ******table???????? pipelined begin j in ( select a.assetid, shortname, longname, attributevalue dbo$asset inner join dbo$asset_attribute aa on a.ass