Posts

Showing posts from April, 2011

html - Javascript that validates user entries and then displays any error via pop up box for option forms? -

im having difficult time trying create javascript file validate sample form options , quantities. im trying when person fills out form , theres error, want pop why. if good, typical display summary of items ordered, numbers of each item, cost of each item , total cost. so in short, if customer orders something, want display show ordered , how total tax. <!doctype html public "-//w3c//dtd xhtml 1.1//en" "http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>products & services</title> </head> <body> <h1>pc products</h1> <form action="" name="products" method="post"> <table summary="feedback"> <tr> <td>processors: <select name="product1"> <option>select device</option> <option...

javascript - Google Timeline memory-leak when redrawing chart -

here chart https://jsfiddle.net/damiantt/t2skaegg/2/ <script type="text/javascript" src="//www.google.com/jsapi"></script> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <input id="draw" type="button" value="draw" onclick="drawchart();" /> <div id="chart_div_container" style="overflow-x: auto;min-height:0%;"> <div id="chart_div" style="overflow: visible;min-height:0%;"></div> </div> <script type="text/javascript"> google.charts.load('current', { 'packages': ['timeline', 'table'] }); var initwidth = $('#chart_div').innerwidth(); var colormap; function drawchart() { $('#chart_div').off...

php - Why am I rendering HTML code? -

i doing small project in php using notepad++, using xampp , rendering fine until did php include above tag. before rendering before render , showing entirely html code after render . here code - <?php include 'database.php'; ?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>shout !</title> <link rel="stylesheet" href="css/style.css" type="text/css"/> </head> <body> <div id="container"> <header> <h1>shout it! shoutbox</h1> </header> <div id="shouts"> <ul> <li class="shout"><span>10:15pm - </span>brad : hey guys to.</li> <li class="shout"><span>10:15pm - </span>brad : hey guys to.<...

excel - Euro symbol not showing (VBA) -

i'm trying write if statement checks input (a currency) , assigns correct symbol dollar amount. code below, every currency works except euro, works if dollar amount letters, , not numbers. missing obvious? if note_currency = "" note_denomination = "$" + note_denomination elseif note_currency = "eur" note_denomination = "€" + note_denomination elseif note_currency = "jpy" note_denomination = "¥" + note_denomination elseif note_currency = "gbp" note_denomination = "£" + note_denomination else note_denomination = "$" + note_denomination end if okay figured out - kind of. tried sub in excel , same thing happens me. using symbol , chr(128) shows blank cell. what found worked if know range have these numbers, change cell's format type text ( @ ): range("a1:a100").numberformat = "@" then, when run code, euro symbol shows if use note_...

c++ - Constructing a pair with an rvalue -

in this: vector<pair<string,int>> vp; string s; int i; while(cin>>s>>i) vp.push_back({s,i}); i'm curious last line. pair constructed in call push_back , therefore moved, not copied, correct? if had instead been written this: vector<pair<string,int>> vp; string s= ...; int i= ...; pair<string,int> p{s,i}; vp.push_back(p); while construction of pair involves same resources, pair named, p , therefore no longer rvalue , therefore move semantics no longer used, , therefore pass value, causing copy made, right? this implies me possible, constructing objects inside arg lists performance improvement; can verify? the pair constructed in call push_back , therefore moved, not copied, correct? the temporary pair constructed , bound rvalue reference argument of push_back . moved argument vector . vp.push_back({s,i}); is equivalent to: vp.push_back(std::pair<std::string, int>{...

Log user IP with PHP -

currently i'm using script log users ip adresses: $userip = $_server['remote_addr']; however, after bought anti-ddos http proxy, returns proxy ip instead. $_server['remote_addr'] -> 198.12.12.102 i'm using cloudflare proxy, i've entered proxy's ip inside ip field in cloudflare , selected 'bypass cloudflare network'. well, yes, if request proxied, php sees proxy's address. in case, and in case , should @ alternative http headers. proxy may, should , add original ip address http header, x-forwarded-for , available in $_server['http_x_forwarded_for'] . usually it's security risk pay attention these headers; if know your proxy you control explicitly adds header on your behalf should use it.

c# - PdfArray.remove() is not removing all annotations -

i want remove annotations pdf. i'm using code: void removeannotations(string inputpath,string outputpath) { pdfreader pdfreader = new pdfreader(inputpath); pdfstamper pdfstamper = new pdfstamper(pdfreader, new filestream(outputpath, filemode.create)); pdfdictionary pagedict = pdfreader.getpagen(1); pdfarray annotarray = pagedict.getasarray(pdfname.annots); (int = 0; < annotarray.size; i++) { annotarray.remove(i); } pdfstamper.close(); } when first create annotarray , has 217 items. after for-loop of annotarray.remove() , has 108 items, , can still see callouts , lines on pdf generated @ outputpath . it's not clear me remaining items have in common, why skipped annotarray.remove() . how can remove every annotation? suppose have 10 elements in array: array = [a, b, c, d, e, f, g, h, i, j] you loop on array this: for (int ...

Java Google Drive API download file -

i trying download file drive api , trouble. read guide downloading file drive api v3 , use code string fileid = "0bwwa4outeiv1uvnwohitt0xfa2m"; outputstream outputstream = new bytearrayoutputstream(); driveservice.files().get(fileid).executemediaanddownloadto(outputstream); every time getting error ` com.google.api.client.http.httpresponseexception: 400 bad request { "error": { "errors": [ { "domain": "global", "reason": "badrequest", "message": "bad request" } ], "code": 400, "message": "bad request" } }` from errors , suggested actions : error encountered can mean required field or parameter has not been provided, value supplied invalid, or combination of provided fields invalid. this error can thrown when trying add duplicate parent drive item. can thrown when trying add parent create cycle in directory gr...

Selenium locate custom html attribute -

<div> <input id="" class="form" type="text" z:validate="" z:prompt="form1.prompt('submit')" z:placeholder="" z:tie="submit" z:disabled="{form1.isenabled('sumbitapply')}" placeholder="" maxlength="20"> </div> i want locate element using z:tie="submit" custom attribute. so far have tried below options. did not work. //input[@z:tie='sumbit'] //input[z:tie='sumbit'] i believe you're having trouble because of ":" in attributes. if change ":" "_" work fine.

database - PHP - Is this secure enough for unique session tokens? -

i creating php application , need user authentication secure possible! once user has logged-in need set cookie (along other cookies) session identifier , has unique. <?php // set default timezone time() function. date_default_timezone_set("europe/london"); $secure_token_length = 16; // 32-digits long. // generate unique token. $token = time() . "-" . bin2hex(openssl_random_pseudo_bytes($secure_token_length, $strong)); // set session identifier. setcookie("session", $token, 0, "/app/", false, false, true); ?> as can see i'm creating unique token , appending current unix timestamp ensure value not generated twice, secure token stored in database within unique column , token not inserted database if in use (using php's do-while function), advice on how make more secure please comment. if want "secure possible" please use established method rather trying create own. example, let third-party authenticate...

ConnectionRefusedError: [WinError 10061] while using Selenium in Python 3.5 -

i trying launch firefox , land desired website. getting error message "connectionrefusederror: [winerror 10061]". tried using interactive shell , able launch browser, except error showed when try specify website. please see code below >>> selenium import webdriver >>> browser = webdriver.firefox() >>> browser.get('http://google.com') --> part trouble i tried check internet options , set automatic. i'm not sure if maybe caused firewall or admin rights going.please take note using admin account project. suggestions appreciated! sorry guys, figured out. browser must not closed after being launched in interactive shell. works fine now. considered ticket closed!

jenkins - Jenkinsfile and different strategies for branches -

i'm trying use jenkins file our builds in jenkins, , have following problem. have 3 kind of builds: pull-request build - merged master after code review, , if build works manual pull-request build - build same above, can triggered manually user (e.g. in case have unstable test) an initial continuous deliver pipeline - build code, deploy repository, install artifacts repository on target server , start application there how should contain of above builds single jenkinsfile. right idea have make giant if check branch , steps. so have 2 questions: 1. appropriate way in jenkinsfile? how name of executing branch in multi-branch job type? for reference, here's current jenkinsfile: def servers = ['server1', 'server2'] def version = "1.0.0-${env.build_id}" stage 'build, ut, it' node { checkout scm env.path = "${tool 'maven'}/bin:${env.path}" withenv(["path+maven=${tool 'maven'}/bin...

asp.net - How to get updated page information through C# WebBrowser when updatePanel AJAX event happens? -

i automating scenario in wpf using webbrowser . code snippet follows string id = paginationcontrolprocessing[1].pagectrl.id; webdoc.getelementbyid(id).gotfocus += new htmlelementeventhandler(wb_ongotfocus_paginationcontrols); webdoc.getelementbyid(id).focus(); webdoc.getelementbyid(id).raiseevent("onchange"); webdoc.invokescript("__dopostback", new object[] { "ctl00$contentplaceholder1$pgcontrol$nextpagelink", "" }); when page changes through pagination control, able hit event handler focus change. problem happening when pagination controls hit not able retrieve data 2nd , 3rd page. i can page navigation , works in webbrowser control. data updated in table these asp.net ajax controls attached. in event handler, when content of object webbrowser1, not contain content of new data appears in updatepanel control. data control when 2 , 3 clicked comes through updatepanel asp.net control. what event can used capture data coming updatepane...

Android activity in landscape - with fragment or dialog in portrait and landscape -

im building camerafunction in application. i've implemented function activity surfaceview, , activity set landscape only. here problem: i have various settings can changed within view eg. flashmode, resolution, zoom etc. whenever user selects spinner, presented dialog allows him/her select between various options - dialog in landscape. i'm trying figure out how display dialog in portrait mode if phone turned. can orientation using sensormanager, how put info use? im thinking maybe can have fragments within acticity overlay surfaceview, , have fragments rotated accordingly current orientation. how? anyways preferred solution have spinnerdialog rotate according orientation, have set orientation in manifest landscape, cant see how can achieved. any suggestions? in advance

Bytecode manipulation on Android class -

i bytecode manipulation on android.view.view class (adding methods), possible? should use javassist or maybe different library? thanks no can't. android uses own bytecode format not compatible "standard" bytecode format javassist , other libs operate on. http://bravenewgeek.com/dalvik-bytecode-generation/

Cmake how to link to OpenSSL on device? Or should I? -

we have crossplatform app using cmake , have been linking precompiled openssl binaries. link android , ios's own openssl. how in cmake? we avoid using binary not compatible os version. valid or typical concern? if wanting link apple-provided openssl libraries, may want rethink strategy. apple have following text in cryptographic services guide (emphasis mine): although openssl commonly used in open source community, openssl not provide stable api version version. reason, although os x provides openssl libraries, openssl libraries in os x deprecated, and openssl has never been provided part of ios . use of os x openssl libraries apps discouraged. if app depends on openssl, should compile openssl , statically link known version of openssl app. use of openssl possible on both os x , ios. however, unless trying maintain source compatibility existing open source project, should use different api. also see answers here , here . ios @ least, have build...

javascript - datatables element in row triggers selected/deselect -

i'm using jquery datatables plugin select extension , need use <select> list in 1 of fields (inside each row). <option> gets id selected row. the problem each time click list element, row select atrribute triggered. ok if user doesn't select row , clicks list, if row selected when user clicks list element, row deselected, causing id empty. i thinking in disable <select> list , enabling when row selected, preventing <select> element triggering select attribute (this last part lost, done dt option, jquery. tried, foolishly, css option z-index realized has nothing do... ). what have in mind (so far...): $('.select_class').on('click', function() { $(this).parent().parent().preventaddclass('.selected'); }); how this? the <select> list part of data comes ajax source: [{"id":76,/* other fields*/"the_select":"<select class=\"select_class\"><option value=\...

javascript - notification to the user when a table in the database change -

i'm using spring project , need best solution problem, because affect performance system. better using javascript or create method on java ? from web server: poll database, , check new data or listen notifications database. preferred method. you'd need postgresql or oracle though from web browser: reload page using refresh header (don't this) poll server using ajax use comet use server-sent events . lightest weight. use websocket here's how spring, postgresql, , websocket: http://blog.databasepatterns.com/2014/04/postgresql-nofify-websocket-spring-mvc.html

haskell - Lenses with Sum Types (that have Product types) -

{-# language templatehaskell #-} import control.lens data fruit = fruit { _fruitcolor :: string } $(makeclassy ''fruit) data fruits = banana int fruit | strawberry string fruit printer :: hasfruit s => s -> io () printer f = putstrln $ f ^. fruitcolor sample :: io () sample = printer $ fruit "yellow" printer $ banana 5 $ fruit "yellow" i have core product type, fruit. want have data types contain core product type, fruit, want able have them represented sum type, fruits. using sum type, fruits, i'd able access components of core product type, fruit. namely, i'd types banana , strawberry instance of hasfruit. is there straightforward way have fruits instantiate hasfruit? there better pattern represent - core product type in sum type? it make more sense this: data fruittype = banana int | strawberry string data fruits = fruits { _fruitsfruittype :: fruittype, _fruitsfruit :: fruit } makefields '...

SAML authentication using ADFS for IONIC mobile app? -

i looking way put own login page, create saml assertion , send our adfs server saml request ionic app. on how done. i got app url registered relying party on our adfs using ionic app custom url i not allowed share adfs server details can not use: auth0-ionic is there other way use own login page , send saml request adfs authentication? i did find 1 option, manually generate saml request xml string , send request, not sure if there better way available. appreciate help. please let me know if more information required. thanks

Spring Data Rest: pass Collection<Entity> as query String parameter -

first off, related spring data rest: how search object's key? appears resolved in https://jira.spring.io/browse/datarest-502 my issue (i believe) , extension of this. i'm seeing following behavior: i have 2 repository queries defined e.g. person findbyaccount(@param("account") account account)); collection<person> findbyaccountin(@param("accounts") collection<account> accounts)); both search methods exposed via spring-data-rest. can access first using url such http://localhost:8080/people/search/findbyaccount?account=http://localhost:8080/accounts/1 i can access second method using url such http://localhost:8080/people/search/findbyaccountin?accounts=http://localhost:8080/accounts/1 , if try pass in multiple accounts, such http://localhost:8080/people/search/findbyaccountin?accounts=http://localhost:8080/accounts/1,http://localhost:8080/accounts/2, it run query except ignore first account ( http://localhost:8080/accounts/1 ) , ...

python - recognize separate normal distributions in one data set -

Image
a model have constructed produces output takes shape of 3 normal distributions. import numpy np d1 = [np.random.normal(2,.1) _ in range(100)] d2 = [np.random.normal(2.5,.1) _ in range(100)] d3 = [np.random.normal(3,.1) _ in range(100)] sudo_model_output = d1 + d2 + d3 np.random.shuffle(sudo_model_output) what pythonic way find normal distribution mean , standard deviation associated each normal distribution? cannot hardcode estimate of distributions start , end (~ 2.25 , 2.75 here) because value change each iteration of simulation. i adapted fit : fitting histogram python from scipy.optimize import leastsq import numpy np import matplotlib.pyplot p %matplotlib inline d1 = [np.random.normal(2,.1) _ in range(1000)] d2 = [np.random.normal(2.5,.1) _ in range(1000)] d3 = [np.random.normal(3,.1) _ in range(1000)] sum1 = d1 + d2 + d3 bins=np.arange(0,4,0.01) a=np.histogram(sum1,bins=bins) fitfunc = lambda p, x: p[0]*exp(-0.5*((x-p[1])/p[2])**2) +\ p[3]*exp(-0.5...

c++ - Tellg and seekg and file read not working -

i trying read 64000 bytes file in binary mode in buffer @ 1 time till end of file. problem tellg() returns position in hexadecimal value, how make return decimal value? because if conditions not working, reading more 64000 , when relocating pos , size_stream(size_stream = size_stream - 63999; pos = pos + 63999;), pointing wrong positions each time. how read 64000 bytes file buffer in binary mode @ once till end of file? any appreciated std::fstream fin(file, std::ios::in | std::ios::binary | std::ios::ate); if (fin.good()) { fin.seekg(0, fin.end); int size_stream = (unsigned int)fin.tellg(); fin.seekg(0, fin.beg); int pos = (unsigned int)fin.tellg(); //........................<sending file in blocks while (true) { if (size_stream > 64000) { fin.read(buf, 63999); buf[64000] = '\0'; cstring strtext(buf); sendfileconte...

ios - How to make a splitViewController behave the same on all devices -

for reasons rather not go into, have splitviewcontroller want behave same way on screens. in other words, not wish have split screen master-detail on left-right, rather show master or detail, depending on how user using it. you can set uisplitviewcontroller 's preferreddisplaymode property uisplitviewcontrollerdisplaymodesidebyside (the default uisplitviewcontrollerdisplaymodeautomatic ). system try honor wishes, you'll have specify custom primarycontentwidth or preferredprimarycolumnwidthfraction property force on compact device.

html - Does a PHP file work in a NODE JS Container? -

i'm new php, , building app in node js container on nitrous. adding php backend mandrill email form. php files work on node js containers? sorry newbie question. thanks! node runs javascript. in order run php, you'll need web server capable of running php such nginx + fpm or apache + mod_php. here official getting started docs on nitrous + php: https://www.nitrous.io/stacks/php/ .

Selenium driver fails to start WebDriver session for non-root user with Firefox -

i have gocd (thoughtworks) agent running end-to-end tests using selenium , protractor on dedicated server through grunt automated task headless firefox on xvfb. if run task root (mind files , folders on directory owned go user), runs fine. if run task go user (which 1 runs automated tests), following error: 16:37:42.357 running "protractor:ci" (protractor) task 16:37:42.573 starting selenium standalone server... 16:37:42.581 [launcher] running 1 instances of webdriver 16:37:43.194 selenium standalone server started @ http://xx.xx.xx.54:48234/wd/hub 16:37:45.385 error - unable start webdriver session. 16:37:45.393 16:37:45.394 /var/lib/go-agent/pipelines/development/e2e_tests/node_modules/grunt-protractor-runner/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.js:113 16:37:45.394 var template = new error(this.message); 16:37:45.394 ^ 16:37:45.394 unknownerror: bad request 16:37:45.394 command duration or timeout: 166 millise...

VB6 - Populate User Defined Type Array from Stored Procedure then Find Item in Array -

i coming more of .net background , need make changes old vb6 application. the .net equivalent of i'm trying in vb6 is, define (model) class 3 properties public class myclass { public string ref { get; set; } public string oldnumber { get; set; } public string newnumber { get; set; } } in .net call stored procedure return set of results (there few thousand records) , assign them to, example, instance of list<myclass> . i then, whenever need to, attempt find item within list, 'ref' property 'blah', , use item/its other properties (oldnumber , newnumber). however, in vb6, don't know how same process best achieved. can please help? if using ado can cache results querying static cursor client-side recordset , disconnecting it. you can use sort, find, filter, etc. , move through rows needed. can improve searches building local index within recordset after opening , disconnecting using field object's optimize dynamic property....

python 2.7 - BigQuery Create a table from Query Results -

new big query api. trying basic query , have save table. i not sure doing wrong below.(i have read similar questions posted topic) don't error doesn't save results in table want. any thoughts/advice? import argparse googleapiclient.discovery import build googleapiclient.errors import httperror oauth2client.client import googlecredentials credentials = googlecredentials.get_application_default() bigquery_service = build('bigquery', 'v2', credentials=credentials) query_request = bigquery_service.jobs() query_data = { 'query': ( 'select * ' 'from [analytics.ddewber_acq_same_day] limit 5;'), 'destinationtable':{ "projectid": 'xxx-xxx-xxx', "datasetid": 'analytics', "tableid": "ddewber_test12" }, "createdisposition": "create_if_needed", "writedisposition": "...

java - For loop printing an unexpected number of times -

public static void main (string[] args) { scanner input = new scanner(system.in); int[] array = new int[5]; system.out.print("please enter 5 numbers. \na="); array[0] = input.nextint(); system.out.print("\nb="); array[1] = input.nextint(); system.out.print("\nc="); array[2] = input.nextint(); system.out.print("\nd="); array[3] = input.nextint(); system.out.print("\ne="); array[4] = input.nextint(); boolean totaliszero = false; (int i=0;i<array.length ;i++) { (int j=1;i>j ;j++ ) { if ((array[i] + array[j])==0) { system.out.println("the numbers " + array[i] + " , " + array[j] + " have total sum equal 0."); totaliszero = true; } } } if (!totaliszero) { system.out.print("none of numbers have total sum of 0 each other. "); } } here simple...

c# - .NET Framework x509Certificate2 Class, HasPrivateKey == true && PrivateKey == null? -

i'm attempting work x509 certificate imported currentuser keystore on windows 10 computer using "certificates" snap-in of mmc. same procedure has been tested on windows 8.1 computer same result. using standard powershell pki module, i'm getting x509certificate2 object using get-item: $my_cert = get-item cert:\currentuser\my\adaa82188a17thumbprintxxxxxxxxxxx the output of $my_cert | fl * follows: pspath : microsoft.powershell.security\certificate::currentuser\my\xxxxxxxxxxxxxxxxxxx psparentpath : microsoft.powershell.security\certificate::currentuser\my pschildname : xxxxxxxxxxxxxxxxxxx psdrive : cert psprovider : microsoft.powershell.security\certificate psiscontainer : false enhancedkeyusagelist : {secure email (1.3.6.1.5.5.7.3.4), ip security user (1.3.6.1.5.5.7.3.7), encrypting file system (1.3.6.1.4.1.311.10.3.4), document signing (1.3.6...

c# - Passing a Date Parameter in XML inside another XML element on config file -

i bit new understanding xml config files know far: have config file used c# based .exe , gets parsed move files 1 location another. as of right use standard creating file element , destinations/source: <?xml version="1.0" encoding="utf-8"?> ...miscellaneous xml config nodes <filelocation sourcepath="\\server" destinationpath="\\server" archivepath="\\server"> <file> <filekeyword>company_memo.txt</filekeyword> <filedestination>memo.txt</filedestination> </file> </filelocation> so can see scans source folder , renames whatever put in moves destination directory. question: i've been trying figure out how append date parameter, preferable date, or full name of file finds in instead of setting arbitrary name. this: <filelocation sourcepath="\\server" destinationpath="\\server" ...

c - Why should I use 'rdtsc' differently on x86 and x86_x64? -

i know rdtsc loads current value of processor's time-stamp counter 2 registers: edx , eax. in order on x86 need (assuming using linux): unsigned long lo, hi; asm( "rdtsc" : "=a" (lo), "=d" (hi)); return lo; and x86_x64: unsigned long lo, hi; asm( "rdtsc" : "=a" (lo), "=d" (hi) ); return( lo | (hi << 32) ); why that? can explain me? in x86-64 mode, rdtsc clears higher 32 bits of rax. compensate bits have shift hi left 32 bits.

r - How do I reference an object name as text in a label for a ggplot? -

basically wish mitigate amount of re-coding have when creating new plots changing reference "xvar" object below... xvar<-"n_age" ggplot(data=dat4,aes(x=n_age,y=count))+ geom_smooth()+ labs(x=xvar, y="count") this code works ok in "labs" part of statement (as referencing text) in "aes" component need re-specify n_age. can not use syntax removes quotation marks xvar object, reference object? thanks, daniel. you can specify aes_string instead of aes : xvar<-"n_age" ggplot(data=dat4,aes_string(x=xvar,y="count"))+ geom_smooth()+ labs(x=xvar, y="count")

php - SPF DKIM PTR seem good, but still marked as spam -

tl;dr spf ad dkim pass, prt record complete, no blacklisted ip, not spammy message, still go spam. gmail (and other mail hosts) marking messages spam. they're not spam, they're purchase receipts, upcoming class reminders , thank notes attending class. sent bespoke database driven system, looks upcoming classes, , pulls message , email addresses (and first names) database , sends message. it's been working fine couple of years, noticed few months ago customers started complaining weren't getting mail expected. it's @ point no gmail user receive messages inbox. other servers flag spam. so signed vps, away possible bad server neighbors. read lot on spf , dkim, , believe have them set correctly. ptr seems resolve right domain. the email not spammy @ all, no content changes have effect (including simple plain text messages). html few linked images, including 1 open tracking pixel (src of spacer.phpid=12345). include unsub link. think follow guidelines sendin...

javascript - How do I write a synchronous while loop using node.js and promises -

i call function takes data every student specific time interval , repeat same process until reaches condition. the current code seems make parallel calls function iteratethruallstudents(); my code looks this: var startdate = new date("march 16, 2016 00:00:00"); //start february var fromtimestamp = null; var totimestamp = null; var today = new date(); var todaytimestamp = new date(today).gettime() / 1000; async.whilst( function () { return fromtimestamp < todaytimestamp; }, function (callback) { console.log(startdate); fromtimestamp = new date(startdate).gettime() / 1000; startdate.setdate(startdate.getdate() + 5); totimestamp = new date(startdate).gettime() / 1000; iteratethruallstudents(fromtimestamp, totimestamp); callback(null, startdate); }, function (err, n) { console.log('finished ' + n); } ); function iteratethruallstudents(from, to) { student.find({stat...

c++ - Is it safe to return from function before all std::futures are finished? -

i have code that: int function() { std::vector<std::future<int>> futures; (const auto& elem : elements) { futures.push_back(std::async(&myclass::foo, myclass, elem); } (auto& f : futures) { const int x = f.get(); if (x != 0) return x; } } can return function when there unfinished async calls? i'm interested in 1 non 0 value. should wait until async calls finished? code safe? the destructor of std::future (when initialized call std::async ) blocks until async task complete. ( see here ) so function return statement not complete until of tasks have finished.

ember.js - Instance initializer unit test fails with "store is undefined" -

after generating example application: ember new preloadtest cd preloadtest/ ember g instance-initializer preload ember g model test-data ember g route index ember g adapter application with following files: models/test-data.js import ds 'ember-data'; export default ds.model.extend({ name: ds.attr('string'), value: ds.attr( 'number' ) }); routes/index.js import ember 'ember'; export default ember.route.extend({ model(){ return this.store.peekall( 'test-data' ); } }); instance-initializers/preload.js export function initialize( appinstance ) { let store = appinstance.lookup( 'service:store' ); store.pushpayload( { "testdatas": [ { "id": 1, "name": "aaa", "value": 1}, { "id": 2, "name": "bbb", "value": 2}, { "id": 3, "name": "ccc", "value": 3} ] } ); } export de...

mapkit - Draw direction arrow in polyline in MKMapView -

Image
i want draw polyline arrow direction. understand not include in mapkit. i tried create custom mkoverlaypathrenderer , override drawmaprect i'm bit confused on how this. is there way achieve goal? here example of i'm trying do

javascript - How to fast-forward or rewind an HTML5 video to a certain time point -

i'm trying write javascript , can't figure out why method isn't working. var vid = document.getelementbyid('myvid'), ticks = 50, // number of frames during fast-forward frms = 10, // number of milleseconds between frames in fast-forward/rewind endtime = 24.0; // time fast-forward/remind (in seconds) // fast-forward/rewind video end time var tdelta = (endtime - vid.currenttime)/ticks; ( var = 0; < ticks; ++i ) { (function(j){ settimeout(function() { vid.currenttime = vid.currenttime + tdelta * j; }, j * frms); })(i); } fiddle: https://jsfiddle.net/f90yu2t4/1/ are html videos not advanced enough support kind of rapid movement place place in video? two things: for jsfiddle, code wrapped in window.onload, code inside window.onload isn't executed. should remove wrapper (at least when using jsfiddle). second, in settimeout function, vid.currenttime = vid.currenttime + tdelta * j; doesn't w...

c# - Get name of Enum instance -

say have enum: public enum myenum{ valueone = 1, valuetwo = 2, valuethree = 3 } and field/variable: public myenum myenuminstance = myenum.valuetwo; i need name of myenuminstance via reflection from class . i tried: myclassinstance.gettype().getfield("myenuminstance").getvalue(myclassinstance) which returns valueone , no matter myenuminstance set to. how can string value/name of enum field via reflection? you don't need reflection. need call .tostring() . myenuminstance.tostring(); which output "valuetwo" ; however, if insist on using reflection, following example works fine: var myclassinstance = new myclass(); myclassinstance.gettype() .getfield("myenuminstance") .getvalue(myclassinstance); public enum myenum { valueone = 1, valuetwo = 2, valuethree = 3 } public class myclass { public myenum myenuminstance = myenum.valuetwo; } note in c#6 can use nam...

objective c - iOS: Faster way to format html text to attributed text? -

i have method format html text attributed text following. however, method painfully slow. there way achieve faster? self.textlbl.attributedtext = [[nsattributedstring alloc] initwithdata: [html datausingencoding:nsunicodestringencoding] options:@{ nsdocumenttypedocumentattribute: nshtmltextdocumenttype } documentattributes:nil error:nil];

Ckeditor contentelement="false" working but it can be delete or Replace -

i need block editing , deleting in (ckeditor) elements. trying attribute of contenteditable='false' allowing delete , replace. how can dodge issue? please review below content: <elems> <elem1>editable content</elem1> <elem2>unchangable content</elem2> <elem3>editable content</elem3> </elems> you're looking ckeditor widgets feature matches requirements. it's under development , it'll available in ckeditor 4.3. update: feature has been in core while , it's stable. there's official guide widgets api.

sql server - CAST and CASE in SQL SELECT statement -

i'm trying return string when conditions true, i'm running data type issue... li.num_seats_pur , li.num_seats_ret both smallint data types... here's i'm stuck: select case when (li.num_seats_ret = li.num_seats_pur) 'ret' else (li.num_seats_pur - li.num_seats_ret) end 'seats' t_lineitem li; i understand 'ret' not smallint, every combination of cast use here still causing error. ideas? when using case expression, if return values have different data types, converted 1 higher data type precedence . , since smallint has higher precedence varchar , return value of else part, 'ret' gets converted smallint . proceed conversion error: conversion failed when converting varchar value 'ret' data type smallint. in order achieve desired result, need cast else part varchar : select case when (li.num_seats_ret = li.num_seats_pur) 'ret' else cast((li....

r - Shiny: leaflet map is not working with rCharts -

Image
using dat data.frame set.seed(123) stationid <- c(rep("station1", 3), rep("station2", 3), rep("station3", 3),rep("station4", 3)) x <- c(rep(-77.2803, 3), rep(-79.1243, 3), rep(-93.4991, 3),rep(-117.632, 3)) y <- c(rep(35.8827, 3), rep(42.4356, 3), rep(30.0865, 3),rep(34.0905, 3)) parameter <- rep(c("a", "b", "c"), 4) value <- c(sample(1200:1800, 3), sample(900:1300, 3), sample(1400:2200, 3), sample(850:1400, 3)) dat <- data.frame(stationid, x, y, parameter, value) head(dat) i created multi bar chart using rcharts below library(rcharts) n1 <- nplot(value ~ stationid, group = "parameter", data = dat, type = "multibarchart") n1$xaxis(axislabel = 'station') n1$yaxis(axislabel = 'value') n1$chart(margin=list(left=100,bottom=100)) n1$params$width <- 1700 n1$params$height <- 700 n1 here's result ...