Posts

javascript - Detecting when a long request has ended in NodeJS / Express -

javascript - Detecting when a long request has ended in NodeJS / Express - i'm dealing server-sent events, pseudo-code looks this: var listeners = []; app.get('/stream', function (req, res) { listeners.push({ req: req, res: res }); }); // ... happens notify(listeners); now works quite fine acutally, how know when client closes browser window don't run out of memory eventually? have manage client-side or there req.on('close', fn); can't find? thanks in advance. :) using request's close event should work fine: var listeners = []; app.get('/stream', function (req, res) { var listener = { req: req, res: res }; listeners.push(listener); req.on('close', function() { listeners.splice(listeners.indexof(listener), 1); }); }); javascript node.js express server-sent-events

Tkinter grid() alignment issue in python -

Tkinter grid() alignment issue in python - i have been working in python first time , trying these labels align in right columns , right row reason doesn't move downwards rows , columns not right either. help much appreciated! code: tkinter import * import sys #setup gui #create main window main = tk(); #create title of main window main.title = "waterizer 1.0"; #create default size of main window main.geometry("1024x768"); #lets fram stick info in plan on using mainapp = frame(main); #snap grid mainapp.grid(); #font main labels labelfont = ('times', 20, 'bold'); #label powerfulness powerlabel = label(mainapp, text="power status"); powerlabel.config(fg="red", bd="1"); powerlabel.config(font=labelfont); powerlabel.grid( row=0,column=20,columnspan=4, sticky = w); #label water waterlabel = label(mainapp, text=...

javascript - jQuery: Duplicating file input groups -

javascript - jQuery: Duplicating file input groups - i'm trying utilize jquery duplicate file input groups, when user selects file upload, automatially creates file upload field , description field. this works fine, except when alter file of file i've selected input for. when that, duplicates file input groups. any insight why going on? jsfiddle: http://jsfiddle.net/czlmbjd6/4/ html: <div id = "add-photos"> <input type="file"></input> <label>description:</label> <input type = "text"></input> </div> <div id = "additional-photos"> </div> js: $(document).ready(function(){ bindfileinputs(); }); function bindfileinputs(){ $("input:file").change(function (){ addphotofield(); }); } function addphotofield() { var id = 1; //standin now, dynamically update number later createphotofield(id)...

java - Why am I getting a Identifier expected error -

java - Why am I getting a Identifier expected error - import java.util.*; public class students { public static void main(string[] args){ scanner scan=new scanner(system.in); pupil s1=new student();//creates object of class aircraft pupil s2=new student(); //or //student s1,s2 //s1=new student(); //s2=new student(); string str; int i; //str=s1.getname(); } } class student{ //extends students{ string name; int 1; ?<identifier> expected? int 2; ?<identifier> expected? int 3; } } in lastly 3 lines identifier expected. why? pupil class supposed store name, , 3 test scores. in java, variables not allowed start numbers - 1 invalid variable name (though num1 valid). see the naming requirements. to prepare code, rename them int var1 , int var2 , int var3 . (though improve names improve - seek more descriptive) java identifier

Error sending an email CakePHP -

Error sending an email CakePHP - i "unknown email configuration 'gmail' " error , while trying send email using cakephp ,is because i'm sending localhost (xampp) ? if($this->user->save($this->request->data)){ $message='click on link below finish registration '; $confirmation_link='www.sitename.com/users/verify/t:'.$hash.'/n:'.$this->data['user']['username'].''; app::uses('cakeemail', 'network/email'); $email = new cakeemail('gmail'); $email->email->from = 'myemail@gmail.com'; $email->email->to=$this->data['user']['email']; $email->email->subject = 'confirm registration'; $email->email->smtpoptions = array( 'host' => 'ssl://smtp.gmail.com', 'port' => 465, 'username' => 'myemail@gmail.com',...

python - How to check if the signs of a Series conform to a given string of signs? -

python - How to check if the signs of a Series conform to a given string of signs? - for illustration have series below, ts = pd.series([-1,-2.4,5,6,7, -4, -8]) i know if there pythonic way check signs of ts against list of signs, such as, sign = '++++---' # returns false while sign = '--+++--' # returns true this solution requires numpy functions, since using pandas info series, not issue you. import pandas pd import numpy np values = pd.series([-1, -2.4, 5, 6, 7, -4, -8, 0]) sign_str = "--+++--0" sign_map = { "+" : 1, "0" : 0, "-" : -1 } expected_signs = list(map(sign_map.get, sign_str)) observed_signs = np.sign(values) np.all(expected_signs == observed_signs) python pandas series

html5 - Chrome on Android: createObjectURL containing image blob captured from camera is broken -

html5 - Chrome on Android: createObjectURL containing image blob captured from camera is broken - this worked me before, broken on few (but not all) android devices using chrome (v38 canary/beta broken). if input set capture camera, blob returned invalid (a broken image appears). if unset attribute , take gallery instead, image loads fine. works on phone, not on few tablets. does know if has changed in chrome? unfortunately, not sure if chrome on broken devices has been updated. html: <form action="" method="post" id="edit_form" enctype="multipart/form-data"> <input {$readonly} id="input" type="file" accept="image/*" capture="camera" /> <div class='fileinput-preview thumbnail' data-trigger="fileinput" style="min-height: 267px; width: 200px; border: 1px solid black;" id="photo_front"></div> javascript: $("#in...