Posts

c++ - Forwarding tuple arguments to a function in VS2012 -

i'm trying forward tuple arguments function in vs2012 (update 3). my understanding this possible in c++11 using variadic templates, unfortunately, vs2012 supports "fake" variadics. auto values = std::make_tuple(4, 8); auto add = [](int a, int b) -> int { return + b; }; auto result = forward_to_function(add, values); i'm hoping there way in vs2012 implement functionality shown above, i'm not sure, possible without true variadics? i saw mention of such "exploder" in channel 9 video. think recent "going native" (andrei?) reported having full general solution, not presented. there less complete workable solutions talked about. if can wait, current vs preview compiler has true variadics. look how boost it: implement whole bunch of args, special flag type default argument indicates missing. normally, function (not class) overload it. overloading templated functions fine, too: arguments forward_to_function must exp...

java - How to check a String for multiple items in a String ArrayList -

i have arraylist , add strings i'm checking this. arraylist<string> al = new arraylist<string>(); al.add("is"); al.add("the"); then have method returns match found in string in arraylist. public static string getword(string str1, arraylist<string> list) { for(int = 0; < list.size(); i++) { if(str1.tolowercase().contains(list.get(i))) { return list.get(i); } } return false; } although when want check string has more 1 match returns fist 1 added arraylist, so al.add("is"); al.add("the"); it return "is" if add them this al.add("the"); al.add("is"); it return "the" i need way of determining how many matches there , returning them individually. try use map hold, key string in list , value count matched public static void main(string[] args) throws exception { list<string> list = new a...

Regex replace for String, 3 characters from the end -

i have been able add space string in input field using following: onkeypress="this.value=this.value.replace(/^(\w{5})(?=\w)/,'$1 ')" but count start end of line, , add space after user input has stopped. i've tried onblur, not seem work in chrome. any tips? thanks just guess - onkeypress="this.value=this.value.replace(/(\w{5})(?=\w$)/,'$1 ')"

html - Express/Solve formula with Javascript -

i trying create form allow variables inputted , given formula solved. stumbling on how express formula , how make first 2 variables understood exponent. here complete formula works in excel (cell labels replaced input names html): =varnk * varqr * ( 273 + vart ) / ( 273 + varto ) * varpp / varp * varkq * varkak note "varnk" , "varqr" values entered exponents - i.e. 97.53^12 edit: actual formula (link image don't have enough rep post directly)- http://mattk.net/dwformula1.png here attempted make work. wasn't sure correct way assemble final output, ideally want figure out how make single button operation. <head> <script> function docalcone() { var varnk = document.getelementbyid('varnk').value; var varqr = document.getelementbyid('varqr').value; var vart = document.getelementbyid('vart').value; var varto = document.getelementbyid('varto').value; ...

php - CakePHP-Ask about the logo and other affections? -

Image
sorry have make new question this, because don't know keywords ask problem. i studying cakephp. when make page query list user db , make page navigation inside. ok when add logo top of website. ok if stay on page, when click navigation page. disappear (look link of image broken). this 1 ok when don't click navigation page. and 1 broken. my question is: how fix problem. because not logo, things else have same problem too, want wil appeared on everypage or action. can me this. update: have find way solve problem. use helper make img. instead, use html tag show img. use helper in cakephp like: <?php echo $this->html->image ( 'cakeicon.jpg', array ( 'alt'=>'td-cakephp', 'height'=>'50px', 'width'=>'50px' ) ); ?> i update research situation can solved more easily.

javascript - Can Sequelize.js for Node.js define a table where the Primary Key is not named 'id'? -

i have simple mysql table named things . things table has 3 columns: column name data type =========== ============ thing_id int // auto increment primary key thing_name varchar(255) thing_size int as far can tell sequelize.js expects/requires primary key named 'id'. is there way use standard sequelize.define() call define things table? if not, there way? try var test = sequelize.define( 'things', { thing_id : {type: sequelize.integer(11), primarykey: true, autoincrement: true}, thing_name : {type: sequelize.string(255)}, thing_size : {type: sequelize.integer} },{ }); test.sync() .success(function(){ console.log('table created'); }) .error(function(error){ console.log('failed', error) })

download stock data with R -

i~m trying download stock data r these code: #load packages library(stockportfolio) library(quadprog) #get data of returns stocks <- c( "spy", "efa", "iwm", "vwo", "lqd", "hyg") returns <- getreturns(names(stocks), freq="week") but i'm getting error: it's not possible open connection: http status: '404 not found' #load packages library(stockportfolio) library(quadprog) #get data of returns stocks <- c( "spy", "efa", "iwm", "vwo", "lqd", "hyg") returns <- getreturns(stocks, freq="week") returns time scale: week average return spy efa iwm vwo lqd hyg 0.0011957600 0.0002371890 0.0012480337 0.0005973494 0.0011942381 0.0012353135