Posts

Showing posts from July, 2014

html - Mixing a few position:fixed Div's -

here html & css problem i'm trying solve : html & css: #fixedleftmenu { display: inline-block; height: 50px; background-color: yellow; width: 25px; position: fixed; } #container { display: inline-block; background-color: orange; width: calc(100% - 25px); margin-left: 25px; } #redfixeddiv { height: 100px; background-color: red; width: 25%; position: fixed; } #bluediv { float: right; height: 1000px; background-color: blue; width: calc(100% - 25%); } <div id="fixedleftmenu"></div> <div id="container"> <div id="redfixeddiv"> </div> <div id="bluediv"></div> </div> the yellow div fixed div fixed width . the red div fixed div % width . the blue is % width ; you can see red , blue div's not match 100% width (the...

How can i fetch data from sqlite3 database using C++? -

i new c++ , how can retrive data sqlite3 db using select query , callback method in sqliteutil class? i know data can collected using callback method method scheme readrecords() -> executequery() -> sqlite3_exec(callback) sqliteutil.cpp #include "sqliteutil.hpp" // readrecords method **static int sqliteutil::callback(?char *record?, int argc, char **argv, char **azcolname) { for(int i=0; < argc; i++){ cout << azcolname[i]; cout << "\t"; cout << argv[i] ? argv[i] : "null"; cout << "\n"; } cout << "\n";** return 0; } // thats execute query, dry. void sqliteutil::executequery(string sql) { sql += ";"; int result = sqlite3_exec(db, sql.c_str(), callback, ?records_s?, &zerrmsg); printerror(result); } void sqliteutil::readrecords(vector<string> columns = {}, vector<string> order = {}) { string sq...

javascript - Angularjs: Callback to parent controller -

please consider following code: has directive myitem isolate scope. each item display button call delete() on directive controller. i'd trigger refresh in outer controller ( appcontroller ). of course refresh() function can not found, because of isolated scope. <html> <body ng-app="question"> <div ng-cloak ng-controller="appcontroller"> <my-item ng-repeat="item in list" data="list"> </my-item> <input type="text" maxlength="50" ng-model="new_item" /> <button ng-click="add(new_item)">+</button> </div> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script> <script> (function () { var app; app = angular.module('question', []); app.contro...

r - Draw random numbers from distribution within a certain range -

i want draw number of random variables series of distributions. however, values returned have no higher threshold. let’s want use gamma distribution , threshold 10 , need n=100 random numbers. want 100 random number between 0 , 10. (say scale , shape 1.) getting 100 random variables easy... rgamma(100, shape = 1, rate = 1) but how can accomplish these values range 0 100? edit make question clearer. 100 values drawn should scaled beween 0 , 10. highest drawn value 10 , lowest 0. sorry if not clear... edit no2 add context random numbers need: want draw "system repair times" follow distributions. however, within system simulation there binomial probability of repairs beeing "simple" (i.e. short repair time) , "complicated" (i.e. long repair time). need function provides "short repair times" , 1 provides "long repair times". threshold differentiation between short , long repair times. again, hope makes question little clear...

can not pass json array from PHP to JQuery -

i have been trying pass simple array php jquery. here have far relevant functions in html/js: function myquery() { var xmlhttp = new xmlhttprequest(); var url = "sandbox.php"; xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { myfunc(xmlhttp.responsetext); } } xmlhttp.open("get", url, true); xmlhttp.send(); } function myfunc(response) { var arr = json.parse(response); document.getelementbyid("demco").innerhtml = arr[0]; } for php have tried: <?php $arr = [4,7,2]; echo json_encode($arr); ?> and: <?php $arr = array(4,7,2); echo json_encode($arr); ?> according debugger fails @ json.parse(response) every time. wrong in code here? tried running array, [4,7,2], through http://json.parser.online.fr/ , got no issues. i'm @ wits end, me se! edit: from console: parse error in php on line x x line containing: $arr = [4,7,2]; uncaught exception: syn...

javascript - insert a new document from querying combined collection -

i new nosql world , meteor, have 2 collections, taskcollectioin , workerscollection , goal match each task available timeslot in workerscollection. tasks collection has fields {client,task-name,time-flag,assigned=false} , workers collection has field {name, timeslot:[slot, available]}. have created result collection called matchcollection result need insert document resulting in matching of each task available worker. my question: since dealing querying 2 different collection , comparing field matching, how implement function in meteor solves following psuedo code algorithm? 'for each task taskcollection | if (assigned == false) | | task flag(for example: 10-12 pm) | endif | each worker collection | | **get worker slots | | if (worker timeslot availible given task time-flag) | | | 1-assign task worker | | | 2-set task assigned true | | | 3-set timeslot.available false | | | 4-create document in matchcol...

r - Function for thresholds of two variables -

i trying write function 2 variables. m has 4 categories: equal 19 or less , 20 , 21 , , 22 . al has 3 categories: less 30 , 30 400 , , over 400 . input: m=c(19,20,21,22) al=c(30,400) output: out1 <- c(0.95, 0.94. 0.93, 0.92) out21 <- 1.091+3.02*(al-30) out22 <- 1.093+3.03*(al-30) out23<- 1.099+3.08*(al-30) out24 <- 1 out3 <- c(0.87, 0.89, 0.91, 0.93) i trying write function if else looks like out <- function(m,al) { if(m<=19 & al<30){ out=0.95 } else { if(m=20 & al<30){ out=0.94 } else { if(m=21 & al<30){ out=0.93 ... i easy looking function gives me output more easily. further explanation on conditions: if m <=19 & al <30, out=0.95 if m =20 & al <30, out=0.94 ... if m <=19 & al in between 30 , 400, out=1.091+3.02*(al-30) if m =20 & al in between 30 , 400, out=1.093+3.03*(al-30) ... if m <=19 & al >400, out=0.87 if m =20 & al >400, out=0.89...

xaml - Why is {x:Null} no longer a valid value in a Style Setter in UWP? -

Image
a follow this question , why {x:null} no longer valid option setter.value ? put code in resource dictionary in uwp app: <style x:key="mylist" targettype="listview"> <setter property="transitions" value="{x:null}"/> </style> and use in listview : <listview style="{staticresource mylist}"/> your app crash. nasty crash well, kind takes down app without breaking in debugger. also, designer complains catastrophic failure: i know setting values {x:null} valid. if set <listview transitions="{x:null}"/> directly, works fine... expected. so... happened style setters? ... care explain, microsoft? there @ least alternate method? it weird behavior , overall because explained setting directly null works , style not. alternative found set clear transitioncollection: <page.resources> <style x:key="mylist" targettype="listview...

python - argparse's "required" ignored in the help screen? -

consider following code: import argparse parser = argparse.argumentparser() parser.add_argument('-o', required=true, nargs=1) parser.parse_args(['-h']) why getting following output if said -o required? usage: test.py [-h] -o o optional arguments: -h, --help show message , exit -o o i expect text -o required. this issue #9694 on python bug tracker , yet unfixed. can read more there. note usage line correctly indicate switch required (if weren't, usage line read usage: test.py [-h] [-o o] instead of usage: test.py [-h] -o o ). for working around it, can use argument groups can given title . example shows @ linked page, allows create groups choice of name instead of default positional arguments , optional arguments groupings.

c++ - Can some one help me figure out what I am doing wrong here? -

i working on problem leet code , question was: you product manager , leading team develop new product. unfortunately, latest version of product fails quality check. since each version developed based on previous version, versions after bad version bad. suppose have n versions [1, 2, ..., n] , want find out first bad one, causes following ones bad. given api bool isbadversion(version) return whether version bad. implement function find first bad version. should minimize number of calls api. the solutions had problem above was: // forward declaration of isbadversion api. bool isbadversion(int version); class solution { public: int firstbadversion(int n) { bool x = isbadversion(n); if (x == true) { return n; } else { return firstbadversion(n + 1); } } }; but on leet code says have wrong solution. please point me in right d...

javascript - Does the match query return only results base on score? -

hello have following object: { type:'foo' users: [{id: myid roles:['admin','fooadmin']}, {id: myid2 roles:['admin']}] } and using bool query objects users id. following term: 'term': { 'users.id': 'myid' } it works except when id has capital letters in it. searched little , found out match query alternative: { "query": { "match": { "users.userid":token._source.userid } } } so far been working me because case sensitive. lately i've heard match query gets 'best results',meaning gets results best score. true? i'm risking not objects want match query? match query takes query string, analyzes it , , turns analyzed tokens or query. reason case sensitive because there's lowercase filter in analyzer. so query string like "brown dog" would turned 2 tokens , lowercased, like [brown] or [d...

math - Recurrence relation for basic operation -

i need little creating recurrence relation basic operation following recursive algorithm: int d(int n) { if (n==0) { return 0; } return d(n - 1) + d(n - 1); } i think basic operation addition having trouble setting recurrence relation are sure correct code? recurrence relation is d(n) = 2 * d(n-1) base case d(n) = 0 do see how works? function's recursion step shows recurrence step; function's termination clause shows base case. i'm worried because in closed form, is d(n) = 0 n

java - twitter4j using generic argument names -

so me? twitter4j method arguments use generic naming, example getuserlistmembers(long l, int i, long l1) makes hard work out variables need, need refer documentation. it seems have appropriately named parameters: getuserlistmembers(long listownerid, int listid, long cursor) are sure you're not looking @ jar has javadocs stripped?

phonegap iOS can't find jQuery mobile map file -

i'm having issue jquery mobile css showing on ios simulator. when debug in safari error missing min.map file, i'm not using min file , it's in local folder. i'm using phonegap 4.0, jquery mobile 1.4.5 . generated new project command line , copied www content android project. works android , in local safari browser. i've tried href="./css/ solution. <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.5.css" /> <script type="text/javascript" src="js/cordova.js"></script> <script src="js/jquery-1.11.3.js"></script> <script src="js/jquery.mobile-1.4.5.js"></script>

mongodb - STDERR Meteor app crash with exit 8 after adding new collection (now just crashing repeatedly?) -

hello world: first stackoverflow question. after searching through other questions , meteor documentation can't seem figure 1 out. i'm working clone of scotch.io meteor-polling app, , wanted add new mongo collection, started throwing errors(stderrs no messages) when tried run app included. so, removed references collection: code same when working 1 collection, , i'm still getting errors. puzzled. tried meteor reset , update no avail. here's repo: https://github.com/abraxasrex/meteor-polling the code starting giving errors current master. i'm debugging either insertion of collection or adding votes=[] newpoll in client/components/poll-form.js(?) the error logs mention msavin:mongol. typeerror: property 'undefined' of object [object object] not function @ package (packages/meteortoys_toykit/packages/meteortoys_toykit.js:290:1) if remove you'll have app working again.

android - java xmlpull parse random string from XML -

i'm new android programming , i'm trying figure out how strings file , display strings on buttons randomly. the goal make multiple choice test randomly generated questions (based on database) , keep track of user's correct , incorrect answers (but i'm far part). i watched xmlpull tutorial showed me how pull section of every line in document , tried adapt pull section of 1 line. here's have: string item; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.test_layout); try { item = getitemfromxml(this); } catch (xmlpullparserexception e) { } catch (ioexception e) { } string[] items = item.split("\n"); setlistadapter (new arrayadapter<string>(this, android.r.layout.simple_list_item_1, items)); } public string getitemfromxml(test test) throws xmlpullparserexception, ioexception { stringbuffer stringbuffer = new stringbuffe...

javascript - Ajax return value from php to textbox without posting value to php -

i want value php , set textbox. here ajax code: function docnum(){ $.ajax({ url: 'docnum.php', datatype: 'json', type: 'post', data: { 'json_encode': $('#tanggal').val() }, success: function(data){ $('#number2').val(data); } }); } and here html code <input type="text" id="number2" name="number2" placeholder="number2" onclick="docnum()" /> and here php code docnum.php <?php $counternew="dummyvariable"; print json_encode($counternew); ?> why $counternew can not set number2 texbox? please me

html - Cannot create direct link to image hosted online -

i trying add background image http://wallpaperswide.com/rocky_peak-wallpapers.html website. the link particular image http://wallpaperswide.com/download/rocky_peak-wallpaper-1920x1080.jpg . however, if try load image second link, doesn't load. if paste url browser, redirects me first link. why happen? thanks. edit i'm getting answers there http redirect. know can download file , use locally. however, problem i'm writing script dynamically takes image wallpaperswide.com site , automatically getting image fits person's screen resolution. scan page links , try use links. can't download every image site , have them locally... any suggestions? because http://wallpaperswide.com/download/rocky_peak-wallpaper-1920x1080.jpg not image, it's document. http urls point documents, therefore web server able process , give appropriate result.

android - Google Play Beta App not on Home Screen -

i have beta version of app in google play. i've gotten beta testing work (via list of email addresses) when beta testers opt in, forced return app store every time open app. not allow them place icon on home screen. standard apps in beta testing stage? if not, idea how can fix can open app apps list other apps rather returning play store each , every time? thanks! this posted related to, same following post (the following post refers apps in production, question apps in beta , not answered post) android app not creating shortcut icon on home screen (downloaded play store) in experience beta channel, icon isn't automatically added home screen application has been installed , in app drawer. allows users drag drawer onto home screen themselves. if application isn't showing in application drawer rom bug functionality works fine on stock android.

php - How to return Guzzle JSON response -

i using guzzle make async request returns json. call working fine , response ok, however: $client = new client(); $promise = $client->requestasync($requesttype ,$this->url.$resource, // endpoint [ 'auth' => [ // credentials $this->username, $this->password ], 'json' => $payload, // package 'curl' => [ // curl options curlopt_httpauth => curlauth_basic, curlopt_returntransfer => true, ], 'headers' => [ // custom headers 'accept' => 'application/json', 'content-type' => 'application/json' ] ] ); $response = $promise->wait(); echo $response->getstatuscode().'<br /><br />'; // error handling if($response->getstatuscode() != 200){ ...

excel - VBA Data Validation List Selection -

i'm writing code embed in 1 table. situation this: cell a1 (with option of 50,100 , 150) , cell a2 (with option of 1000 , 5000), both have data validation list in them. when choose cell a1 of 50, a2 has 1000. when wrote code , made selection, there error: run-time error '-2147417848(80010108)': method 'add' of object 'validation' failed. please share opinions or if need post codes here resolve issue. the basic code following: select case range("a1").value case "50" range("a2").clearcontents range("a6").value2 = "1000" case "`100" range("a2").clearcontents range("a2").validation .delete .add type:=xlvalidateinputonly, alertstyle:=xlvalidalertstop, operator _ :=xlbetween .ignoreblank = true .incelldropdown = true .inputtitle = "" .errortitle = "" .in...

How to spot the specific string in PHP? -

my code $data = "met salesperson in sunway carnival. name katie hopkins, manager of marketing & sales. mobile phone 0165531477. , then, met katie holmes, mobile phone 0123456777."; echo preg_match('\h*(\d+)',$data); i want retrieve particular information string, $data , assign people name array $name[] , mobile phones array $mobile[] . below example, don't know how php coding people name , mobile phone numbers particular array. $name[0] = 'kean teck'; $mobile[0] = '0165531477'; $name[1] = 'katie hopkins'; $mobile[1] = '0123456777';

dictionary - Getting ifstream to read ints from a file into a map C++ -

i cannot seem file "paths.txt" read map file. cannot figure out doing wrong. i'd appreciate pointers. end result want take each of key value pairs map. the format of file 192, 16 120, 134 256, 87 122, 167 142, 97 157, 130 245, 232 223, 63 107, 217 36, 63 206, 179 246, 8 91, 178 and code ifstream myfile("paths.txt"); std::map<int, int> mymap; int a, b; while (myfile.good()) { myfile >> >> b; mymap[a] = b; } mymap; you don't have read commas in text file. also , instead of while (myfile.good()) , use while ( myfile >> ...) . std::map<int, int> mymap; char dummy; int a, b; while (myfile >> >> dummy >> b) { mymap[a] = b; }

python - Regular expression of a sentence -

i'm trying write regular expression represent sentence following conditions: starts capital letter, ends period (and 1 period can appear), , allowed contain comma or semi-colon, when does, must appear (letter)(semicolon)(space) or (letter)(comma)(space). i've got capital letter , period down. have idea code think i'm not getting syntax right... in english, expression sentence looks this: (capital letter) ((lowercase letter)(space) ((lowercase letter)(comma)(space))* ((lowercase letter)(semicolon)(space)* )* (period) i realize ignores case first letter of sentence followed comma or semicolon, it's safe ignore case. now when try code in python, try following (i've added whitespace make things easier read): sentence = re.compile("^[a-z] [a-z\\s (^[a-z];\\s$)* (^[a-z],\\s$)*]* \.$") i feel it's syntax issue... i'm not sure if i'm allowed have semicolon , comma portions inside of parentheses. sample inputs match definition: ...

ios - How to increase the content view of NSScrollView horizontally? -

Image
i using nsscrollview of size 440x44 , creating check buttons dynamically , want add them in scroll view horizontally not vertically , have added 10 buttons in scroll view this self.scrollview.hasverticalscroller=no; self.scrollview.hashorizontalscroller=yes; int counter =0; for(int i=0;i<10;i++) { nsrect frame; frame.size.width = frame.size.height = 50; if(i>0) frame.origin.x=counter; nsbutton *mycheckbox2 = [[nsbutton alloc] initwithframe:frame]; [mycheckbox2 setbuttontype:nsswitchbutton]; [mycheckbox2 settitle:@"hello"]; [mycheckbox2 setbezelstyle:2]; [self.scrollview.documentview addsubview:mycheckbox2]; //[self.scrollview setdocumentview:mycheckbox2]; [self.scrollview addsubview:mycheckbox2]; counter=counter+50; // [self.scrollview sethorizontallinescroll:1000]; } when run code achieved but problem unable scroll horizontally....... how can achieve this? set contentsize of scrollview. that...

rest - Returning Aggregate Data on a Resource -

lets leading development of new rest api. greenfield. and have structure person rest api, schema: { "id": 12, "name":{ "first":"angie", "last": "smith", "middle": "joy", "maiden": "crowly", }, "address": { "street": "1122 st.", ..and on... }, ... , on } and lets have client of api (in case whole new web team that's been hired remote , inexperienced) come , "hey need list of unique last names in system". would you: a) tell person "ok, sure, names part of our people resource endpoint. can return list of people give name.last field back, , you'd 1 person every different name.last exists". give them aggregated grouping of people in order satisfy need every unique last name in database people. so hypothetical url example they'd call /pe...

image processing - Rotate a Bounding Box in Matlab -

i have plotted bounding box on image: bbox = [50 20 200 50]; figure; imshow('coins.png'); hold on; rectangle('position', bbox, 'edgecolor','r', 'linewidth', 3); hold off; how can rotate bounding box bbox 30 degrees around centroid , obtain coordinates of new box, can use inpolygon ? update: please use bounding box defined [x y width height]. to rotate coordinates of bounding box need define proper rotation matrix . start defining coordinates of 4 corners: x = [bbox(1), bbox(1), bbox(1)+bbox(3), bbox(1)+bbox(3), bbox(1)]; y = [bbox(2), bbox(2)+bbox(4), bbox(2)+bbox(4), bbox(2), bbox(2)]; rotation rotates around origin (0,0) , if want rotate around center of box need adjust x , y before , after rotation cx = bbox(1)+0.5*bbox(3); cy = bbox(2)+0.5*bbox(4); rotating xr = x-xc; %// subtract center yr = y-cy; xr = cosd(30)*xr-sind(30)*yr; %// rotate yr = sind(30)*xr+cosd(30)*yr; xr = xr+xc; %// add center yr = yr+...

android - Overriding scrolling method of ScrollView for handling horizontal sliding events -

i want override scrolling method (i don't know function uses handle scrolling) of scrollview edittext (with vertical scrollbar) inside scroll vertically when change of y coordinate (for sliding finger/pointer) greater. , if change of x coordinate greater function called. how can it? here code structure clarification. @override public void scrollerfunction(alistener){ public void actionperformed(params) if(abs(starty-endy) >= abs(startx-endx)) //scrollup or scrolldown else anotherfunction(); } you can override onscrollchanged method. you can try ---> @override public void onscrollchanged (int l, int t, int oldl, int oldt){ // l current horizontal scroll origin. // t current vertical scroll origin. // oldl previous horizontal scroll origin. // oldt previous vertical scroll origin. if(abs(oldt-t) >= abs(oldl-l)) //scrollup or scrolldown else anotherfunction(); } give try. don...

Storing current day, month, year as properties in a relation in neo4j using cypher query -

i want create relationship in neo4j having properties day, time, year of current date. how can current day,month, year using cypher neo4j?? first, neo4j doesn't have support datetime type. data create (n1:node)-[r:relationship {day: 30, month: 9, year: 2015}]->(n2:node) read match (:node)-[r:relationship]->(:node) return r.day, r.month, r.year another approach use graphaware timetree . neo4j module representing time in neo4j tree structure.

Problems with C forks, wrong results, probably shared memory -

i have assignment matrix multiplication forks, using shared memory, compare time results multiplication without forks, here multiplication without them: int matriza[am][an]; int matrizb[an][bp]; //here fill matrix .txt file int matrizr[am][bp]; int a,b,c; (a=0; < am; a++){ (b = 0; b < bp; b++) { matrizr[a][b] = 0; (c=0; c<an; c++){ matrizr[a][b] += matriza[a][c] * matrizb[c][b]; } } } then try implement forks results wrong, im not sure if have implement shared memory , where, matriza, matrizb, , matrizr2 should shared? how this? int matrizr2[am][bp]; pid_t pids[am][bp]; int h,j; /* start children. */ty (h = 0; h < am; ++h) { (j=0; j<bp ; ++j){ if ((pids[h][j] = fork()) < 0) { perror("fork"); abort(); } else if (pids[h][j] == 0) { matrizr2[h][j] = 0; (c=0; c<an; c++){ matrizr2[h][j] += matriza[h][c] * matrizb[c][j]; } ...

sql - How to order rows by hierarchy -

i have table hierarchical, parent-child relations , want order hierarchy. table is: id|parent|type -------------- 1 |0 |1 2 |0 |1 3 |0 |1 4 |0 |2 5 |0 |2 6 |2 |2 7 |3 |2 and result want this: id|parent|type -------------- 1 |0 |1 2 |0 |1 6 |2 |2 3 |0 |1 7 |3 |2 4 |0 |2 5 |0 |2 so want tree view type 1 ordered first , type 2 @ end. now i'm trying use recursion order wrong: with cte ( select id, parent, type tbl id=1 union select id, parent, type, row_number()over( order (case when t.type = 1 1 when t.type = 2 2 else 1000 end) rn tbl t inner join cte c on c.id=t.parent ) select * cte order rn how can this? using order hierarchyid cte simple, not test recursive relations declare @data table (id int identity(1,1) primary key, parent int, type int) insert @data values (0, 1), (0, 1), (0, 1), (0, 2), (0, 2), (2, 2), (3, 2) select * @data ;with level ( ...

javascript - React Native & Webpack: Confusing when ESLint detects errors -

for react native project, i'm using react-native-webpack-server , babel , eslint , webpack-hotloader when eslint detects errors in javascript code, ios simulator still refresh app , display stacktrace. instead displaying errors reported eslint , i've of errors index.ios.bundle can confusing , hard debug. for instance code: 'use strict'; import react, { stylesheet, text, view, touchablehighlight, component } 'react-native'; rger // cause error. export default class contactscomponent extends component { render() { return ( <view> <text>this simple application.</text> </view> ); } } i have error reported eslint : 11:1 error "rger" not defined // pretty straightforward and error reported y simulator (so react native): invariant violation: application contactscomponent has not been registered. either due require() error during initialization or failure c...

python - How can I enable default value display under Django CharField -

Image
i have in django models.py line: class method1(models.model): # other param species_param = models.charfield(max_length=20, choices=(('mouse', 'mouse'), ('human','human')) it looks this: note default value set ---- . want set mouse . how can it? i'd remove --- altogether. i not test may solve problem: class mehod1(models.model): # other param species_param = models.charfield(max_length=20, choices=(('mouse', 'mouse'), ('human', 'human')), default='mouse')

c# - System.Progress wrong invocation order -

i'm trying display download progress using httpclient. use system.progress<t> . code looks this: long totalread = 0l; var buffer = new byte[1024]; bool ismoretoread = true; ulong total = (ulong)response.content.headers.contentlength; while (ismoretoread) { int read = await stream.readasync(buffer, 0, buffer.length); if (read == 0) ismoretoread = false; else { var data = new byte[read]; buffer.tolist().copyto(0, data, 0, read); totalread += read; progress.report((int) (totalread*1d / total * 1d * 100) ); } } assume subscribing looks this: var progress = new progress<int>(); progress.progresschanged += (sender, i) => console.writeline(i); client.download(file, progress).wait(); but result, progress order inconsistent, this: 10, 20, 30, 70, 15, 90, 100, 80. is default delegate's behaviour, or there's reason? progress<t>.report asynchronous; mean, report method not raise p...

asp.net mvc - Add new column in WebGrid MVC -

in razor view, have collection of objects want display in grid. able fields when want remove , add more out of source (the collection) 'column "daysleft" not exist' my code: @code viewdata("title") = "index" dim grid = new webgrid(source:=model, defaultsort:="proj_created_time") dim listofcolumns list(of webgridcolumn) = new list(of webgridcolumn) dim projecttitle webgridcolumn = grid.column("project_title") projecttitle.header = "title" dim projectstatus webgridcolumn = grid.column("proj_status") projectstatus.header = "status" dim projectinitialdate webgridcolumn = grid.column("proj_initial_duedate") projectinitialdate.header = "starting date" dim projectnewduedate webgridcolumn = grid.column("proj_new_duedate") projectnewduedate.header = "due date" dim daysleftcol new webgridcolumn {.columnname = "daysleft", .header = "daysleft...

Corresponding windows cmd command for unix command -

i using following unix command on mac separate out columns in file: cut -d ' ' -f 3,4,5,10,11,12 < testfile.txt file sample: unzip trace file: archive: /logs/1.trace/instrument_data/2dfbb7cf-2b32-41d6-9fa6-73cf813dfc24/run_data/1.run.zip inflating: logs/2.trace/instrument_data/2dfbb7cf-2b32-41d6-9fa6-73cf813dfc24/run_data/1.run run 1, starting @ 2015/08/06 16:46:35:185, running until 2015/08/06 16:53:30:445 sample 0: cpu usage: 2.56% memory usage: 5608.00 kib timestamp: 2015/08/06 16:46:35:955 sample 1: cpu usage: 1.21% memory usage: 5576.00 kib timestamp: 2015/08/06 16:46:37:143 sample 2: cpu usage: 2.46% memory usage: 5560.00 kib timestamp: 2015/08/06 16:46:38:323 sample 3: cpu usage: 2.49% memory usage: 5560.00 kib timestamp: 2015/08/06 16:46:39:502 sample 4: cpu usage: 2.51% memory usage: 5560.00 kib timestamp: 2015/08/06 16:46:40:674 sample 5: cpu usage: 2.56% memory usage: 5560.00 kib timestamp: 2015/08/06 16:46:41:832 sample 6: cpu usage: 2.21% ...

jquery - How to re-init tablesorter -

i using jquery tablesorter plugin. start off having table values , initialise table so.. $("#mystorestatustbl").tablesorter({ sortlist: [[3,1],[10,0],[0,0]], stripingrowclass: ['even','odd'], striperowsonstartup: true, widthfixed: false, widgets: ['zebra'], dateformat: "uk", headers: { 0: { sorter: 'digit' }, 2: { sorter: false }, 7: { sorter: false } } }); i later wipe out contents of table after ajax call... $('#mystorestatustbl tbody').html(''); and re-populate values after ajax call. the re-populate working properties have applied in tablesorter init no longer applied. i tried trigger update after ajax call... $("#mystorestatustbl").trigger("update"); but not work. can please give me advice on this? thanks can please try following sequence after ajax call: $("#mystorestatustbl").trigger(...

.net - how to check if the listView is empty -

im creating windows form , have 2 problems i want enable button add item in listview otherwise disable if empty assuming have added item in listview. how can totalprice of item , put in label item added? thanks. this code use compute total price of item in listview dim total integer = 0 each itemrow listviewitem in me.lvorder.items total += convert.toint32(itemrow.subitems(2).text) next sorry cant put image better understanding because need 10 reputation post image. something simple should want: btnxxx.enabled = (lvorder.items.count > 0) you need make sure doing in appropriate event(s). or when add or remove items

javascript - How to inject one controller function to another controller using angularjs? -

i have 2 ng-controllers example controller1, controller2, want inject controller2 method in controller1 , want access through js api function using "document.queryselector('[ng-controller=custom-entity-design-ctrl]')". possible get? tried using factory services not working. it's saying error $scope not defined. source code **controller1** myapp.controller("controller1",function($scope, $document, $http, $localstorage) { $scope.test1 = function() { alert("test1"); }; }); **controller2** myapp.controller("controller2",function($scope,$http,$compile,$localstorage, $log) { $scope.test2 = function() { alert("test2"); }; }); in detail... want access $scope.test2 method controller1. i tried using factory not working. source code: myapp.factory("testservice", function($compile, $http, $scope) { $scope.test2 = function() { ...

ruby - Javascript trigger when using poltergiest/capybara outside of rails -

i'm using capybara, rspec , poltergeist, outside of rails, run headless integrations tests. scenario that, there 2 select fields. if select value in first select field, 2nd select field populated based on value of first select field. if run spec using poltergeist in mac osx, spec works. in ubuntu, fails, seems 2nd select field not populated. have js: true on specs. here's spec_helper.rb: require 'capybara/poltergeist' require 'capybara' require 'capybara/rspec' require 'pry' require 'support/session_helper' rspec.configure |config| config.include capybara::dsl config.include capybara::poltergeist config.include sessionhelper capybara.run_server = false capybara.default_driver = :poltergeist capybara.javascript_driver = :poltergeist capybara.app_host = "http://vps-staging.dropmysite.com" options = { js_errors: false } capybara.register_driver :poltergeist |app| capybara::poltergeist::driver.new(a...

java - If Task queue failed at some queue then how can i inform to client some queue are failed -

hi using task queue saving customer in customer entity. saving 10 customer customer entity using task queue. task in queue there 10 customer. if due wrong inputs 5 customer not saved in entity , 5 customer saved in entity. how can inform these failed 5 customer information client side. any help? thanks in advance there's no built-in way communicate between tasks , client side. straight forward solution query (poll) server side successful execution of tasks. edit : if don't need let client side know, , want debug problem , see went wrong, can view logs. in developers console go monitoring >> log , search url of task. updated answer accordingly

android - How to mark textview as strike through in Expandable Listview -

when call action mode on expandable listview item, 1 of options mark done. what in onactionitemclicked, child_clicked view long clicked: textview row = (textview) child_clicked.findviewbyid(r.id.todotitle); if (todo.getstatus() == 1) { int count = msqlitehelper.marktodoascomplete(id, msqlitedatabase); row.setpaintflags(row.getpaintflags() & ~paint.strike_thru_text_flag); } else { int count = msqlitehelper.marktodoasactive(id, msqlitedatabase); row.setpaintflags(row.getpaintflags() & (~paint.strike_thru_text_flag)); } row layout looks this: <linearlayout> <textview android:id="@+id/todotitle"/> </linearlayout> but nothing happening, no errors. have done here make work? apply code textview of expandablelistview item. tv.setpaintflags(tv.getpaintflags() | paint.strike_thru_text_flag);

javascript - Split string ignoring html tags -

is possible split string space " " , ignore html tags in ? html tags may have style elements : style="font-size:14px; color: rgb(0, 0, 0)" ..... the string i'm talking is: <div class="line"><span style="color: rgb(0,0,0)">john</span><u> has</u><b> apples</b></div> if can see have space character inside u tag , inside b tag what trying text split following <div class="line"><span style="color: rgb(0,0,0)">john</span><u> has</u><b> apples</b></div> i have following regex not give me rest of string, first 2 parts : [\<].+?[\>]\s split using following regexp: str.split(/ (?=[^>]*(?:<|$))/) [ "<div class="line"><span style="color: rgb(0,0,0)">john</span><u>", "has</u><b>", "apples</b></div...

sql server - How to filter records when foreign table has combined primary key in SQL -

i have 2 tables interlinked: table #1: checklist id_checklist(pk) | name_checklist | version(pk) 1 xyz 1.0.0 1 xyz 1.1.0 1 xyz 1.2.0 2 pqr 1.0.0 3 abc 1.1.0 table #2: machine_checklist id_machine | id_checklist(foreign key) | version(foreign) 1 1 1.2.0 1 3 1.1.0 2 1 1.1.0 now want of remaining checklist not included in id_machine = 1 so query this: select id_checklist, name_checklist, version checklist (id_checklist not in (select mc.id_checklist machine_checklist mc mc.id_machine = '1')) or (version not in (select mc.version machine_checklist mc mc.id_machine = ...

jquery - How to show percentage when form submit? -

i'm using jquery submit form, how display current percentage of form ? /* form */ $(document).on('submit','form.formprogress',function(e){ e.preventdefault(); addloading(); var dataform = $(this).serializearray(); var actionform = $(this).attr('action'); var targetform = $(this).attr('data-target'); type: $(this).attr('method'); $(this).find(":input").attr("disabled", true); $wait = $(this).html('<div class="panel panel-info"><div class="panel-body" align="center"><img src="img/wait.gif"></div></div>'); $(targetform).load(actionform,dataform); clearloading(); return false; }); /* form */ you can use pace.js automatically watches page loads , ajax navigation , shows loader.

ios - seetter connot be specified for readonly property upgrade to swift2.0 -

meet warning when upgrade project code swift 2.0. public class extension : nsobject { private(set) public var name : string = "" } above code prompt warning:setter connot specified readonly property. currently, how update these code adapt swift2.0 "the swift programming language (swift 2.1): access control" writes: you can make property getter public, , property setter private, combining public , private(set) access level modifiers: therefore, it's legal: public class extension : nsobject { public private(set) var name : string = "" } ps: way, works swift 2.0 too.

javascript - MutationObsrver not able to recognise changes -

i have written small script identify changes in paragraph. don't know why changes not identified mutationobserver . want alert displayed when there changes made text. $(function(){ //store test paragraph node var test = $('#test'); //observe paragraph this.observer = new mutationobserver( function(mutations) { alert('paragraph changed!') }.bind(this)); this.observer.observe(test.get(0), {characterdata: true, childlist: true}); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <div contenteditable="true" id="editor"> <p id="test"> edit text! </p> </div> any or suggestions highly appreciated, thank in advance! you need add subtree: true config (example below). because character data that's changing isn't p element, it's text node within p element. if obs...

Swift: casting Any to array of protocol objects -

there protocol: protocol valuable { func value() -> int } and class implements protocol: class value: valuable { private let v: int init(value: int) { v = value } func value() -> int { return v } } there array of value objects stored in variable of type: let any: = [value(value: 1), value(value: 2), value(value: 3)] it possible cast [value]: let arrayofvalue = as? [value] // [1, 2, 3] why not possible case [valuable]? let arrayofvaluable = as! [valuable] // compiler error bad instruction let arrayofvaluable2 = as? [valuable] // nil updated: in swift3 entirely possible cast [any] [valuable] . cast succeed long elements in array can casted; cast fail otherwise. var strings: [any] = ["cadena"] var mixed: [any] = ["cadena", 12] strings as! [string] // ["cadena"] mixed as? [string] // nil mixed as! [string] // error! not cast value... previously of swift 2: make [valuable] o...

drupal - Yaml, mapping multiple values -

i trying improve upon wordpress drupal 8 migration module ( https://github.com/amitgoyal/d8_migrate_wordpress ) , add functionality import taxonomy terms. have written queries join taxonomy terms posts, having trouble assigning multiple terms field (called tags, entity reference taxonomy terms) of drupal content type article. have created manifest file mapping article content type: id: posts label: wordpress posts migration_groups: - wordpress source: plugin: posts destination: plugin: entity:node process: nid: id vid: id type: type langcode: plugin: default_value default_value: "und" title: post_title uid: post_author status: plugin: default_value default_value: 1 body/value: post_content body/format: normal field_image/target_id: post_image field_tags/target_id: terms in posts.php file, handles fetching , processing of wordpress data, have function (prepareterms), sets property 'terms', used yaml file above. if se...

sql - How to select the lowest and highest value joined in one row postgres -

i have data in similar format this +--------+------------+-------+ | type | variety | price | +--------+------------+-------+ | apple | gala | 2.79 | | apple | fuji | 0.24 | | apple | limbertwig | 2.87 | | orange | valencia | 3.59 | | orange | navel | 9.36 | | pear | bradford | 6.05 | | pear | bartlett | 2.14 | | cherry | bing | 2.55 | | cherry | chelan | 6.33 | +--------+------------+-------+ and want row per type highest price , lowest price so, variety should taken form row highest price +--------+------------+-------+-------+ | type | variety | min | max | +--------+------------+-------+-------+ | apple | limbertwig | 0.24 | 2.87 | | orange | navel | 9.36 | 3.59 | | pear | bradford | 6.05 | 2.14 | | cherry | chelan | 6.33 | 2.55 | +--------+------------+-------+-------+ what best way achieve using postgres? i found site: how select first/least/max row per group in sql , it...

wordpress - Woocommerce: Align add to cart button with CSS -

is there way align “add cart” button on shop page ? when product names different lengths. try add css code not working without hover. .woocommerce .products .product .button { font-size: 13px; /* padding:8px 26px; */ margin-left: 10px; position: absolute !important; display: block; bottom: 30px; vertical-align: bottom !important; } .woocommerce a.added_to_cart { /* display: inline-block; */ font-size: 12px; line-height: 18px; padding-top: 8px; position: absolute !important; display: block; bottom: 30px; vertical-align: bottom !important; white-space: nowrap; border-bottom: 1px solid transparent; } try break product name if product name long enough or use 'product name long..... ' way display product name.or better override template archive.php on child theme.

javascript - Covert pure angular to ecma6 plus angular -

i want build dynamic controllers in eccma script code.i'll show example angular code.but couldn't understand how implement in eccma6. let module = 'app.core.checka'; class windowviewer{ constructor() { this.restrict = 'e'; this.template = ` < button ng - click = "sendmsg()" > 85855 < /button><div ng-model="ngmodel" kendo-window="windowid" k-title="'ajax content'" k - width = "'90%'" k - height = "'90%'" k - visible = "false" k - draggable = "false" k - max - height = "'100%'" k - max - width = "'100%'" k - position = "{top: '10px', bottom: '100px', left: '5%', right: '5%'}" k - position - left = "'5%'" k - pinned = "true" k - actions = '[ "minimi...

symfony - Symfony2 Sylius setting the default locale -

when want create shipment error: an exception has been thrown during rendering of template ("no locale has been set , current locale undefined.") in sonataadminbundle::standard_layout.html.twig @ line 148. i think need set default locale sylius, tried alot of examples, none of them helped.. i have setup: config.yml: sylius_shipping: driver: doctrine/orm # configure doctrine orm driver used in documentation. classes: shipping_method: model: application\sylius\shippingbundle\entity\shippingmethod translation: model: application\sylius\shippingbundle\entity\shippingmethodtranslation shipping_method_rule: model: application\sylius\shippingbundle\entity\rule shipment: model: application\sylius\shippingbundle\entity\shipment shipment_item: model: application\sylius\shippingbundle\entity\shipmentitem shipping_category: model: applicati...