Posts

javascript - SyntaxError: Use of const in strict mode -

i'm working node.js, , in 1 of js files i'm using const in "strict mode" . when trying run it, i'm getting error: syntaxerror: use of const in strict mode. what best practice this? edit: 'use strict' const max_image_size = 1024*1024; // 1 mb the const , let part of ecmascript 2015 (a.k.a. es6 , harmony), , not enabled default in node.js 0.10 or 0.12. since node.js 4.x, “all shipping [es2015] features, v8 considers stable, turned on default on node.js , not require kind of runtime flag.”. node.js docs has overview of es2015 features enabled default, , require runtime flag . upgrading node.js 4.x or newer error should disappear. to enable of ecmascript 2015 features (including const , let ) in node.js 0.10 , 0.12; start node program harmony flag, otherwise syntax error. example: node --harmony app.js it depends on side strict js located. recommend using strict mode const declarations on server side , start server harmony flag....

php - Mysql - get 6 results before and after the desired value to make comparison chart -

today facing challenge me, solve multiple queries, little bit of php , other funny things, wondering whether mean can achieved single query and/or stored fn/procedure. i explain myself better: in list of cities, need pick value (say "general expenses") of named city (say "rome"). pretty simple. what is: have 6 records same value before , 6 after rome one. see something: | position | city | expenses | | 35 | paris | 1364775 | | 36 | milan | 1378499 | | 37 | new york | 1385759 | | 38 | london | 1398594 | | 39 | oslo | 1404648 | | 40 | munchen | 1414857 | | 41 | rome | 1425773 | *** <--this value need | 42 | dublin | 1437588 | | 43 | athen | 1447758 | | 44 | stockholm | 1458593 | | 46 | helsinki | 1467489 | | 47 | moscow | 1477484 | | 48 | kiev | 1485665 | these values populate bars chart. as can see there complexit...

python - numpy broadcast from first dimension -

in numpy, there easy way broadcast 2 arrays of dimensions e.g. (x,y) , (x,y,z) ? numpy broadcasting typically matches dimensions last dimension, usual broadcasting not work (it require first array have dimension (y,z) ). background: i'm working images, of rgb (shape (h,w,3) ) , of grayscale (shape (h,w) ). generate alpha masks of shape (h,w) , , want apply mask image via mask * im . doesn't work because of above-mentioned problem, end having e.g. mask = mask.reshape(mask.shape + (1,) * (len(im.shape) - len(mask.shape))) which ugly. other parts of code operations vectors , matrices, run same issue: fails trying execute m + v m has shape (x,y) , v has shape (x,) . it's possible use e.g. atleast_3d , have remember how many dimensions wanted. how use transpose: (a.t + c.t).t

ios7 - iOS 7 change tabBar selected icon -

i've created tabbar in storyboard , set custom image. want use different image "selected" state, know can't set image using storyboard how do programmatically? i want change icon tint colour in code can't make happen either. i appreciate please. try in appdelegate.m file [tbc.tabbar setselectionindicatorimage:[uiimage imagenamed:@"your_image_name.png"]]; where tbc - tabbarcontroller uistoryboard *iphonesb = [uistoryboard storyboardwithname:@"main_iphone" bundle:nil]; customtabbarcontroller *tbc = [iphonesb instantiateinitialviewcontroller];

jquery - Detect if the select box scroll bar has reached to bottom -

i have select dropdown , want load more options in when scroll bar reaches @ bottom not do. used following code did not work me $(function () { var $win = $('#couponproduct_0_id_brand'); $win.scroll(function () { if ($win.scrolltop() == 0) alert('scrolled page top'); else if ($win.height() + $win.scrolltop() == $(document).height()) { alert('scrolled page bottom'); } }); }); found answer here instead of automatically loading more list-items, suggest placing button users can tap load more (but that's suggestion). reference check out pulgin

c++ - push_back object reference -

as saw code, wondering run without problems. the object passed reference isn't copy of it. if put reference vector , object out of scope, shouldn't accessible anymore. but does. reason why works push_back() creates copy of referenced object. answer of behavior? struct struct1 { int value; }; std::vector<struct1> testvect; void pushvect(struct1 & element) { testvect.push_back(element); } void fillvect() { struct1 s1; (int = 0; < 10; i++) { s1.value = i; pushvect(s1); } } the push_back methods of vector taking care of making copy itself: c++ reference adds new element @ end of vector, after current last element. content of val copied (or moved) new element. so during call estvect.push_back(element); the vector works copy. therefore there no problem.

ruby on rails - How to generate reset password token -

i using devise gem authentication. in application admin create users, want user's reset password link when admin creates users. this action:- def create @user = user.new(user_params) @user.password = '123123123' @user.password_confirmation = '123123123' if @user.save @user.update_attributes(:confirmation_token => nil,:confirmed_at => time.now,:reset_password_token => (0...16).map{(65+rand(26)).chr}.join,:reset_password_sent_at => time.now) usermailer.user_link(@user).deliver redirect_to users_path else render :action => "new" end end this link reset user's password but getting reset password token invalid when open link , update password. you can use user.send_reset_password_instructions that.