Posts

Showing posts from June, 2014

Binding 'Delimiter' In Powershell -

i know can use export-csv feature export data csv file, keep getting error of export-csv: can not bind parameter 'delimiter'. can nnot convert value "c:\test' type system.char error: string must 1 character long this powershell syntax - , data want export can have \ or - in it $info = (@'foxtrot') foreach ($in in $info) { $dir = "c:\$in" export-csv c:\$in.csv $dir } try using parameter names -delimiter second parameter e.g. export-csv -path "c:\$in.csv" -inputobject $dir

python - Unit conversion from mm to m in text file with text and numbers -

i'm trying convert following style text file mm m (i.e., divide numbers 1000). it's made of regular pattern , contains text numbers. i have managed solve (eventually) using python, it's bit rough , ready completes task. suggestions/improvements appreciated. import re import numpy np import linecache io import stringio myfile = "file" results = open("results.txt","w") in range(1,50000): line = linecache.getline(myfile,i) if re.search('[a-za-z]', line): results.write(line) elif line.isspace(): results.write(str(line)) elif re.search('[-]', line): results.write(str(line)) else: c = stringio(line) data = np.loadtxt(c) = np.array(data) c = / 1000 d = str(c).replace('[','').replace(']','') results.write(str(d)+'\n') results.close() the file so: add tube 3033303.0 2998206.95111 106180.162...

iphone - adding uitextfields dynamically at runtime -

i want generate textfields dynamically in app scenario having textfield , button if entered number 2 in textfield , pressed button, 2 texfields must generated on view controller you can achieve using code; int num=yournum; (int = 1; <= num; i++) { uitextfield *textfield = [[uitextfield alloc] initwithframe:cgrectmake(...)]; textfield.tag = i; ... [self.view addsubview:textfield]; } and access correct text field afterwards you'd call [self.view viewwithtag:tag] .

javascript - Meaning of declaration in JS - [[0]] -

does know meaning of declaration in js: var m = [[0]]; mean declarated type, , why 0 in brackets? [0] array first index equal 0 [[0]] array first index equal array (whos first index 0) it easier imagine if had more elements , space bit better: var m = [[0,1,2],[2,4,5],[1,3]] so m[0] = [0,1,2]; m[1] = [2,4,5]; m[2] = [1,3]; this can expanded many dimensions need leading collections of collections of collections. you can access each index , use array referencing instance: m[0].push(4); m[2].join(','); etc. (as mentioned above) can access shorthand like: m[0][0] m[x][y] m[n-1][m[0][1]] making complicated or simple need.

matrix - define column names as combination of a retpeted string and a vector in R -

i want name columns of matrix using string , vector of length of rows. example: k<-c(5:15) xmin = 3 xmax = 15 x<-c(xmin:xmax) m<-matrix(, nrow = length(x), ncol = length(k)) ideally, name matrix columns using string , vector k, column name of i'th column same item @ i'th position of vector k. so, this: s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 [1,] na na na na na na na na na na na [2,] na na na na na na na na na na na [3,] na na na na na na na na na na na [4,] na na na na na na na na na na na [5,] na na na na na na na na na na na [6,] na na na na na na na na na na na [7,] na na na na na na na na na na na [8,] na na na na na na na na na na na [9,] na na na na na na na na na na na [10,] na na na na na na na na na na na [11,] na na na na na na na na na na na [12,] na na na na na na na na na na na [13,] na na na na na na na na na na na where string "s" . couriously, didn't work was: n=null n<- as.vector(n) m=1 (m in length(...

c++ - simple ctor dilema - inheritance -

what outcome of following code, , please describe why :) class mother { public: mother ( ) { cout << "r" << endl; } ~mother ( ) { cout << "n" << endl; } }; class daughter: public mother { public: daughter ( ) { cout << "a" << endl; } ~daughter ( ) { cout << "b" << endl; } }; void foo(mother m){ cout<< "foo" <<endl;} int main( ) { daughter lea; mother* rachel; foo(lea); } i not sure why, told me be: r,a,foo,n,b,n (from left right) why calling "daughter lea" generates r , a? due inheritance? , why did "foo" appear? shouldn't last? thanks! this flow of program execution int main( ) { daughter lea; // <- invokes ctor of daughter, after mother mother* rachel; // nothing happens --pointer foo(lea); // foo->~mother, ~mother ...

Visit every couple of element of a generic List in Java only once -

i have list in java, , exploit visit every couple of element once. example if had array have done like: o[] x = ...; for(int = 0; i<x.length; i++){ for(int j=i+1; j<x.length;j++){ someoperation(x[i],x[j]); } } the problem have list (and suppose don't know if list arraylist or linkedlist). in order have same complexity case listed before, write in pseudo-code, like: listiterator<o> it1 = list.listiterator(); while(it1.hasnext()){ o x = it1.next(); it2 = it1.clone(); //it2 have same "status" of it1, different object in memory while(it2.hasnext()){ y= it.next(); someoperation(x,y); } } as far know don't have it1.clone(). way similar stuff more or less: int = it1.nextindex(); it2 = list.listiterator(i); but, far know, list.listiterator(i); could have complexity of o(n) - in case of linkedlist, , absolutely avoidable in other languages. on other side, implementing same...

arm - Address spaces for ROM's and finding out the virtual address of certain files -

thanks reading question. i new arm , computer architectures in general sorry if basic question. i have spent plenty of time reading , learning mmu , virtual physical address translation. have learn't address spaces. sure io peripherals such ethernet , usb have there own addresses external ram , rom's right? wanted know address values read pdf document, here: http://infocenter.arm.com/help/topic/com.arm.doc.den0001c/den0001c_principles_of_arm_memory_maps.pdf , confusing. cant see says exact address space rom , address space have found doesn't add 128gb example on arm phones. can me make sense of this? getting wrong? , how find out exact addresses peripherals, rams , rom's can load , store functions these addresses in codes. how find out virtual address of files , documents if going mess around coding 1 of old phones. eample address 0x00ba ffff 0x0aff ffff audio file. learn lot though exploring in way. thanks again, will smith arm makes processor c...

javascript - Angular JS loading issue -

i trying following angular-spinner working in project: i trying working http.get calls. far have: in controllers: $scope.loading = true; $http.get('js/data/test.json').success(function(results){ $scope.section = results.section; $scope.loading = false; }); in view: <span us-spinner="{radius:15, width:4, length: 8}" ng-show="loading"></span> <div ng-repeat="post in section" class="inner"></div> currently loading shows fast, want know correct way use it? how can delay before data loads , spinner shown. ideas? you try add timeout: $scope.loading = true; settimeout(function () { $http.get('js/data/test.json').success(function(results){ $scope.section = results.section; $scope.loading = false; } }, 5000); this wait 5 seconds before trying retrieve data json file. edit: use $timeout service angular. don't forget include in controller! (thank walfrat) ...

c++ - Invalid use of type class after forward declaration -

i have written program demonstrate double dispatch in c++. shows invalid use of type class though have forward declared classes. there way rectify without writing in separate header files. #include <iostream> #include <string> using namespace std; class number; class integer; class rational; class number{ public: int num, den; virtual void add(number&) = 0; virtual void addinteger(integer&) = 0; virtual void addrational(rational&) = 0; virtual string tostring() = 0; }; class rational : public number{ void addinteger(integer& i){ this->num = this->num + i.num*this->den; this->den = this->den; cout << this->num << "/" << this->den; } void addrational(rational &r){ this->num = this->num*r.den + this->den*r.num; this->den = this->den*r.den; ...

mysql - SQL JOIN: Select Records from Another Table With Matching IDs -

i having trouble building correct sql join statement select records table. --table product: id name catid1 catid2 and --table category: catid categoryname product.catid1 , product.catid2 referenced category.catid so want select product fields , replace product.catid1 , product.catid2 category.categoryname (for product.catid1 ) , category.categoryname (for product.catid2 ). this not work explains need: select product.id, product.name, category.categoryname product.catid1, category.categoryname product.catid2 product, categories; all need double left join categories table: select p.id, p.name, c1.categoryname catid1, c2.categoryname catid2 product p left join categories c1 on p.catid1 = c1.catid left join categories c2 on p.catid2 = c2.catid if there no match either catid1 or catid2 , corresponding field in select clause going null .

Learning Java and Eclipse -

i'm trying write login program in eclipse. question type of gui best use? i'm totally confused on gui types i.e swing (swt), jframe, window builder.... know broad question if possible,a simple answer suffice. thanx in advance! window builder eclipse addon allows create jframes. can find link here this allows use swing create nice guis. recommend try { uimanager.setlookandfeel(uimanager.getsystemlookandfeelclassname()); } catch (classnotfoundexception | instantiationexception | illegalaccessexception | unsupportedlookandfeelexception e) { e.printstacktrace(); } this make window updated os user using.

python - Run some JavaScript every time a Jupyter Notebook loads -

i running jupyter notebook server , run arbitrary javascript code configure notebook every time loaded. example of code have run... $('div#maintoolbar').hide(); $('div#header-container').hide(); require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"], function(sublime_keymap, cell, ipython) { cell.cell.options_default.cm_config.keymap = 'sublime'; var cells = ipython.notebook.get_cells(); for(var c=0; c< cells.length ; c++){ cells[c].code_mirror.setoption('keymap', 'sublime'); } } ); i feel should easy can't quite find documentation on it... the documentation have found refers ipython objects in javascript. suggestions on when use keywords ipython vs jupyter? example both ipython.keyboardmanager , jupyter.keyboardmanager valid javascript objects in notebook. as hugh bothwell mentioned can put js in custom.js file,...

c# - Autofac not auto wiring properties to a custom class -

i trying setup class using autofac autowired properties custom class controller calls. have setup test project show this. have 2 projects in solution. mvc web application , class library services. here's code: in service project, accountservice.cs: public interface iaccountservice { string doathing(); } public class accountservice : iaccountservice { public string doathing() { return "hello"; } } now rest in mvc web project. global.asax.cs var builder = new containerbuilder(); builder.registercontrollers(assembly.getexecutingassembly()).propertiesautowired(); builder.registerassemblytypes(typeof(accountservice).assembly) .where(t => t.name.endswith("service")) .asimplementedinterfaces().instanceperrequest(); builder.registertype<test>().propertiesautowired(); builder.registerfilterprovider(); var container = builder.build(); dependencyresolver.setresolver(new autofacdependencyresolver(container)); test...

sql server - Sql Create Table Code Failing -

for life of me don't know why code below failing. input appreciated. many thanks. create table #t_dem_pflow (unit varchar(10), source varchar(7)) insert #t_dem_pflow (unit, source) values insert #t_dem_pflow (unit, source) values /* insert #t_dem_pflow (unit, source) values */ create table #t_dem_decsvc (unit varchar(10), source varchar(7)) insert #t_dem_decsvc (unit, source) values create table #t_dem_inunsched (unit varchar(10), source varchar(7)) insert #t_dem_inunsched (unit, source) values error message: msg 156, level 15, state 1, line 10 incorrect syntax near keyword 'insert'. msg 156, level 15, state 1, line 22 incorrect syntax near keyword 'create'. msg 156, level 15, state 1, line 32 ...

scala - Applying function to Spark Dataframe Column -

coming r, used doing operations on columns. there easy way take function i've written in scala def round_tenths_place( un_rounded:double ) : double = { val rounded = bigdecimal(un_rounded).setscale(1, bigdecimal.roundingmode.half_up).todouble return rounded } and apply 1 column of dataframe - kind of hoped do: bid_results.withcolumn("bid_price_bucket", round_tenths_place(bid_results("bid_price")) ) i haven't found easy way , struggling figure out how this. there's got easier way converting dataframe , rdd , selecting rdd of rows right field , mapping function across of values, yeah? , more succinct creating sql table , doing sparksql udf? you can define udf follows: val round_tenths_place_udf = udf(round_tenths_place _) bid_results.withcolumn( "bid_price_bucket", val round_tenths_place_udf($"bid_price")) although built-in round expression using same logic function , should more enough, not mentio...

meteor - Vertical alignment gets broken -

i have login form centered vertically described in docs using middle alligned , however, if place dynamic content within centered block (e.g {{message}} , message being helper) breaks centering , block aligned top. is there way around it?

Can you change Zurb Foundation's Responsive breakpoint from 640px to 768px? -

can change zurb foundation's first breakpoint 640px 768px? (are there side effects of doing so, , common , accepted practice?). i think bootstrap's first breakpoint 768px , allow more room "desktop" browser or tablet. 640px might cramped fit in things, , goes way 1024px, difficult design in between. at 640px, header elements pushed down row, items need styled cramped margin space, , @ 900px or so, margin space % values, expanded remain cramped. if using sass version of foundation, it's easy change breakpoints. take @ _settings.scss file, here few relevant lines: $breakpoints: ( small: 0, medium: 640px, large: 1024px, xlarge: 1200px, xxlarge: 1440px, ); $breakpoint-classes: (small medium large); so trying achieve, change value of medium 768 , , if want, increase large . note array of breakpoint classes doesn't contain xlarge , xxlarge default - if want these additional classes add them array. can define own if need to. ...

TypeScript not finding definitions -

i have following file structure: + src | test.ts | z_module.d.ts tsconfig.json test.ts // nothing? /// <reference path="./z_module.d.ts" /> // can't write: var a: zzrm.zzrmobject; // have use: import * zzrm 'zzrm'; var a: zzrm.zzrmobject; z_module.d.ts declare module "zzrm" { export interface zzrmobject {id: string} } i have tried reduce problem may have reduced incorrectly. problem came trying use sequelize-auto-ts. downloading repo , upgrading sequelize.d.ts , opening in visual studio code (version 0.10.6) highlights this line error "cannot find namespace 'sequelize'." var sequelize:sequelize.sequelizestatic = require('sequelize'); ^^^^^^^^^ even though sequelize.d.ts reference @ top of file with: /// <reference path="../../typings/sequelize/sequelize.d.ts" /> the above "reduced" example works if zzrm module declared without quotation mark...

comparison - Comparing strings with logical operators in an IF statement -

i trying figure out how compare strings within if statement. of code can ignored, there context. trying add message simple rock, paper, scissors game when enters string besides rock, paper, or scissors. can tell me doign wrong in portion asterisks around it? var userchoice = prompt("do choose rock, paper or scissors?"); var computerchoice = math.random(); if (computerchoice < 0.34) { computerchoice = "rock"; } else if(computerchoice <= 0.67) { computerchoice = "paper"; } else { computerchoice = "scissors"; } console.log("computer: " + computerchoice); var compare = function (choice1, choice2) { if (choice1 === choice2) { return "the result tie!"; } **else if (choice1 !== "rock" || "paper" || "scissors") { return "your options rock, paper, or scissors friggin plebian!"; }** else if (choice1 === "rock") { if (choice2 === ...

templates - How to include CSS and JS once in Laravel 5 -

i building large laravel 5.2 application. using number of 3rd party libraries (such jquery, d3, , others). i combine libraries single file (with elixir), since of pages won't need full set, keep them separate. templates complex, , want easy way make sure css/js file included, once. currently, in our master template, have stacks css , js, , push onto stack, example: @push( asset('path.js') ) but, doesn't give way ensure file included once, like @pushonce( asset('path.js') ) i couldn't find extensions provide this. there extensions provide this? need implement myself? or taking wrong approach (this can't unique problem). one thing makes app special users might in slow connections (2g) , have cross china firewall, i'm hesitant concatenate single file (file size makes huge difference).

excel - Vlookup in a Loop Process to Change Save Filename VBA -

all - looking write loop can change filename , folder location depending on value runs in loop. example, if running macro cells g2:g7, when process moves g2 g3, want filename , folder location change according reference table (look image details). effectively, want filename , foldername lookups fund types. public sub get_file() dim sfiletype string dim sfilename string 'save file name, if "" default dim sfolder string 'save folder, if "" default dim breplace boolean 'to replace existing file or not dim surl string 'the url location extract information dim cell, rng range dim sheet worksheet 'initialize variables set rng = range("i2:i10") set sheet = activeworkbook.sheets("macro_button") each cell in rng if cell <> "" sfiletype = cell.value sfilename = sfiletype & "_" & format(date, "mmddyy...

sql server - SQL How to SELECT specific fields from tables using a table of table names -

so, i trying find (messy?) solution more messy problem. have sql server 2014 database which, in part, stores data software package stores data me. software creates table specific fields each set of data - name , geometry field. example, 1 might contain cities ( dtcitiesdata ), contains roads ( dtroadsdata ), contains states( dtstates ), etc. have table ( dtspatialdatatables ) stores names of tables store data want. table has 2 fields: id , tablename . i create select statement queries dtspatialdatatables entries, queries tables name corresponding each tablename result, , selects name , geometry them. in pseudocode, want this: select tablename dtspatialdatatables foreach tablename : select name, geometry (tablename) i can php via first query against dtspatialdatatables , loop of queries each of returned row tablename s want know if possible via sql directly. in reality, want create view query can directly query view rather soak of processing time on potentia...

c++ - How to create LLVM Array type using AllocaInst? -

i want create llvm arraytype on stack wanted use allocainst (type *ty, value *arraysize=nullptr, const twine &name="", instruction *insertbefore=nullptr) . problem don't understand interface. guessed ty arraytype::get(i.gettype(), 4) , should give arraysize . furthermore, requires value* , confused me lot. either misunderstood llvm alloc or need provide llvm constant value array size. if have give constant, isn't little bit redundant since arraytype contains numelement information. as example line of code, way trying to: allocainst* arr_alloc = new allocainst(arraytype::get(i.gettype(), num) /*, parameter for?*/, "", funcentry.getfirstinsertionpt()); i type of array elements such as: type* = integertype::getint32ty(module->getcontext()); then can create arraytype of num elements: arraytype* arraytype = arrayt...

CSS animation needs correction -

i appreciate if check below in codepen css animation. i'm trying make work better. want underline start below icon, not stuck window, have space right under first icon. * { box-sizing: border-box; } body { font: 300 100% 'helvetica neue', helvetica, arial; } .container { width: 100%; margin: 0 auto; } ul li { display: inline; text-align: center; } { display: inline-block; width: 25%; padding: .75rem 0; margin: 0; text-decoration: none; color: #333; } .two:hover ~ hr { margin-left: 40%; } .one:hover ~ hr { margin-left: 12.5%; } .three:hover ~ hr { margin-left: 66%; } .four:hover ~ hr { margin-left: 75%; } hr { height: .25rem; width: 20%; margin: 0; background: tomato; border: none; transition: .3s ease-in-out; } .home-content-1{background-color: #f7f8f9; text-align: center;padding:5em 0em 2em;} .home-content-1 .row{margin-top: 2em;} .home-content-1 h3{font-...

java - Table View does not exist -

Image
i using squirrel sql client version 3.7 view derby database username connection umar , password umar .. when run insert query inside connection following error i using netbeans , doesn't work there code gives same error .. do fix here statement use creating administrators table create table adminstrators(admin_id bigint not null generated identity,username varchar(30) not null,password varchar(16) not null,constraint admin_pk primary key (admin_id) ) it spelling mistake in sql query create table administrators(admin_id bigint not null generated identity,username varchar(30) not null,password varchar(16) not null,constraint admin_pk primary key (admin_id) ) please close question

sql - WHERE Clause with conditions in it -

i want create clause take account termination date , if hire date between these values , term date isn't on or before hiredate - ie employee never started - how go that? far have this: select a.adpid employeeid, isnull(a.lname, '') [last name], isnull(a.fname, '') [first name], isnull(a.primaryemail, '') [email], isnull(m.fname + ' ' + m.lname, '') manager, isnull(convert(varchar(100), a.hiredate, 101), '') hiredate, isnull(convert(varchar(100), a.terminationdate, 101), '') termdate, isnull(div.divisionname, '') division, isnull(fun.functionname, '') [function], isnull(dep.departmentname, '') ...

Random button that reload a div or script not page using jquery or javascript -

i'm new @ , need random button on page show new line of information in div every time click on random button. wondering if there on 800 lines possible put in outside file txt or html. here got far , doesn't work , i'm getting confuse... please help <script type="text/javascript" src="jquery-2.2.0.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#text').hide(); $('a#random').click(function(){ $('#text').toggle(); }) function rndtext() { var rannum= math.floor(math.random()*textarray.length); document.getelementbyid('#text').innerhtml=textarray[rannum]; } var textarray = [ "hello", "how you", "good bye" ]; $("#text").load() }) </script> <body> <div id="text...

javascript - propblem using react js in Chrome extension -

i following tutorial build new tab chrome extension .. https://facebook.github.io/react/docs/tutorial.html but when attach <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script> for rendering jsx using babel suggested tutorial error browser console. "browser.min.js:4 uncaught evalerror: refused evaluate string javascript because 'unsafe-eval' not allowed source of script in following content security policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:"." screenshot of error i know violating csp directive again how can use latest reactjs using babel ? in manifest.json file, can try setting "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'" i got answer here . got rid of error me, i'm not knowledgeable enough know other implications, sorry.

ios - UI Testing failure - App state is XCApplicationStateRunningActive not XCApplicationStateNotRunning -

i using xcui tests automate testing of of flows in our application (~35 test scenarios) xcode 7.2.1 running these tests locally consistently pass, whereas running them on our virtual machine instance (parallels, mac mini, osx 10.11, 8gb ram) fail @ different parts in process. i errors such as: ui testing failure - app state <xcuiapplicationprocess: 0x7ff661528a50 (null) (6798)> xcapplicationstaterunningactive (3), still not xcapplicationstatenotrunning (1)[0m i have turned off animations within application, , put significant waiting times throughout application try , cater slower running, no ends. has had similar problems running xcuitests , termination of simulator when running them? any great.

scala - Multiclass SVM with Spark 1.6? -

i ran multi-class logistic regression spark use svm cross validate results. looks spark 1.6 supports svm binary classifications. should use other tools this? h20 example? after research, found branch not integrated in spark 1.6 allowed me run svm on multi class classification problem. big bekbolatov. the commit can ofund here: https://github.com/bekbolatov/spark/commit/463d73323d5f08669d5ae85dc9791b036637c966

c - Regarding implementing a new transport protocol -

i trying implement own transport layer protocol tcp used application, on top of network layer using raw sockets api in linux. working on ubuntu 14.04. i have been able send , receive packets. now in part of implementing transport protocol, looking forward write functions connect(int sockfd) - establish connection server. send_data(int sockfd, char* data) - send data receive_data(int sockfd, char* data) - receive data close(int sockfd) - close connection also since trying implement protocol tcp, keep protocol reliable want send acknowledgement each received data packet. have made own tcp header follows typedef struct rtlp_hdr { int checksum; short int src_port; //defined short int des_port; //defined int seq_no; int ack_no; }rtlp_hdr; now in implementation of send_data function after send data packet wait receive acknowledgement next data packet given time, , if don't receive ack or receive corrupted ack( afte...

bash - Replace NULL string pattern with blank -

i have pipe delimiter file in need replace null string blank. file huge around 9 gb , contain 2 million records , has 150 columns delimited pipe. pqr|null|null|null abc|abc null xyz|xyz null|null desired output pqr|||null abc|abc null xyz|xyz null| using perl can use lookaheads this: perl -pe 's/(?<=\|)null(?=\||$)//g' file output: pqr|||null abc|abc null xyz|xyz null| if don't have perl sed should work: sed 's/|null|/||/g; s/|null\(|\|$\)/|\1/g' file output: pqr|||null abc|abc null xyz|xyz null|

javascript - Triggering simultaneous transitions with D3 -

i have built d3 script (click here jsfiddle) connects nodes paths. can see fiddle, have created transition sends circle node node c. i want amend script follows: send 10 blue/red circles b in 10 seconds send 15 blue/red circles c in 10 seconds steps (1) , (2) simultaneous circle dispatch 'random'. circle speed not vary dispatch triggered unevenly across different paths, color , 10 seconds. more 1 circle can on path @ once. steps 1 4 can of course saved in array, so: { "pathab": { "duration": 1000, "blue": 5, "red":5 }, "pathac": { "duration": 1000, "blue": 5, "red":10 } } i stuck. @ moment can't fire 2 sequential events (the second overrides first, , first not triggered). efforts fire simultaneous events failed. have been scanning stack overflow evening limited success. appreciated!

c++ - uncrustify options for lambda -

my question uncrustify 0.62 , lambdas. uncrustify.cfg options can format code this: void f1b() { std::for_each( a, b, [ ] ( int& b ) -> foo { b += 3; return(beer); } ); } to code this: void f1b() { std::for_each(a, b, [] (int& b) -> foo { b += 3; return(beer); } ); } ? nb: next lines : nl_cpp_lambda_leave_one_liners=false nl_cpp_ldef_brace=add sp_cpp_lambda_assign=add are in uncrustify.cfg. thanx. you might this: indent_paren_open_brace=true

web - Should server-side objects contain all database columns/relationships at creation time? -

i unexperienced computer science student , while making projects different courses few conceptual questions occurred. say develop website similar imdb, music, scratch , want list artists on frontpage. database schema done relationship , attributes, , there table artists. should server-side artist-class contain table columns , relationships @ creation time not needed @ time? or should construct these objects minimal parameters (like id, name) , rest when needed (resulting in more individual sql statements) via helper-methods? know there maybe no definitive answer except 'it depends' or boils down personal preference, maybe there consensus. if name or link resources read on things grateful, didn't know search exactly. thanks. ps: people wondering why don't ask these questions in cs course; held students/assistants had pass course , don't have experience themselves. i not sure means answering assuming not exist in question. edit answer when clarificati...

mysql - How GROUP BY and COUNT or SUM works together in SQL queries -

i wonder how group by , count or sum works in sql queries. for example, why following code use sum function on rows within each group, not groups itself? select product_name, sum(substring_index(company_name, '|', -1) '%live%' count_live, sum(substring_index(company_name, '|', -1) '%demo%' count_demo, sum(substring_index(company_name, '|', -1) not '%live%' , substring_index(company_name, '|', -1) not '%demo%') count_other, count(*) total foo group product_name order total desc ; how executed? part of expression executed earlier? aggregate function sum or count return result based on group of rows (aggregated column specified in group clause) in case obtain both: sum of value contained in rows same product_name , count of these rows. the group condition lead aggregation , work aggregate funtion in same way ..

android - Application on Device Close on open -

every time open app on phone check it, close on second opens , says: ""name of app" stopped" its autoclose without go main layout p.s tnx guys! debug says: target device: 54d1969c installing apk: c:\users\erel\androidstudioprojects\accountsaver\app\build\outputs\apk\app-debug.apk uploading file to: /data/local/tmp/com.erelbiran.accountsaver com.android.ddmlib.adbcommandrejectedexception: device unauthorized. adb server's $adb_vendor_keys not set try 'adb kill-server' if seems wrong. otherwise check confirmation dialog on device. mainactivity package com.erelbiran.accountsaver; import android.app.activity; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.toast; public class mainactivity extends activity { db mydb; button btnadd; edittext user = (edittext)findviewbyid(r.id.enteruser), pass = (edittext)findviewbyid(r.id.ente...

excel - Automatically fill data from another sheet -

Image
main question i auto-fill sheet a values sheet b in excel 2013. data in 2 sheets in same workbook. example =========== sheet 1 =========== =========== sheet 2 =========== location year val1 val2 location year val1 val2 usa.vt 1999 usa.vt 1999 6 3 usa.vt 2000 usa.vt 2000 3 2 usa.vt 2001 usa.vt 2001 4 1 usa.vt 2002 usa.vt 2002 9 5 usa.nh 1999 usa.nh 1999 3 6 usa.nh 2000 usa.nh 2002 12 56 usa.nh 2001 usa.me 1999 3 16 usa.nh 2002 usa.me 2002 4 5 usa.me 1999 usa.me 2000 usa.me 2001 usa.me 2002 i use function or formula automatically populate sheet 1 based on values in sheet 2 according to: location , year , , column ( val1 or val2 ). non-matches ze...

Service not defining when injecting it for Karma testing - AngularJS -

i've seen few of these questions on internet, none of answers seem solve problem. have service works in served app, when test in karma not being defined. i've got modules , associated controllers, directives , services in src folder. structure of file follows: angular.module('cst-error-framework', ['md.alerts', 'md.input', 'md.modals']); angular.module('md.alerts', []) .directive(//..associated directives here angular.module('md.input', []) //blah blah blah angular.module('md.modals', []) //directives , controllers .factory('mderrorhandler', function () { //contents here }); i know seems bit cumbersome there other reasons have in 1 file. then spec mderrorhandler follows: describe('service errorhandler', function () { beforeeach(function() { module('cst-error-framework'); angular.mock.module('templates'); }); var mderrorhandler; beforee...

flask wtforms - How to keep past value after error in html? -

i have textarea form , want keep value user has inserted if error occurs when trying submit. i've tried works input type="text", when use textarea past value of field gone when error occurs. other questions related php apps, know when html? <div class="form-group"> <label class="control-label col-sm-2" for="msg">message:</label> <div class="col-sm-10"> <textarea type="text" rows="3" class="form-control" name="message" value="{{request.form.msg}}" id="msg" required></textarea> </div> </div> just fixed it! putting {{request.form.msg}} in between , this: <textarea type="text" rows="3" class="form-control" name="message" id="msg" required>{{request.form.msg}}</textarea>

c# - Cross-thread operation not valid when using Invoke -

Image
i've made chat system , got error: cross-thread operation not valid: 'messagebox' etc. what have done: i've added invoke. here code: invoke(new action(() => messagebox.items.add(usersname.text + ": " + receivedmessage))); the problem is, sends message other user blank. because i'm connected chat locally. here picture: receiving messages: private void messagecallback(iasyncresult aresult) { try { byte[] receiveddata = new byte[1500]; receiveddata = (byte[])aresult.asyncstate; asciiencoding aencoding = new asciiencoding(); string receivedmessage = aencoding.getstring(receiveddata); invoke(new action(() => messagebox.items.add(usersname.text + ": " + receivedmessage))); buffer = new byte[1500]; socket.beginreceivefrom(buffer, 0, buffer.length, socketflags.none, ref theirip, new asynccallback(messagecallback), buffer); } catch (exception ex) { ...

java - ArrayList / ArrayAdapter .add() function overwriting last element instead of adding to end of array -

i'm working on school assignment create bookmarking app 2 activites, listactivity called booknote , activity called manageactivity. all typing must done in manageactivity , passed booknote list changes, reading, , writing data. my problem when call function "addbookmark" in booknote activity. want happen new list item added @ end of list bookmark objects info in it. what happening whatever item @ end of list overwritten instead of new item being created. my code below comments stating intentions of each function. booknote activity public class booknote extends listactivity{ private arrayadapter<bookmark> adapter; private final string filename = "bookmarks.txt"; public string title = "empty", url = "empty", note = "empty"; public string bookmarkclicked =""; public int listviewid = 0; public boolean intentlistener = false; public int intentreturncounter = 0; public boolea...

python - X labels matplotlib -

i want change x axis years. years saves in variable years. i want make plot of data looks this: it should image however, not able create x axes years. plot looks following image: this example of produced image code my code looks follows: import pandas pd import matplotlib.pyplot plt data = pd.read_csv("data1.csv") demand = data["demand"] years = data["year"] plt.plot( demand, color='black') plt.xlabel("year") plt.ylabel("demand (gw)") plt.show() i thankful advice. the plot method in example not know scaling of data. so, simplicity treats values of demand being 1 unit apart each other. if want x-axis represent years, have tell matplotlib how many values of demand should treat "one year". if data monthly demand, 12 values per year. , here go: # setup figure fig, (ax1, ax2) = plt.subplots(2) # generate random data data = np.random.rand(100) # plot undesired way ax1.plot(data) # change tic...

c# - LINQ Join on multiple columns with different record using extension method syntax -

this question has answer here: the type of 1 of expressions in join clause incorrect in entity framework 3 answers sorry, if question doesn't make sense. let me explain. i have existing sql query below: select t1.portfolio, t1.valuedate currentvaluedate, t1.differencepercent currentdp, t2.valuedate previousvaluedate, t2.differencepercent previousdp, case when t1.differencepercent = t2.differencepercent 1 else 0 end ischange [accountingdata].[dbo].[navrec_navsummary] t1 join [accountingdata].[dbo].[navrec_navsummary] t2 on t1.portfolio = t2.portfolio , t2.valuedate = dateadd(day, case datename(weekday, t1.valuedate) when 'sunday' -2 when 'monday' -3 else -1 end, datediff(day, 0, t1.valuedate)) so basically, i'm interested in displaying portfolio's along c...

plc - LReal Vs Real Data Types -

in plc structure text main difference between lreal vs real data type? use when replacing double or float when converting c based language structure text plc lreal double precision real, float, or floating point variables 64 bit signed value rather real single precision real, float, or floating point made 32 bit signed value. stores more in lreal makes lreal closer double , float. other thing keep in mind depending on plc convert real lreal calculations. plus lreal limited 15 decimal places rather real 9 decimal places. if need more 9 decimal places recommend lreal if need less stick real because lreals have convert integer real lreal. save step.

r - Problems wit calling values from function to function -

i have problems connecting 2 functions. want call results garch function loglik function, doesn't work. can help? not complete code end: #the basic part of code taken http://www.r-bloggers.com/garch-estimation-using-maximum-likelihood/ on 2016-02-05 library(quantmod) library(fbasics) library(rmgarch) library(fgarch) library(parallel) library(ccgarch) library(mgarch) #from https://github.com/vst/mgarch on 2016-01-25 library(tsdyn) library(ggplot2) library(mvnmle) library(rootsolve) library(matrixcalc) #load data, time series closing prices, 10 year sample #dax 30 getsymbols('^gdaxi', src='yahoo', return.class='ts',from="2005-01-01", to="2015-01-31") gdaxi.de=gdaxi[ , "gdaxi.close"] #s&p 500 getsymbols('^gspc', src='yahoo', return.class='ts',from="2005-01-01", to="2015-01-31") gspc=gspc[ , "gspc.close"] #credit suisse commodity return strat getsymbols('crsox...