Posts

Showing posts from May, 2012

html - Understanding Screen Sizes/Pixel Density for Web Development (Websites & Emails) -

i'm trying understand few things deal pixels. the first of changes between developing html email , website in terms of appearing on mobile screen. more specific, when developing website, can have media queries run below 375px (i.e. @medie screen , (max-width 375px)) , changes occurring in code not reflected on desktop (since browsers without going inspect restrict width @ 400px); however, on phone has smaller screen iphone se, changes occur under media query hit. so on own makes sense me, because phone screen smaller min browser width, of course changes apply in block hit when website executed on phone. confusion gets introduced. when developing html email, have table set 600px wide. there no media query affecting html. table 600px wide under circumstances, when displaying on less 600px wide phone, assume of page clipped, not so. when viewing email in gmail, entire composition visible. made me scratch head bit, researched , found sources claiming phone greater 600px wide. t

What is AST in graphql? -

what ast in graphql ? using graphql-js. how anything? nothing in documentation seems explain ast is graphql 2 things: a query language a type system when graphql server receives query process comes in string. string must tokenized , parsed representation machine understands. representation called abstract syntax tree. when graphql processes query, walks tree executing each part against schema. converting raw strings ast first step of every compiler c++ chrome's javascript's vm babel. as graphql , how helps, here video may explain in bit more detail. https://www.youtube.com/watch?v=pmwho45wmqy

java - Insert an element into an array sorted according to frequency, then sort the array by frequency again -

so asked asked write o(n) function, insertranked(int[] list, int item) , insert element array sorted frequency (i have written boolean function check if int[] list sorted frequency). after inserting element array, array sorted again frequency. for example, insertranked([65, 65, 65, 65, 1, 1, 1, 8, 8, 987, 987, 2, 2, 40], 2) should produce [65, 65, 65, 65, 1, 1, 1, 2, 2, 2, 8, 8, 987, 987, 40] . is possible in o(n)? have thought of storing elements , counts linkedhashmap , using collections.sort() time complexity of collections.sort() o(n*log(n)). here's 1 approach start off based on count. import java.util.arraylist; import java.util.hashmap; import java.util.treemap; public class sortcount { public static void main(string[] args) { int nums[] = {([65, 65, 65, 65, 1, 1, 1, 8, 8, 987, 987, 2, 2, 40}; hashmap<integer,integer> counts = new hashmap<integer,integer>(); for(int = 0; < nums.length; i+

c# - Does the GC know about the IIS app pool memory limit? -

Image
i have .net c# website in iis. if assigned app pool doesn't have memory limit, app memory usage seems grow until there maybe 1gb of ram left, there seemingly garbage collection event , memory usage goes down dramatically. rinse , repeat. however, if set private memory limit (kb) in app pool specific (pretty low, double of app uses initially) value, app grow in memory usage , app pool recycle. is garbage collector aware of iis app pool limit? if not, there way notify garbage collector there one?

sprite kit - Best way to switch back and forth between two variables when switched swift -

i have variable, gamemode, switch between vertical , horizontal whenever screen tapped. issue having takes lower variable , gamemode displays horizontal. how fix switches whenever touchesbegan method called? appreciated! here code issue having: override func touchesbegan(_ touches: set<uitouch>, event: uievent?) { if gamemode == "horizontal" { gamemode = "vertical" } if gamemode == "vertical" { gamemode = "horizontal" } print(gamemode) } it happens because if gamemode "horizontal" , set gamemode "vertical" , after gamemode == "vertical" returns true , set gamemode "horizontal" . try code: override func touchesbegan(_ touches: set<uitouch>, event: uievent?) { if gamemode == "horizontal" { gamemode = "vertical" } else { gamemode = "horizontal" } print(gamemode) }

webpack - Debug lazy loaded Angular 2 module in Chrome / VS Code -

Image
i using webpack angular 2/4 , using modules lazy loaded. therefore modules , components not included in main .js file, code resides in 1 of files webpack generates counts up: 0.js , 1.js , on. my problem neither chrome nor vs code can debug code within files reason. when include code main .js file, debugging works fine. there can it? example : i have small directive displays local time in html element. use directive in component lazy loaded. when try debug directive (or else lazy loaded) vs code says following: debugging not possible in chrome either. if use directive in root component (or else not lazy loaded) breakpoint working in vs code in chrome. i tracked down files webpack generating main client , parts lazy loaded. each chunk of lazy loaded components located in files named 0.js , 1.js , on - , think here may cause of problem. map files the map files debugging generated accordingly, output: look *.js.map file not created. if using angular c

Rails Devise/Invitable -

i have rails app devise , devise_invitable (links official docs on overriding controllers), have made devise_invitable invitations_controller.rb display list of invited users within devise/invitations/new.html.erb. both devise , devise_invitable views in app/views/devise , app/views/devise/invitations respectively , devise/devise_invitable controllers in app/controllers/users/ . rails throws undefined method 'each' nilclass in invitations/new view in loop: # app/views/devise/invitations/new.html.erb <% @invited_users.each |invited| %> omitting code... <% end %> # app/controllers/users/invitations_controller.rb class users::invitationscontroller < devise::invitationscontroller def new super # not empty, returns multiple records in console @invited_users = user.where.not(invitation_sent_at: nil) end end # config/routes.rb ... devise_for :users, controllers: { registrations: 'users/registrations',

Logic error using .erase (C++) -

so program reading input of numbers , lists them in order. seen in output. without use of algorithm library, sorted , getting rid of repeated data. however, if there data value repeated, last value of vector not printed. incorrectly using .erase? void remove_repeated(int size, vector<int>& num_vec){ for(int = 0; < num_vec.size(); i++){ if(num_vec[i]==num_vec[i+1]){ num_vec.erase((num_vec.begin()+i)); } } } output when no value repeated: **welcome hw reading program** please, enter hw:1-10 problems: 1, 2, 3, 4, 5, 6, 7, 8, 9,and 10 output when value repeated: **welcome hw reading program** please, enter hw: 1-10,1-3 problems: 1, 2, 3, 4, 5, 6, 7, 8,and 9 after erase element @ index i vector, next element @ index i , not @ index i+1 . have take care not go out of bounds when comparing i+1 , ie loop has this: for(int = 0; < num_vec.size()-1;){ if(num_vec[i]==num_v

How to get a list of multiple emails from a string by using split in Java? -

i'm facing issue hours :( . have string contains bunch of emails in it: " email1@gmail.com , 'email2@gmail.com,email3@gmail.com, email4@gmail.com' , 'email5@gmail.com ,email6@gmail.com' " so i'm trying extract each email each substring , end array contains email: example: string[] myarray = {email1@gmail.com , email2@gmail.com, email3@gmail.com, email4@gmail.com, email5@gmail.com}; here's code: string str = "email1@gmail.com , 'email2@gmail.com,email3@gmail.com, email4@gmail.com' , 'email5@gmail.com ,email6@gmail.com'"; string[] newarray = str.split(","); for(int = 0 ; < newarray.length; i++) { if(newarray[i].contains(",")) { newarray = newarray[i].split(","); } } keep in mind substring may have multiple emails in it. thank help! you can use pattern matching , regex, simple email follows

angular - Angular2: How to make sure the execution will be run in order line by line? -

i have angular2 navbar component includes logout button: import { component, oninit } '@angular/core'; import { loginservice } '../login.service'; import { router } '@angular/router'; @component({ selector: 'app-navbar', templateurl: './navbar.component.html', styleurls: ['./navbar.component.css'] }) export class navbarcomponent implements oninit { loggedin: boolean; constructor(private loginservice: loginservice, private router : router) { if(localstorage.getitem('portaladminhasloggedin') == '') { this.loggedin = false; } else { this.loggedin = true; } } logout(){ this.loginservice.logout().subscribe( res => { localstorage.setitem('portaladminhasloggedin', ''); }, err => console.log(err) ); this.router.navigate(['/login']); lo

POST request to REST API implemented in PHP -

i integrating new front-end survey application using angularjs old restful back-end application running on php/mysql. currently require users sign in order complete survey. allow guest users, i.e. not signed up, complete survey. best way bypass using auth token (or generate new one) guest user in php? post request make guest, no other requests needed. i new php. below how creating survey: public function createnew(application $app, request $request, $now = false) { $data = $request->request->all(); $token = (isset($data['token']) ? $data['token'] : $app['token']); $survey = new survey($token, 'token'); $error = new jsonresponse(array('status' => 400, 'message' => "error while completing survey")); $success = new jsonresponse(array('status' => 200, 'message' => 'survey completed.')); ... } basically, token required , returns error if not provided. thank

Java-Assign string within array to JButton randomly within a for loop. Each element once -

public static void main(string[] args){ string[] word = {" ", " itsy " , " bitsy ", " spider ", " went " , " " , " ", " water ", " spout. ", " down ", " came ", " " , " rain ", " , ", " flushed ", " ", " spider ", " out. "}; random random = new random(); jframe frame = new jframe(); frame.setlayout(new borderlayout()); frame.settitle("javagame"); frame.setsize(600,600); frame.setdefaultcloseoperation(jframe.exit_on_close); jpanel northpanel= new jpanel(new gridlayout(3,6)); (int i=0; i<18; i++) { jbutton button = new jbutton(); northpanel.add(button); button.settext(word[random.nextint(word.length)]); } } i'm looking plug in make sure each element populates once.

c# - How to generate EC keypair with Bouncy Castle -

my current project using fips resources of bouncycastle encrypten/decryption signing , on.. keys still generated usual c# bouncy castle. now, because waste want change code, can't find documentation on how this. what have far: ecdomainparameters s = new ecdomainparameters(...?) fipsec.keypairgenerator ecgen = cryptoservicesregistrar.creategenerator(new fipsec.keygenerationparameters(s)); but how specify type of curve, g , n? thanks in advance if can somehow. i found examples in bouncycastle unit tests. try downloading code tests: https://www.bouncycastle.org/csharp/download/bccrypto-csharp-1.8.1-src.zip or find appropriate source on web page: https://www.bouncycastle.org/csharp/index.html then class unit test: ectest for example have code this: /** * key generation test */ [test] public void testecdsakeygentest() { securerandom random = new securerandom(); biginteger n = new biginteger("88342353238919216479164875036030888480755034

ios - how to initialize methods in a UIViewController inside of a viewDidLoad method -

there method creating data. method needs called once. structure: var datacreated : bool? = false override func viewdidload() { super.viewdidload() if datacreated! == false { createdata() self.datacreated = true } } is right way ensure createdata() method called once? thank you. since want createdata called once per instance of view controller, using viewdidload place call it. further, since viewdidload called once per instance of view controller, there no need datacreated property. can remove that. override func viewdidload() { super.viewdidload() createdata() } another option call createdata init method of view controller. depends on createdata needs access. if createdata method needs access views , outlets, must use viewdidload .

parsing - Ignoring whitespace on a per-parser-rule basis in Antlr4 -

my grammar must ignore whitespaces part, except in contexts. answers this question advises define specific lexer rules handle exceptions want. the problem (i think) cannot handle such cases @ lexer level, since seem triggered high @ parser level. to more specific: want recognize like myrule: myparsetree1 operator myparsetree2 // ws skipped | myparsetree1 ws sensitiveoperator ws myparse // ws carries meaning keeping in mind have ws -> skip rule because in of grammar whitespaces should skipped. in xtext , rules can specify on rule-scoped basis hidden tokens apply within rule's scope: myrule (hidden comments): ... // ws reaches parser, comments don't myrule2 (hidden ws, comments): ... // ws skipped, comments but clueless antlr4. if want skip tokens depending on grammar context should have @ question here given procedure described skipping whitespace (as want it).

xsd - JAXB binding to remove propOrder -

i have written xsd: <?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" targetnamespace="http://api.synthesys/models/generated/simple/chat" xmlns:drsc="http://api.synthesys/models/generated/simple/chat" xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify" jaxb:extensionbindingprefixes="simplify" jaxb:version="2.1"> <xsd:element name="conversation"> <xsd:complextype> <xsd:sequence> <xsd:element name="start-time" type="xsd:datetime" minoccurs="1" maxoccurs="1"/> <xsd:choice minoccurs="0" maxoccurs="unbounded"> <!-- code generation,

java - How to remove every preceding and succeeding value of an instance of an object in a ListIterator -

i have been trying these methods couple days now. point is, given 2 methods, 1 removes preceding value , 1 removes succeeding value. in each, given parameter of type listiterator , of type object. instance of value checking object in listiterator. for example, when removing preceding value, given list such as: [12, 42, 28, 92, 3, 25, 3, 89] i supposed remove element before every occurrence of number 3 such becomes: [12, 42, 28, 3, 3, 89] when removing succeeding value, given list such as: [12, 42, 28, 92, 3, 25, 3, 89] i supposed remove element after every occurrence of number 3 such becomes: [12, 42, 28, 92, 3, 3] i have attempted already, no success. current code: remove preceding: public static void removepreceeding(listiterator it, object value) { if (it.hasnext()) { it.next(); } else { return; } while (it.hasnext()) { if (it.next().equals(value)) { it.previous(); it.remove(); }

collapsible using mobole jquery 1.4.5 in sharepoint -

i'm having problem using jquery in sharepoint add collapsible header. i importing jquery using script editor web part in sharepoint. this causing problems when using more 1 tag. my code is: <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script> <script type="text/javascript" src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> the code surrounding headers is: <div data-role="collapsible"> <h1>header</h1> <p>content</p> </div> when add script tags jquery in script editor, page edit button no longer works. need remove script part in page maintenance work again. how can implement in sharepoint?

validation - Validating Azure Functions CRUD operations -

i have started @ azure functions , 1 of biggest concerns validation. i have looked @ crud operations far, there doesn't way validate data coming request or storage. i have found poco-validation , thought might useful. i know kind of , open ended question i'd interested see others doing validation. we added function filters underlying webjobs sdk feature isn't exposed yet in azure functions (see issue here ). related this, we're considering support validation annotations applied poco types (issue here ). until above issues addressed, realize story validation isn't great. recommended approach perform required validation in function code calling out shared validation helpers/code needed.

powershell - Visual Studio Build Agent scripted setup -

i´m trying automate vsts build agent setup ( https://www.visualstudio.com/en-us/docs/build/actions/agents/v2-windows ). however there's interactive step in process. it´s cmd script file requires user's input. tried generate txt file settings, , run script reading input file: .\config < settings.txt but didn´t work. got message: enter server url > enter authentication type (press enter pat) > enter perso nal access token > cannot read keys when either application not have cons ole or when console input has been redirected. try console.read. is possible set build agent script? there way "redirect" console input in such way config.cmd works perfectly? did try passing --help config.cmd there number of examples below snippet of examples: unattended configure , unconfigure examples: remember check return code when using unattended configuration unattend configuration vsts pat authentication win : .\config.cmd --unattended --url htt

javascript - Moment.js ignores day of week during parsing validation -

i trying check string being valid date string. can't validate day of week in string representation. these 2 commands show similar result: moment("tuesday 19/09/2017", "dddd d/m/yyyy", true).isvalid() //true moment("tuesday 20/09/2017", "dddd d/m/yyyy", true).isvalid() //true how can check it? can't split string in 2 parts, because don't know format. it appear isvalid checking date part. if want check whole string, maybe 1 idea parse it, if result same after re-formating it's valid. eg. function valid(dt,fmt) { return moment(dt, fmt).format(fmt) === dt; } let fmt = 'dddd d/m/yyyy'; let dates = [ "tuesday 19/9/2017", "tuesday 20/9/2017" ]; dates.foreach((dt) => { console.log(dt + ' ' + valid(dt, fmt)); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>

r - Vegan pkg - diversity for (cover) data per row -

i'm trying calculate simpson's diversity() index different species (column headings) need compare indices between 2 treatments. have treatments in rows , species in columns: treatment plot pinus abies <chr> <int> <dbl> <dbl> 1 control 1 0.54 0.01 2 logging 2 0.02 0.09 is there way this? examples i've found have species in columns (dune, bci). help.

html - Text is forcing DIVs to not stay the same size -

im trying keep equal on page. when there text in 1 div pushing side down. how keep both divs equal height max of parent div on desktop? i tried playing around table display didn't go me, i'm not versed in it. <style><!-- .pagerow { display: inline-block; position: relative; width: 100%; text-align: center; vertical-align: middle; white-space: nowrap; } .pageblock { display: inline-block; position: relative; width: 50%; height: 100%; text-align: center; vertical-align: top; padding-left: 15px; padding-right: 15px; white-space: normal; } .pagetext { display: inline-block; position: relative; max-height: 100%; max-width: 100%; object-fit: contain; vertical-align: top; } .pagemap { display: inline-block; vertical-align: bottom; } @media (max-width: 768px) { .pagerow { display: inline-block; white-space: normal; } .pageblock { display: inline-block; w

Service Fabric Node Balancing doesn't trigger -

i attempt test service fabric node balancing mechanism on own private cluster , can’t figure out why doesn’t work. below steps took: configure cluster resource manager timer periodically check balancing state 5s, set balancing threshold metric “memoryusage” defined 2 , define node capacity metric 1200. clustermanifest looks like: clustermanifest create 2 stateless application: 1 called “nodebalancingtestappwith500” defaultload 200, weight high , instance count 5 , other 1 called “nodebalanceteststatelessservice” static load 400, weight high , instance count 1 publish both cluster. applicationmanifest looks like: applicationmanifest after publish 2 apps cluster, load in 5 nodes 200,200, 600, 200 , 200. expect see app “nodebalancingtestappwith500” defaultload 200 in node 3 should moved node after resource manager kicks in. after balancing , should 200,400,400,200,200 this? could tell why node balancing doesn’t work? seems there no capacity violation

c - Different scheduling jitter for task frequencies -

recently implemented qnx neutrino rtos on zynq-7000 platform (arm a9) , measured scheduling jitter different task frequencies no cpu load. in test wait in msgreceive function pulse generated timer. read high frequency clock fpga (100mhz). measured scheduling jitter 10hz, 100hz, 1khz, 10khz , 100khz tasks , got strange results. short period task got (-300,+300) nanoseconds jitter, longer periods got following: 1khz task had (+600, +1300) nanoseconds jitter 100hz task had (+8, +12) microseconds(!) jitter 10hz task had (+69,+71) microseconds jitter jitter not grow bigger longer period tasks, greater zero. didnt expect such differencies. provide explanation of such behaviour? might explained posix standard, allows timers expire not prematurely overhead? why did become more visible long period tasks?

c# - How to inject a service in AutoMapper Profile class? -

i working on project have automapper profile class has mappings. however, reason, need call service , in order call service, need call inject service in profile class. so class looks following: public class myclass : profile { public myclass { //somemapping here } } now, want inject service, needs take service in constructor , constructor following: public myclass(iservice service) { //somemapping here } now, services.addautomapper(); calls classes inherit profile class auto magically , , not call parameter constructor. now question best way call service in automapper profile class? addautomapper() extension method synthatic sugar. needs can initialize automapper manually: mapper.initialize(cfg => { cfg.addprofile(new myclass()); }); https://github.com/automapper/automapper/wiki/configuration#assembly-scanning-for-auto-configuration maybe solve issues.

python - Numpy "double"-broadcasting - is it possible? -

is possible use "double"-broadcasting remove loop in following code? in other words, broadcast across entire time array t same-dimensioned arrays freqs , phases . freqs = np.arange(100) phases = np.random.randn(len(freqs)) t = np.arange(0, 500) signal = np.zeros(len(t)) in xrange(len(signal)): signal[i] = np.sum(np.cos(freqs*t[i] + phases)) you can reshape t 2d array adding new axis it, trigger broadcasting when multiplied/added 1d array, , later on use numpy.sum collapse axis: np.sum(np.cos(freqs * t[:,none] + phases), axis=1) # add new axis remove sum testing : (np.sum(np.cos(freqs * t[:,none] + phases), axis=1) == signal).all() # true ​

How to provide a callable object protected access like lambda in C++? -

i have lambda need convert callable object can specialize call operator. impression has been lambda void(auto) signature equivalent callable struct this: struct callable { foo & capture; template< typename t > void operator()( t arg ) { /* ... */ } } however, lambda can access private , protected members when declared within member function. here's simplified example: #include <iostream> using namespace std; class { protected: void a() { cout << "yes" << endl; } }; class b : public { public: void call1(); void call2(); }; struct callable { b * mb; void operator()() { // not compile: 'void a::a()' protected within context // mb->a(); } }; void b::call1() { // how access a() ?! [&]() { a(); }(); } void b::call2() { callable c{ }; c(); } int main() { b b; b.call1(); b.call2(); } is there way emulate behavior in callable struct,

c# - Is there a way to simplify this with a loop or linq statement? -

i'm trying find out if there way create loop example code below // objects below create list of decimals var ema12 = calc.listcalculationdata.select(i => (double)i.ema12); var ema26 = calc.listcalculationdata.select(i => (double)i.ema26); var ema = calc.listcalculationdata.select(i => (double)i.ema); var adl = calc.listcalculationdata.select(i => (double)i.adl); var r1 = goodnessoffit.rsquared(ema12); var r2 = goodnessoffit.rsquared(ema26); var r3 = goodnessoffit.rsquared(ema); var r4 = goodnessoffit.rsquared(adl); i'm trying similar below pseudo code. please keep in mind each var item list of decimals foreach (var item in calc.listcalculationdata.asenumerable()) { var item2 = calc.listcalculationdata.select(i => (double)item); var r1 = goodnessoffit.rsquared(item2); } more information: listcalculationdata list of custom class have added below. i'm trying cycle through each variable in class , perform select query perform goodness of fi

jestjs - How to use a specific webpack config file for running Jest? -

i trying write test using jest , import es6 module. using webpack3 , jest 21.0.2. test code starts with import const 'util/const'; this throws error "syntaxerror: unexpected token import". have development.webpack.config.js , production.webpack.config.js files development , production build. webpack.config.js files reads env variable , determines file refer. below code part of development.webpack.config.js handle error: env: { test: { presets:['react',["es2015"]], plugins: ["transform-es2015-modules-commonjs", "dynamic-import-node"] } } it seems when run npm test, jest not referring development.webpack.config.js. there way set specific webpack config file when running jest?

javascript - Polymer - Vaadin Date Picker; Vaadin Grid: How to change date format? -

Image
does know how change date format vaadin-date-picker? i'm using polymer , vaadin-grid , cannot change date format. the code of vaadin-date-picker.html element is: <!-- @license copyright (c) 2017 vaadin ltd. program available under apache license version 2.0, available @ https://vaadin.com/license/ --> <link rel="import" href="../polymer/polymer-element.html"> <link rel="import" href="../polymer/lib/mixins/gesture-event-listeners.html"> <link rel="import" href="../iron-dropdown/iron-dropdown.html"> <link rel="import" href="../iron-media-query/iron-media-query.html"> <link rel="import" href="../vaadin-themable-mixin/vaadin-themable-mixin.html"> <link rel="import" href="vaadin-date-picker-overlay.html"> <link rel="import" href="vaadin-date-picker-mixin.html"> <link rel="import"

autohotkey - Solution to AHK sending too many events when holding down a mouse button? -

when using 3 different methods of holding down left mouse button: mouseclick, left, 0, 0, 1, , d, r or send {lbutton down} or click down the game i'm making macro logs me out complaining i'm sending many actions. tested script, like: f3:: click down return so there's no chance other code causing it. i wondering if there settings can use (by settings mean coordmode, mouse, screen ) or other solution perhaps prevent whatever rapid event sending ahk using simulate mouse button being held down. there possible fix can try? i'm open testing ideas. well, introduce sleep so: lbutton:: while (getkeystate("lbutton", "p")) { mouseclick, left sleep, 100 } return though dislike binding mouse click behaviours via same mouse click, can lead results difficult out of. here's example toggleable hotkey. insert:: sendinput, {lbutton down} loop { sleep, 100 if getkeystate("insert", "p"

Age restriction using Javascript -

i new javascript absolutely little idea language. trying put age restriction in job application form date of birth text field, date format dd/mm/yyyy , applicants must @ between 15 , 80 years old @ time fill in form otherwise won't able apply. not want embed html file write in .js file only. for dob input type text, name dob, id dob, pattern (0[1-9]|1[0-9]|2[0-9]|3[01])/(0[1-9]|1[012])/[0-9]{4} thank you. you can use min , max attributes of html5 input date html: <input type="date" id="txtdate" /> javascript : var dttoday = new date(); var month = dttoday.getmonth() + 1; var day = dttoday.getdate(); var year = dttoday.getfullyear(); var maxyear = year - 18; if(month < 10) month = '0' + month.tostring(); if(day < 10) day = '0' + day.tostring(); var maxdate = maxyear + '-' + month + '-' + day; va

node.js - nodejs, http, legacy servers, and "HPE_UNEXPECTED_CONTENT_LENGTH" -

running simple http request in nodejs web crawling purposes. unfortunately, 1 website we're trying crawl configured such has content-length header twice . this throwing error on nodejs: error: parse error @ error (native) @ socket.socketondata (_http_client.js:363:20) @ emitone (events.js:96:13) @ socket.emit (events.js:188:7) @ readableaddchunk (_stream_readable.js:176:18) @ socket.readable.push (_stream_readable.js:134:10) @ tcp.onread (net.js:548:20) bytesparsed: 239, code:'hpe_unexpected_content_length' }, isoperational: true, bytesparsed: 239, code: 'hpe_unexpected_content_length' i'm trying find workaround doesn't involve downgrading nodejs server... ideas?

Populate a Listview with 2 columns from text file c# WPF -

super noob question. sorry...very new c# wpf. split txt. file 2 columns in list view. txt file listview . hostname: land under "item" , actual host name fall under "details" , forth rest of file. think need split string , array , foreach, lost @ point...help.

javascript - How to choose and work with a drop down list in js -

i got problem. created drop down list choosing algorithm work with. works first option not of them. please me? thanks in advance var form1 = document.getelementbyid('form1'); var form2 = document.getelementbyid('form2'); var form3 = document.getelementbyid('form3'); var formarray = []; formarray.push(form1.innerhtml); formarray.push(form2.innerhtml); formarray.push(form3.innerhtml); //select drop down list// function changetocal() { dropdownlist.selectedindex--; document.getelementbyid('form').innerhtml = formarray[dropdownlist.selectedindex]; } //calculate // document.getelementbyid('form').addeventlistener("submit", function(event) { var fieldy = document.getelementbyid('fieldy'); var fieldx = document.getelementbyid('fieldx'); var resultfield = document.getelementbyid('resultfield'); var x = parsefloat(fieldx.value); var y

javascript - Why is persisting data not working as it should? -

i'm working 3 tabs called 'monday', 'tuesday' , 'favorites'. have toggle icon empty heart @ start 'favorite i'. if i'm in monday , click on icon, empty heart turns filled out , parent cloned , added '#fav' tab. when happens clone saved local storage. if people refresh page, can still see preferences. when heart clicked in 1 of cloned divs specific div removed '#fav' , removed array. everything works well, except when refresh browser , local storage detected. so, in case if i'm in monday , click on filled heart doesn't remove clone #fav , still adds new clone #fav. also, if i'm in #fav tab, when clicking in 1 of hearts, should erase index array, in fact, erases full array. how overcome issue? many thanks. html: <section id="speakers-programme"> <div class="container"> <div class="tabs_main"> <div class="col-md-5"><a data-targ

ruby on rails - How to test rake tasks with Whenever Gem? -

i'm trying execute simple rake task using whenever gem code isn't being executed. i set environment development, updated cron using whenever --update-crontab command , rake task works if run command on console. but, when run server log file not being generated. i saw question here same problem solved setting environment development, didn't work out me. my rake task: namespace :testando task :consulta => :environment produto = produto.first puts produto.nm_produto end end my schedule.rb: set :output, "#{path}/log/cron_log.log" set :environment, 'development' every 1.minute rake "testando:consulta" end i'm using rails 5.0.0.1 , i'm programing in cloud9, think os ubuntu. what's missing ? update: i followed instructions of main answer in topic cron job not working in whenever gem and worked! task running server not being started (with "rails s" command). please run crontab -

swift - How do I get Firebase to add new users and not overwrite current users (iOS, Xcode 8)? -

this code keeps overwriting database after new user created. code have put in: func handleregister () { guard let email = emailtextfield.text, let password = passwordtextfield.text, let name = nametextfield.text else { print("form not valid") return } auth.auth().createuser(withemail: email, password: password, completion: {(user: user?, error) in if error != nil { print(error.self) return } guard (user?.uid) != nil else { return } }) let ref = database.database().reference(fromurl: "//firebase link") let usersreference = ref.child("users").child("uid") let values = ["name": name, "email": email] usersreference.updatechildvalues(values, withcompletionblock: { (err, ref) in if err != nil { print(err

javascript - iPhone HTML disable double tap to zoom -

i designing website focused on data entry. in 1 of forms have buttons increment , decrements number value in form field quickly. using <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> to disable zoom appeared work using firefox app ios. however, when user tested safari, clicking on button fast resulted in zooming in on page, distracting user , making impossible increase value quickly. appears of ios 10, apple removed user-scalable=no accessibility reasons, that's why works in 3rd party browsers firefox. closest found disabling double tap zoom this var lasttouchend = 0; document.addeventlistener('touchend', function (event) { var = (new date()).gettime(); if (now - lasttouchend <= 300) { event.preventdefault(); } lasttouchend = now; }, false); from https://stackoverflow.com/a/38573198 however, disables tapping altogether, although

entity framework - Connection string not working with MySQL -

i creating rest api using mysql db in visual studio 2015 in asp.net mvc 4.5 . have done each , every step in needed run api using mysql , getting exception. {"message":"an error has occurred.","exceptionmessage":" format of initialization string not conform specification starting @ index 121. ","exceptiontype":"system.argumentexception","stacktrace":" @ system.data.common.dbconnectionoptions.getkeyvaluepair(string connectionstring, int32 currentposition, stringbuilder buffer, boolean useodbcrules, string& keyname, string& keyvalue)\r\n @ system.data.common.dbconnectionoptions.parseinternal(hashtable parsetable, string connectionstring, boolean buildchain, hashtable synonyms, boolean firstkey)\r\n @ system.data.common.dbconnectionoptions..ctor(string connectionstring, hashtable synonyms, boolean useodbcrules)\r\n @ system.data.common.dbconnectionstringbuilder.set_connectionstring(string