Posts

Showing posts from September, 2012

c# - Enums in lambda expressions are compiled differently; consequence of overload resolution improvements? -

while trying out visual studio 2015 rc, received run-time error on working code. given lambda (x => x.customerstatusid == customerstatuses.active) passed function expression<> , debugger shows difference in expression tree. formerly compiled this: .lambda #lambda1<system.func`2[services.dataclasses.customerdc,system.boolean]>(services.dataclasses.customerdc $x) { (system.int32)$x.customerstatusid == 0 } but in c# 6.0 compiles .lambda #lambda1<system.func`2[services.dataclasses.customerdc,system.boolean]>(services.dataclasses.customerdc $x) { (system.int32)$x.customerstatusid == (system.int32).constant<services.dataclasses.customerstatuses>(active) } although fix tree-traversing code straightforward , additional detail appreciated, know of other gotchas floating around this? alternately, have link information on specifics of how overload resolution improved? cannot find any. this has nothing overload resolution. previous co...

arraylist - Distinguishing between the different data types in Java -

i have text file contains following: hello 1 2 3 4 5.6 lol 23.5 34.6 23 456 rofl. i wrote down code in java read contents of text file , distinguish between 3 data types.i used try catch statements , code works(kinda). problem converts whole numbers doubles well. example following code outputting: list of integers in textfile: [1, 2, 3, 4, 23, 456] list of doubles in textfile: [1.0, 2.0, 3.0, 4.0, 5.6, 23.5, 34.6, 23.0, 456.0] list of strings in textfile: [hello, 5.6, lol, 23.5, 34.6, rofl] i want prevent happening. suggestions appreciated. arraylist<integer> data_int=new arraylist<integer>(); arraylist<string> data_string=new arraylist<string>(); arraylist<double> data_double=new arraylist<double>(); while(file.hasnext()) { string s=file.next(); system.out.println(s); try { integer.parseint(s); data_int.add(integer.parseint(s)); } catch(nu...

css - media Query for macbook pro 15" -

i'm trying apply media query laptop 15" , smaller no success. here media query: @media screen , (min-device-width: 1200px) , (max-device-width: 1600px) , (-webkit-min-device-pixel-ratio: 1) { } and: @media screen , (min-device-width: 1200px) , (max-device-width: 1600px) , (-webkit-min-device-pixel-ratio: 2) , (min-resolution: 192dpi) { } i works 13inch macbook pro no 15". any appreciated. thanks it might problem with, should work on mobile devices (tablet, smartphones): min-device-width try using (without -device-) min-width or max-width styles desktop @media screen , (min-width: 1025px) , (max-width: 1280px) { /* styles desktops */ } also add inside tag <meta name="viewport" content="width=device-width, initial-scale=1">

css - Wordpress Drop Down Menu on Mobile Not Responding / Working -

im hoping can me solve issue. have started using wordpress instead of coding , stuck on drop down menu right. site newsby2.com looks great , how want on laptop , menu not drop down on laptop when go mobile supposed drop down not responding. word menu appears in red , when click on it changes white color nothin comes down. ive tried putting inline on of codes did displayed submenu right away without me having click on it. want when click on word menu sub menu appear. /*--------------mobile menu-------------------*/ #mobile-menu { display:none; position:relative; margin:0 15px; } #mobile-menu > span { display:inline-block; text-transform:uppercase; font-family:'rokkitt', serif; font-size:24px; cursor:pointer; color:#e03d3d; } #mobile-menu > span:hover { color:#fff; } #toggle-view-menu { display:none; list-style: none; margin: 0; padding: 0; border-top: none; position:absolute; top:33px; left:0; z-index:99999; width:220px; } #toggle-view-menu > li { margin: 0; pos...

arrays - Looping through a Vector -

i using rstudio , trying create function loop through vector , perform calculation while condition. function should return data frame entered vector in 1 column , number of iterations took satisfy while condition in another. have created function preformed calculation while condition serves basic operation function having problems with. here is: t5<-function(x){ z=x while(x != 1){ if(x %% 2 == 0) x= x/2 else x= (3 * x +1) z=c(z, x) } return (z) } here have new function...my problem function (t7): t7<-function(x){ y=0 i=0 for(i in 1:length(x)){ y[i]=length(t5(x[i]))-1 print(y[i]) } #m<-data.frame(x, y[i]) } i had print y[i] because way function something. here output shows (which half of need): t7(2:10) [1] 1 [1] 7 [1] 2 [1] 5 [1] 8 [1] 16 [1] 3 [1] 19 [1] 6 can me understand how make t7(2:10) run through array , return data frame listing array , number of iterations took...

git status : bad config value for 'core.autocrlf' in .git/config -

i getting following error on doing following $ git status fatal: bad config value 'core.autocrlf' in .git/config i same result git branch or other command suggestions on cause might ? [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true hidedotfiles = dotgitonly autocrlf = = [remote "origin"] url = git@mst-git:tgi-common/gcmmon.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master [submodule "experience"] url = git@mst-git:tgi-windows-os/exp.git [submodule "module"] url = git@mst-git:tgi-general-tools/module.git not sure how did it, remove line in file says autocrlf = =

Measure jQuery plugin requirements -

i'm developing jquery plugin don't know version of jquery minimal plugin run. is there way measure requirements of jquery plugin ? a couple of ideas: i haven't used quick search turned $versions claims easy way of testing plugin against multiple versions of jquery. if have page tests/demos need check, put code in jsfiddle , run down list of versions of jquery in frameworks & extensions menu.

php - Update field with result of DateDiff of two other populated fields -

all need take 2 datetime fields , set third field result. this has easy i've been working on 2 days , cannot result i'm looking for. $con = mysqli_connect(dbhost, dbuser, dbpass, dbname) or die('connection failed: ' . mysqli_connect_error()); $helpme=mysqli_query($con, "update chat_main set exact_time = datediff(start_timestamp, end_timestamp)"); mysqli_close($con); the issue datediff returns number of days between 2 dates. appears in context of implementation, 2 dates on same day. so, 0 result of datediff. suggest using timediff, difference of 2 times, not 2 dates.

jquery - Can someone help me pinpoint my Javascript error for a simple Ajax request using Google Street Map API? -

i'm not familiar javascript i'm following along udacity tutorial learn more javascript , ajax. below have following code supposed grab image google street view api , append image onto body. here code: function loaddata() { var $body = $('body'); var $wikielem = $('#wikipedia-links'); var $nytheaderelem = $('#nytimes-header'); var $nytelem = $('#nytimes-articles'); var $greeting = $('#greeting'); // clear out old data before new request $wikielem.text(""); $nytelem.text(""); // load streetview // code goes here! var $streetinput = $('#street').val(); var $cityinput = $('#city').val(); var $googlestreeturl = 'https://maps.googleapis.com/maps/api/streetview?size=400x600&location=' + $streetinput + ' ' + $cityinput $.ajax($googlestreeturl, { success: function() { $body.append("<img class='b...

accessing variables from main method in python idle -

so know if create python file no main method declared , run it, i'm able access variables within file idle, if declare main method, cannot access variables idle after main method has finished running. does know if there's workaround i'm able use methods in python program, while being able access variables within them in idle? if declare variable inside method/function in scope life of method or function. can't access them outside. if want variable available declare in global space , import other function/class. file1.py some_var = whatever def foo(): another_var = 42 def bar(): return 42 file2.py from file1 import some_var will give acces some_var not able access another_var unless return form function , save this from file1 import bar another_var = bar() you can access variable in function while function running using pdb library so: >>> def foo(x): import pdb; pdb.set_trace() # 1 of rare times it's okay im...

use of random() and randomize() in C++ -

please explain me how code providing gives output : 1 2 3 4 5 6 7 8 9 10 11 #include<stdlib.h> #include<iostream.h> int main() { randomize(); int num, rndnum; cin >> num; rndnum = random(num) + 7; (int n =1; n<=rndnum; n++) cout << n <<""; } please explain me code snippet well taking input num user , passing random() function. taking returned value function , adding 7 , assigning rndnum . looping through 1 rndnum , printing of each of numbers (1, 2, ...., rndnum). in case of printing out 1 - 11 must have gotten return value of 4 random(num) .

activerecord - Parent object eager load nested associations Rails -

in rails 4 have following models class parent < activerecord::base has_many :sons has_many :grand_sons, through: sons scope :load_tree, (id) -> {parent.includes(sons: [:grand_sons]).find(id)} end class son < activerecord::base belongs_to :parent has_many :grand_sons end class grandson < activerecord::base belongs_to :son end with load_tree obtain object like: { id: 1, sons: [ { id: 1, parent_id: 1, grand_sons:[ { id: 1, son_id: 1, } , ...] }, ... ] } but after doing tree = parent.load_tree(1) got tree # <parent id=1> tree.sons #[<son id=1>, <son id =2>] seems not able eager load objects, suggestions? try parent.includes(:sons, {:sons => :grand_sons}).find(id) my understanding is, must specify relationship nested associations explicitly.

cmake - How can I build a C++ project with multiple interdependent subdirectories? -

i have c++ project i've used directories more of organizational element -- way 1 might use packages in java or directories in php. directories not intended self-sufficient elements, rather way of organizing whole of project , keeping me being overwhelmed sources. how can construct cmakelists.txt files deal this? making directories libraries doesn't seem fit here, since interdependent , not intended used way. as related issue, of examples i've seen of multiple subdirectories in cmake (and there aren't many of those) have ignored or glossed on issue of setting include_directories , i've been having trouble with. short of combing source files determine file depends on , in directory, there anyway set directories under /src/ potential include directories , let cmake work out ones dependent? here's example structure: --src --top1 --mid1 --bot1 --src1.cpp --hdr1.h --bot2 --src2.cpp --hdr2.h --mid2 ...

c++ - Multiple destructor calls -

i ran following code.. #include <iostream> using namespace std; class base { protected: int count=0; public: base() { cout << "constructor called" << endl; } ~base() { cout << "destructor called" << endl; } int getcount() {cout << "the count value " << count << endl;} base operator ++ (int) {count++; cout << "postfix increment called" << endl;} base operator ++ () {count++; cout << "prefix increment called" << endl;} }; class derived : public base { public: base operator --(int) {count--; cout << "postfix decrement called" << endl;} }; int main() { derived a; a++; ++a; a--; return 0; } the result constructor called postfix increment called destructor called prefix increment called destructor called postfix decrement called destructor called destructor called my question why dest...

What is an Android Kernal and how does it differ from the Android Version? -

i'm trying understand difference between kernal android , android version. i read this guide explaining kernal , kernal android (answer: special linux kernel), don't understand how differs android version. know 2 different things. android kernal , android version not same thing. does mean android kernal has it's own version separate android version updates totally separately? example, android phone might prompt update it's android version, android phone ever prompt update it's kernal? can have same android version run on 2 different kernals? confused here... your android phone might prompt update it's android version more accurately, android device might prompt install firmware update. replace existing firmware updated edition of android, including kernel. would android phone ever prompt update it's kernal? only in context of prompting install firmware update. can have same android version run on 2 different kernals? ...

Column width not working in datatables bootstrap -

i using following code set column width of datatable. during partial page load width appears correct , when loads completely, width off. <script> $(document).ready(function () { $("#membergrid").datatable({ "dom": 't<"clear">lfrtip', "tabletools": { "sswfpath": "../../content/swf/copy_csv_xls.swf" }, "destroy": true, "info": true, "blengthchange": false, "bfilter": false, "bautowidth": false, "aocolumns": [{ "swidth": "20%" }, { "swidth": "20%" }, { "swidth": "20%" }, { "swidth": "10%" }, { "swidth": "20%" }, { "swidth": "10%" }] }); }); </script> table markup <table...

python - Pandas - reading from SQL server, and outputting to csv - encoding problems -

i reading data pandas sql server 2014 12.0.4100 sp1 database. data stored in windows-1252 encoding. i using python 2.7. i want output resulting dataframe excel or csv. specifically: import pyodbc cnxn = pyodbc.connect(r'driver={sql server};server=.\my_server;database=my_db;trusted_connection=yes;') sql = "select * my_table" df = pd.read_sql(sql, cnxn) df.to_csv("my_csv.csv", encoding="utf-8") however, fails error message: unicodedecodeerror: 'utf8' codec can't decode byte 0x92 in position 13966: invalid start byte what need export utf-8 csv? the solution convert columns non-ascii characters utf-8 explicitly. you can using following code: def convert(my_str): return my_str.decode('windows-1252').encode('utf-8') df["name"] = df["name"].apply(convert) once converted, able write .csv , excel format without problems.

java - JAXB wrap non-collection fields -

given xml file each value wrapped in it's own element that: <root> <type1> <foo>1</foo> </type1> <type2> <bar>2</bar> </type2> </root> is there easy way map this? @xmlelement("type1/foo") or @xmlelementwrapper("type1") @xmlelement("foo") ? far can tell need create corresponding class model ( root , type1 , type2 ) type1 , type2 provide no added value act wrapper.

sql server - How to pivot dynamic number of columns row result into a verticle result list -

there single row of data in table have varying number of columns named c1, c2, c3.. etc. can locate row want un-pivot dynamic number of columns values single column result... have researched ton on pivot/unpivot stuff examples i've found don't seem handle dynamic number of columns in results. native results: col 1 col 2 col 3 col 4 col 5.... col x id name dob city state desired results: columnnametbd: id name dob city state thank you! tim after feedback question able piece solution. have way physically instanciate structure dynamic/inconsistent structure automatically. declare @scolumnnames varchar(5000) declare @ssql varchar(5000); --flatten list of column names select @scolumnnames = ' ' + ( select '(' + column_name + '),' 'data()' smar_stg.information_schema.columns (nolock) table_name = 'v_etl_ctx_corem_excel_dtl_c...

loops - python: append to end of first line in a text file -

i have loop ending in statsg.append(str(mean)) and after loop np.savetxt(path+'stats.txt',statsg,'%s') so after 2 iterations text file 2 lines of text in stats.txt file. i'd prefer have 1 line of text (i.e. second iteration of loop appends end of first iterations output. your question not clear, can initiate empty string before loop, in each iteration append it. string_to_save = '' line in file: string_to_save += line save_function(file_name, string_to_save) if not helpful edit question more details asked in comments.

Facebook iOS SDK user cookie issue in FBWebdialog -

i getting awkward issue in ios app when try post on friend's wall using fbwebdialog fbconnect://success?error_code=110&error_msg=missing+user+cookie+%28to+validate+session+user%29 in using stored access_token on server , creating session using on every device when user logs in. while cannot sure, issue seems access token using. mentioned 'stored' access token possible access token had expired when made request. answer may point in right direction.

json.net - ASP.NET VNEXT DNU Restore error -

every time try perform package restore in visual studio, error below. same error when using samples github command prompt i.e ( c:\users\xxxxxx\documents\github\aspnet\samples\1.0.0-beta4\hellomvc dnu restore) i set execution environment use following dnx -dnvm use 1.0.0-beta4 -r clr -arch x86 -p i have tried deleting packages .dnx/packages , have tried replacing runtimes, nothing seems work. this may result of installing visual studio 2015 rc on ctp 6; however, have tried uninstalling , re-installing visual studio multiple times. any appreciated. writing lock file c:\users\xxxxxx\documents\visual studio 2015\projects\test3\src\test3\project.lock.json ---------- system.missingmethodexception: **method not found: 'newtonsoft.json.linq.jvalue newtonsoft.json.linq.jvalue.createnull()'.** @ microsoft.framework.runtime.dependencymanagement.lockfileformat.writestring(string item) @ microsoft.framework.runtime.dependencymanagement.lockfileformat.writearray[titem]...

firefox - php output system() in real time -

i'm trying make system call , have each line sent browser in real time echo('<pre>'); system('ping -c 10 www.google.com'); echo('</pre>); this works when call command line (each line of ping output 1 @ time). not work when try open browser (firefox or chrome). i has output buffering enforced browser. not display new data unless above cetrain threshold. solutions these kind of problems typically involve outputting bunch of blank characters, ie str_repeat(' ',1024*64) . can think of way browser display output in real time? you can not way. php request running once , retrun 1 response. also result of system function shown @ end of execution of command. see in command line logs of command self not php code. i suggest use kind of long polling technologies or soquet-io establish continues / real time communication server.

algorithm - Organizing multiple requests to a server -

i have trouble defining problem. setup this: there multiple devices have push data central server. talking 2-3k devices. question how organize request , retries in case of failure, use servers bandwidth efficiently , don't ddos ourselves. devices can't talk each other directly. even search terms helpful, names of algorithms, scientific papers etc. the phrase want "exponential backoff". best practice in wide variety of settings. here top 4 results of google search phrase: http://en.wikipedia.org/wiki/exponential_backoff http://docs.aws.amazon.com/general/latest/gr/api-retries.html https://developers.google.com/api-client-library/java/google-http-java-client/backoff https://msdn.microsoft.com/en-us/library/microsoft.practices.transientfaulthandling.exponentialbackoff.aspx

finding maximum value in python list of tuples -

this question has answer here: how tuple comparison work in python? 2 answers i have list of tuples (list): ('2015-06-19', 3453455, 5, 'scheduled') ('2015-05-19', 6786788, 6, 'overdue') ('2015-04-19', 2342344, 2, 'not received') ('2015-03-19', 9438549, 0, 'not received') ('2015-02-19', 6348759, 7, 'not received') when run this, this: >>> print(max(list)) ('2015-06-19', 3453455, 5, 'scheduled') obviously, max(list) determined max based on first value in list of tuples. i'm wondering if default behavior of max(list) in regards list of tuples; check first item in tuple? and, if wanted return tuple maximum based on second item/column. how that? you can specify field use comparison using lambdas max(list,key=lambda x:x[1]) or alternatively, u...

java - How to sort Strings considering the digits inside them? -

i have codes looking 1 of following: aaa_bbb_d2_aa aaa_bbb_d3_aa aaa_bbb_d11_aa eee_b2b_c2_ac in general should sorted strings, in case of “aaa_bbb_d3_aa” vs. “aaa_bbb_d11_aa” former should come first in contrast simple string sorting. the numerical part important sorting resides after either “_d” or “_c” substring , followed “_aa” or “_ac” ending string. what efficient sorting algorithm in java or sql? collections.sort(yourlistofstring, (string a, string b) -> { int comparison = integer.valueof(a.split("_")[2].replaceall("[dc]", "")).compareto(integer.parseint(b.split("_")[2].replaceall("[dc]", ""))); return comparison == 0 ? a.split("_")[3].compareto(b.split("_")[3]) : comparison; }); (i assume strings in list)

excel - Copying and Pasting a Range of Cells from One Worksheet to Another Worksheet -

i trying copy range of cells 1 worksheet (sheet2) different range of cells in worksheet (sheet1) when run below, run time error (1004) application defined or object defined error. appreciated! option explicit sub deletecolumns() workbooks(1).worksheets(1).columns(2).select workbooks(1).worksheets(1).columns(2).delete sheets("sheet2").range("i4:i29").copy destination:=sheets("sheet1").range("h4:h29") end sub delete line: workbooks(1).worksheets(1).columns(2).select there's no need before doing .delete anyway

JavaScript get last URL segment -

what best way last segment of url (omitting parameters). url may or may not include last '/' character for example http://home/billing/index.html?param1=2&another=2 should result in: index.html http://home/billing/index.html/ should result in: index.html i've tried can't how check last / ar href = window.location.pathname; var value = href.lastindexof('/') + 1); maybe like? window.location.pathname.split('?')[0].split('/').filter(function (i) { return !== ""}).slice(-1)[0] split on '?' throw out query string parameters get first of splits split on '/'. for splits, filter away empty strings get last 1 remaining

ngroute - Angular router's viewContentLoading issue did not work -

i have created set of views using ui-router.then write run() function listen route issue this: $rootscope.$on('$viewcontentloading',function(evt,config){ console.log("one loading!"); }) so want create movement or kind of animate during view content loading,but code above consoled nothing. try state called $viewcontentloaded , same thing,and worked,it consoled expected. but why these 2 issues behave differently? are positive you're setting listeners on correct scopes? $viewcontentloading broadcast on $rootscope while $viewcontentloaded emitted local $scope . this stackoverflow question may shed light on why 2 act different , may figure out what's wrong: $rootscope.$broadcast vs. $scope.$emit maybe can add plunkr showing issue? unable replicate issue.

python - How to execute an .sql file in pymssql -

i'm trying execute sql file in python using pymssql, file contains begin transaction, commit transaction , end, , safety nets before , after. i'm trying open file in memory , execute content: file = open(options.sqlfile, 'r') sqlfilecontents = file.read() file.close() cursor.execute(sqlfilecontents) conn.commit() but it's returning me errors: pymssql.programmingerror: (102, "incorrect syntax near 'go'.db-lib error message 102, severity 15:\ngeneral sql server error: check messages sql server\ndb-lib error message 102, severity 15:\ngeneral sql server error: check messages sql server\ndb-lib error message 102, severity 1 5:\ngeneral sql server error: check messages sql server\ndb-lib error message 102, severity 15:\ngeneral sql server error: check messages sql server\ndb-lib error message 102, severity 15:\ngeneral sql server error: check messages sql server\ndb-lib error message 102, severity 15:\ngeneral sql server error: check messag...

icCube Reporting AmChart balloon text fromatting -

Image
working amchart bubble in iccube reporting, if leave default balloon behavior, which want... want replace x, y , value parameterized axis names... tried put <b>[[title]]</b></br>evo @{anneerefselected} - @{anneefinselected} : [[x]]</br>pdm séjours @{anneefinselected} : [[y]]</br> <b>séjours @{anneefinselected} : [[value]]</b> in widget's graph.balloon text property instead... : the formatting of numbers has gone i loose series name any appreciated, thxs. currently can use fvalue formatted version of value column, third in case. unfortunatly, there no version x , y (fx, fy). add future versions. on meantime value columns have formatted version can use this. assuming have following column labels: column0 , column1 , column2 , column3 , have add following balloon text: <b>[[column0]]</b></br>evo @{anneerefselected} - @{anneefinselected} : [[column1formatted]]</br>pdm séjours @{anneefinsel...

javascript - How to inspect element on popover with unknown identity? -

i running browser tests on chrome , cannot find particular popover in codebase. i figured snag name or id via manual inspect element, of course disappears when try right click it. without identifying information go (unless try js things surrouding divs suspect might live in?), how can handle on element? if it's hover event triggered, in inspect element should able force state. right click code in inspect element , should see things :hover , :focus , maybe :active . select whichever 1 triggers event, , should able view code.

java - "this" does not work in my program -

so basically, i'm doing assignment on game, , i'm trying create key commands. thing not work far addkeylistener(**this**) .i tried fixing ended breaking entire program. code far is: public static void main (string[] args) throws interruptedexception { (int x = 0 ; x < 999 ; x++) { int lvl = 0; int line = 0; write (); line = start (line); (int p = 0 ; p < 999 ; p++) { if (line == 0) { system.out.println ("select level (1-3)"); lvl = in.getint (); if (lvl == 1) { jframe gamu = new jframe ("hoops 1.0"); //jframe runs game in window culminating_mingxuanhe ball = new culminating_mingxuanhe (); gamu.getcontentpane ().add (ball); gamu.setsize (400, 480); //sets size game gamu.setvi...

javascript - AngularJS directive not showing template but others working fine -

i trying add angularjs directive app reason not working. have added other directives before in same way working. have posted code below. html include directive <section class="section-wrap" data-ng-controller="pvprofileviewcontroller"> <div class="container bg_white"> <div> <pv-profile-password-reset pv-user="user"></pv-profile-password-reset> </div> <div> <pv-profile-email-update pv-user="user"></pv-profile-email-update> </div> </div> </section> angularjs directive file 'use strict'; /* * profile email request update section */ angular.module('mean.system').directive('pvprofileemailupdate', ['pvprofile', '$timeout', 'global', 'utilities', function (pvprofile, $timeout, global, utilities) { function controller($scope) { ...

java - Start task using calendar object where just the second is set -

using below code, i'm attempting start thread when second part of time reaches 0 - ie when next minute starts. public class sched { public static void main(string args[]) { calendar calstart = calendar.getinstance(timezone.gettimezone("gmt+1")); calstart.set(calendar.second, 0); scheduledexecutorservice scheduler = executors.newscheduledthreadpool(1); scheduler.scheduleatfixedrate(new sched().new rc(), calstart.gettime().gettime(), 3, timeunit.seconds); } private class rc implements runnable { public void run() { /* impl */} } } but thread not starting. appears not setting start time correctly. run setting initialdelay param 0 , why setting using calendar object not working? fyi, hardcoding initialdelay 0 works (tested on jdk8): scheduler.scheduleatfixedrate(new sched().new rc(), 0, 3, timeunit.seconds); i don't know why you're using calendar object (actually, don't kno...

Php to .xlsm (Macro enabled files) -

i trying use phpexcel library export data .xlsm file.i know macro enabled files not officially supported. know how it?or other way around? phpexcel doesn't support macro reading , writing

How to add integers in 2 arraylists? JAVA -

lets have arraylist = {9,5,3,7} , arraylist b = {4,9,8,7,5}. (the length of 2 arraylists can either same or different.) these arraylists represent numbers (but written in least significant first order) i want create arraylist (result) contains sum of each digit , counterpart in other arraylist. if sum > 9 remainder carries on next digit. above same doing: 7359 + 57894 = 65253 the result must arraylist: result = {3,5,2,5,6}. this have tried: bigint result = new bigint(); int temp=0; int carry=0; bigint bigger = this; bigint smaller = otherbigint; if(this.lessorequal(otherbigint)){ smaller = this; bigger = otherbigint; } for(int i=0; i<bigger.digitlist.size(); i++){ temp= bigger.digitlist.get(i)+smaller.digitlist.get(i)+carry; carry = temp/10; result.digitlist.add(i,temp%=10); } if(carry == 1){ result.digitlist.add(1); } return result; i have no idea wrong codes.. p...

selenium webdriver - How to install Selenium2Library for Robot Framework using pip + Jython? -

since version 2.7.0 jython contains pip bundled in. needs activated running following command before using it: jython -m ensurepip so after should possible install selenium2library robot framework with jython -m pip install robotframework-selenium2library right? but when following error: attributeerror: 'module' object has no attribute 'geteuid' here full cmd / shell output: c:\foldername>jython -m pip install selenium2library traceback (most recent call last): file "c:\jython27\lib\runpy.py", line 151, in _run_module_as_main mod_name, loader, code, fname = _get_module_details(mod_name) file "c:\jython27\lib\runpy.py", line 151, in _run_module_as_main mod_name, loader, code, fname = _get_module_details(mod_name) file "c:\jython27\lib\runpy.py", line 109, in _get_module_details return _get_module_details(pkg_main_name) file "c:\jython27\lib\runpy.py", line 109, in _get_module_details r...

prediction - How to predict on a new dataset using caretEnsemble package in R? -

i using caretensemble package in r combining multiple models trained in caret. have got list of final trained models (say model_list ) using caretlist function same package follows. model_list <- caretlist( x = input_predictors, y = input_labels, metric = 'accuracy', tunelist = list( randomforestmodel = caretmodelspec(method='rf', tunelength=1, preprocess=c('boxcox', 'center', 'scale')), ldamodel = caretmodelspec(method='lda', tunelength=1, preprocess=c('boxcox', 'center', 'scale')), logisticregressionmodel = caretmodelspec(method='glm', tunelength=1, preprocess=c('boxcox', 'c...

c# 4.0 - Code duplication issue inside an if -

i have code duplication want avoid cannot create method containing code because there slight difference in line inside if. here's mean : code 1 : if case1 () { same code if() { same code line1 } code 2 : if case2 () { same code if() { same code line2 } both codes same except 1 line (line1 , line2). since code big want be able copy inside function example. have idea how this? thanks generally speaking, looking action or func . that's type encapsulates executable code: public int yourcommonmethod(int parameter, func<int, int> calculate) { // common code if(calculationneeded) { // common code result = calculate(parameter); } // more common code } you call 2 different calculation methods: int result = yourcommonmethod(5, => + 17); or int result = yourcommonmethod(5, => / 48); for action, need less: public int yourcommonmethod(int paramet...

sql - CROSS APPLY WITH UDF -

Image
create function getbyid ( @id int ) returns table return( select * products productid=@id+10) function above retruns records of products product id grater 10 . when used cross apply below select o.* [order details] o cross apply getbyid(o.productid) p i in result productid less 10 not possible . the example uses nortwind database sample available everywhere . order details table , prodcuts tables linked productid select* getbyid (1) gives result below when udf called (as above) result shows productid < 10 can see error ? if want function return products productid greater 10, should add check clause. example: create function getbyid ( @id int ) returns table return( select * products productid=@id , productid > 10)

ruby on rails - Carrierwave only saves image as tmp in Production-env -

spent whole daying trying work. carrierwaves , fileuploads works fine when doing on development/local-computer, when trying on server env:production , deploying through capistrano files saved in uploads/tmp/ , not stated in image_uploader. def store_dir "#{rails.root}/public/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end i have tried several things suggested when searced nothing have solved problem. furthermore form/post not forward me stay on same page uploaded, doesnt happen when in development/local. here parts deploy.rb thought solve problem: set :linked_dirs, fetch(:linked_dirs) + %w{public/uploads} task :symlink_uploads run "ln -nfs #{shared_path}/uploads #{release_path}/public/uploads" end after :restart, :seed_roles, :symlink_uploads edit question: have move pictures being uploaded tmp want them stored? please following and in set config/initializers/carrierwave.rb carrierwave.confi...

mysql - PDO php pagination -

i have been trying add secure pagination page (from mysql database). after looking online 1 think sqj-injection etc free found: http://www.phpro.org/tutorials/pagination-with-php-and-pdo.html however when use script error: ah01215: php fatal error: call undefined method pager::getpagerdata() in /path....to..etc/index.php on line 62 line 62 is: $pager = pager::getpagerdata($_session['total_records'], $limit, $page); full code: <?php /*** make or break ***/ error_reporting(e_all); /*** begin session ***/ session_start(); /*** include database connection class ***/ include 'db.php'; /*** include pager class ***/ include 'pager.php'; /*** set page name ***/ $page_name = htmlentities($_server['php_self']); /*** set number of results per page ***/ $limit = 20; /*** check session array total_records ***/ if(!isset($_session['total_records'])) { try { /*** first count of records ***/ $sql = ...

database - getting multiple rows from db that are associated to previous selected rows. laravel 4.2 php -

so here problem, for school project have make quiz website in normal user should able play quiz, have show questions associated quiz , answers associated question, when try shows answers associated final question. here code: // select clicked quiz. $quiz = quiz::find($id); // question , answer records db associated selected quiz. $questions = db::table('questions')->where('quiz_id', $id)->get(); foreach($questions $question) { $answers = db::table('answers')->where('question_id', $question->id)->get(); } return view::make("quizzes.makequiz", [ "quiz" => quiz::find($id) ])->with('quiz', $quiz)->with('questions', $questions)->with('answers', $answers); and here html (using blade): <h3>{{ $quiz->name }}</h3><br/> @foreach($questions $question) <h4>{{ $question->question }}...

remove public from url in zend 2 -

i made changes in files following this link. it's working $this->basepath() isn't working in layout.phtml , due css , js not loaded ->prependstylesheet($this->basepath('public/css/bootstrap.min.css')) ->prependfile($this->basepath('public/js/html5shiv.js'), 'text/javascript', array('conditional' => 'lt ie 9',)) zendtest/.htaccess options +followsymlinks -multiviews rewriteengine on rewritebase /zendtest/ rewritecond %{request_uri} !/public [nc] rewriterule ^(.*)$ public/$1 [l] zendtest\module\application\config\module.config.php return array( 'router' => array( 'routes' => array( 'home' => array( 'type' => 'zend\mvc\router\http\literal', 'options' => array( 'route' => '/zendtest/', 'defaults' => array( ...

css - UI Bootstrap tabset show the content right to the tabs -

Image
first of all: i'm totally new @ bootstrap. want use vertical tabset display content right tabs. sketch of idea: <tabset vertical="true" type="tabs"> <tab heading="vertical 1">vertical content 1</tab> <tab heading="vertical 2">vertical content 2</tab> </tabset> but unfortunately didn't make solve this css commands. sexy picture :d <div class="col-xs-3"> <!-- required floating --> <!-- nav tabs --> <ul class="nav nav-tabs tabs-left"><!-- 'tabs-right' right tabs --> <li class="active"><a href="#home" data-toggle="tab">home</a></li> <li><a href="#profile" data-toggle="tab">profile</a></li> <li><a href="#messages" data-toggle="tab">messages</a></li> <li><a href="#setti...

gruntjs - Creating a custom dependency block -

i'm trying load in multiple js dependencies page. per best practice etc i'm loading in js @ bottom of page, have particular js file need load in head. how go making block loads in particular dependency in <head> other js files carry on loading in bottom of page? this particular case happens in yoeman's webapp generator loads modernizr in head , rest of scripts near bottom. if problem dependency facing being injected @ bottom have exclude using following: wiredep: { app: { .... exclude: [ 'bower_components/path-to-the-file-you-dont-want-wiredep-to-inject' ], } } and in head add following: <!-- build:js scripts/vendor/custom-script.js --> <script src="bower_components/path-to-the-file-you-dont-want-wiredep-to-inject"></script> <!-- endbuild -->

check all jquery not working for dynamically populated checkbox -

i have jquery function select checkboxes , populated in php loop. output of loop similar below: <label class="check"><input type="checkbox" name="selectall" value="all"/> select all</label> <label class="col-md-3 col-xs-12 control-label">types of function</label> <div class="col-md-6 col-xs-12"> <div class="col-md-7"> <label class="check"><input type="checkbox" name="chkuser" class="icheckbox"/> birthday</label> </div> <div class="col-md-7"> <label class="check"><input type="checkbox" name="chkuser" class="icheckbox"/> family function</label> ...

iOS: dateformatter in swift return nil -

i have code in app service.requestlastdate{ (response) -> () in var str = response nsstring var d = str.stringbyreplacingoccurrencesofstring("\"", withstring: "") println("d \(str)") // d 2015-05-25 08:13:33 var dateformatter = nsdateformatter() dateformatter.dateformat = "yyyy-mm-dd hh:mm" var date_formatted = dateformatter.datefromstring(d) println("date formatted \(date_formatted)") // nil with code date_formatted ever nil. if print in consolle "d" result "2015-02-12 08:15:16", string real string. if try use string "example" correct date_formatted. happen? can't understand. tried changing nslocale , timezone dateformatter have ever same result. this request func requestlastdate(completion:(response:nsstring)->()){ my_req_date = request(.get, "http://example.com/current_date...

php - Add Filtered Layered Navigation to 1 Column Category Pages in Magento -

i'm running magento 1.9.1.0 rwd theme. when setting page layout 2 columns left bar can see filters in left sidebar correctly (sort price etc). how can working in 1 column page layout (for categories only)? i'd create full-width version of @ top of products using catalin seo catalog layered navigation (for slide price bar etc). the 1column.phtml template not have left block, layer view block injected. 1 way in local.xml put block in content (or after_body_start or before_body_end, or core/text_list child block): <catalog_category_default> <reference name="root"> <action method="settemplate"><template>page/1column.phtml</template></action> </reference> <reference name="content"> <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"> <block type=...

java - How to pass an List<Integer> Object and String in Rest Services in Android -

hi woring quiz app, need call post rest services(json),below 1 sample code not working i need pass 3 thing parameter 1-userid, 2-list questionids , 3- list answerids. question how pass list object not string or json string here- list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(); namevaluepairs.add(new basicnamevaluepair("userid", "121213")); namevaluepairs.add(new basicnamevaluepair("questionsids", listobj); namevaluepairs.add(new basicnamevaluepair("answerids", listobj)); httpclient httpclient=new defaulthttpclient(); httppost httppost = new httppost(url); httppost.setheader(http.content_type,"application/x-www-form-urlencoded;charset=utf-8"); try { httppost.setentity(new urlencodedformentity(namevaluepairs, "utf-8")); } catch (unsupportedencodingexception e) { e.printstacktrace(); } is there other way call post rest service.how re...

TypeScript and member that doesn't give the same value -

i'm developing simple application , have class, in need console.log result of function passed in parameters. context i m trying make simple di container based on ng2 1 (simpler, understand way of work) based on api. so, have injector class, binding class , resolvedbinding class. injector accepts binding in parameters create resolvedbinding objects here injector class : import {resolvedbinding} "./resolvedbinding"; import {binding} "./binding"; export class injector { private _binds:array<resolvedbinding>; constructor(bindings:resolvedbinding[]) { this._binds = bindings; } public static resolveandcreate(binds:array<binding>):injector { return new injector(injector.resolve(binds)); } get(token:any) { (var in this._binds) { if (this._binds[i].key === token) { return this._binds[i].factory(); /*if(new this._binds[i].factory instanceof object...

How to import output from R to an Excel File -

stock_reco<- read.csv("c:\\temp\\migration.csv") migrate<-as.matrix(stock_reco) title<-colnames(migrate) dt1<-migrate[,3] dt2<-as.date(dt1, format= "%d/%m/%y") reco1<-migrate[,6] reco<-as.matrix(reco1) for(i in 1:4099) { if((migrate[i,1]== migrate[i+1,1]) && (migrate[i,2]== migrate[i+1,2])) { k<-difftime(dt2[i+1],dt2[i],units = "days") if((k <=180) && (reco[i] == reco[i+1])) print (migrate[i,]) print (migrate[i+1,]) print ("----------------------------------------------------") } } last 2 print statements give final output in image attached below. want whole final output in excel file. how import output r excel file? want output in form comp name brokerage house date cmp target recomendation yes bank motilal oswal 14/6/2011 294 420 buy yes bank motilal oswal 22/9/2011 285 400 buy the above 1 set if conditions satisf...