Posts

Showing posts from August, 2014

excel - How to get a blank value in lookup? -

i have lookup formula use gather information different page in spreadsheet: =(vlookup($a$3,lookup!$a$3:$ag$472,2,false)*0.01) but if there no data in cell of lookup page, returns value of 0 . cell remain blank, same original cell. try this: =if(vlookup($a$3,lookup!$a$3:$ag$472,2,false)="","",vlookup($a$3,lookup!$a$3:$ag$472,2,false)*0.01)

Facebook Sharing API - Specify Different Image for Object on Page -

i know how set og tags pages specify image, here situation: i have page 4 shareable objects. 1 leads page it's own open graph tags, he's okay. other 3 share link anchor position on same page. how make each of own image? so instance: shareable 1: http://www.demo.com/page <--- fb get's og tags page shareable 2: http://www.demo.com/home#video <-- fb get's og tag home, want specify different image shareable 3: http://www.demo.com/home#photos <-- fb get's og tag home, want specify different image shareable 4: http://www.demo.com/home#cheese <-- fb get's og tag home, want specify different image information afer hashtags gets ignored, have rewrite or parameter, example: http://www.demo.com/home?id=xxx http://www.demo.com/home/video

google apps script - .getFilesByType() does not seem to be working -

i have folder may or may not contain forms , connected response spreadsheets. however, code below returns false when these files present. //checks number of google forms in subdomain folder var files = myfolder.getfilesbytype('google_sheets'); logger.log(files.hasnext()); this code returns true: var files = myfolder.getfiles(); logger.log(files.hasnext()); i'm imagining i'm somehow getting mimetype wrong, far can see in google's documentation correct. i'd rather check these file types instead of checking files. any thoughts? mimetype.google_sheets try instead of 'google_sheets'. i'm not able test @ moment, format google documentation asking for. take notice there not quotes around it.

drupal - Custom Configuration for CK Editor 4 -

i created little module in drupal 7 use custom config file ck editor. works, because can adapt ui color or can activate scayt , edit options imn scayt. so think custom config file working ok. tried saomething plugins in install folder of ck ... seems these not active or not loaded. there difference between assemble ck editor via ck builder , download plugins manually , activate plugins via config.extraplugin = 'floating-tools'; i have expierence, lot of plugins, download not active .... why there no visible control in settings dependig plugins???? how check if plugin loaded. there thing after configuration in custom config file made changings take effect? ...sorry seems dont understand way use ck builder ... i´m confused ... today uploaded build-config.js , added , reduce plugins ... downloaded new version 4.5.4. .. ??? used 4.5.3 before ... then pasted new ck-editor libraries folder of drupal installation , nothing works ... no ckeditor comes editing content

c - If Else in a While Loop -

i having trouble code. when run it, prints out 2 lines in while statement. i'm trying run if statement until mortgageleft can see mistake i'm making? idk if helps, if delete else statement, program runs fine #include <stdio.h> #include <stdlib.h> int main(){ float mortgageleft, interestrate, monthlypayment, monintrate, amountowed; int month=0; printf("what value left on mortgage?\n"); scanf("%f", &mortgageleft); printf("what annual interest rate of loan, in percent?\n"); scanf("%f", &interestrate); printf("what monthly payment?\n"); scanf("%f", &monthlypayment); monintrate= (interestrate/12)/100; printf("month\t\t payment\t amount owed\n"); while (mortgageleft>0) { if(mortgageleft>monthlypayment) { mortgageleft=(mortgageleft*monintrate)+mortgageleft; mortgageleft=mortgageleft-mon

core data - Can I use NSBatchDeleteRequest on entities with relationships that have delete rules? -

i'm attempting use nsbatchdeleterequest delete pile of entities, many of these entities have delete cascade and/or nullify rules. my first attempt delete fails , nserror includes string "delete rule not supported batch deletes". had thought fine delete such things responsible making sure constraints satisfied before save. should able batch delete these managed objects? (i want keep delete rules, other delete paths don't have easy way know set of objects delete) kinds of batch deletes work in case, others not? (say predicates fail, list of object ids work?) batch delete problematic relationships. it goes directly database , deletes records suspending object graph rules, including delete rules. have correctly identified requirement need constraint checking again. (that deal-breaker.) even if manage delete entities , necessary related entities correctly, still left lots of entries in (opaque) join table core data creates in background. there

Powershell takes too long to close; can't totally override the default prompt function -

i don't know what's happening powershell. have shell registry key allows me open powershell window in directory. content is: c:\windows\system32\windowspowershell\v1.0\powershell.exe -executionpolicy unrestricted -noexit and custom defined prompt function: function prompt { write-host ("on ") -nonewline -foregroundcolor white write-host ("$env:computername") -nonewline -foregroundcolor gray write-host (" in ") -nonewline -foregroundcolor white write-host ($(get-location)) -foregroundcolor gray write-host ("$") -nonewline -foregroundcolor magenta return "> "; } it should return on pc-name in c:\ $> however, returns this: on pc-name in c:\ $> ps c:> anything wrong @ powershell? how more debug information guys? i fix issue commenting out few functions in psreadline module installed. module add `b end of current prompt, append user prompt it, , re

symfony - Entity propetytype as object in Symfony2 -

i'm looking information, how use entity propety type object. i have entity products , categories. in products entity propety category type object. how pass object categories propety? ideas how use? example ? i say: don't use object type. instead use doctrine's association mappping . i advice use one-to-many bidirectional or many-to-many bidirectional if want able have 1 product in multiple categories too. follow these steps: place examples in own entity , change annotations @... @orm\... generate getters , setters commandline: app/console doctrine:generate:entities appbundle update database schema: app/console doctrine:schema:update --force now check created getter , setter functions. might find getproducts() removeproduct() , addproduct().

mysql - WordPress import database error -

i'm moving localhost based website live server, uploaded files server. after that, created new database, when came import old database sql file exported localhost, got error : #1064 - have error in sql syntax; check manual corresponds mysql server version right syntax use near '?' @ line 2 line 2 in sql file : -- version 4.1.14 i think server mysql older version. try use plugin move localhost wordpress site server plugins https://wordpress.org/plugins/duplicator/ and https://ithemes.com/purchase/backupbuddy/ try of these two.

Number of Rows in a Full Join (DB2 - SQL) -

i running db2/sql - full join query. proc sql; connect db2 db1 (user=&dpwuscod. password=&dpwpwcod. database=&dpwdbnam.); create table result3 select * connection db2 ( select count(* ) nbrcount full join b on a.pk = b.pk , a.snap_dt='2015-08-31' , a.sys_num not in ('1234') ); disconnect db2; quit; table has 586,648 rows. table b has 2,384,874 rows. i expecting number of rows in full join between 2,384,874 (when there complete overlap of pk) 2,971,522 (when 2 tables have mutually exclusive pk / 2,971,522 = 586,648 + 2,384,874) however, in actuality, above join yielding nbrcount = 24,898,361. any pointers on why number of rows has blown up? because pk s have duplicate matches. easy enough find: select pk, count(*) group pk having count(*) > 1; select pk, count(*) b

c - Segmentation Fault in a Simple Red-Black Tree -

i'm trying build simple red-black tree in c. unfortunately, have encountered segmentation fault i'm not sure how fix. i've included code below , marked line fault occurring. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define red 1 #define black 0 typedef struct rbnode { char key[50]; int color; struct rbnode *left; struct rbnode *right; struct rbnode *parent; } rbnode; typedef struct rbtree { struct rbnode *root; struct rbnode *nil; } rbtree; void inorderprint(rbtree*, rbnode*); void insertrb(rbtree*, rbnode*); void insertrbfixup(rbtree*, rbnode*); void leftrotate(rbtree*, rbnode*); void rightrotate(rbtree*, rbnode*); int count; int main (int argc, char* argv[]) { rbtree *tree = malloc(sizeof(rbtree)); tree->nil = malloc(sizeof(rbnode)); tree->nil->color = black; tree->root = null; tree->nil->left = tree->root; tree->nil->righ

c - Confusion with Pointers Increment -

char *str = "string" ; char *end = str; while(*(end+1) != '\0') { end++; } while(str < end) { char temp = *str; *str = *end; *end = temp; str++; end--; }` edit: both these *str = *end , *str++ = *end invalid? the above code gives error @ line. aren't str , end pointing read part in memory whether post increment? char *str = "string" ; is string literal placed in read-only data section. in line: *str = *end; is trying modify string, segfault.. same *str++ = *end , both invalid. to make code work, change char *str = "string"; to char str[] = "string"; but note can not use *str++ because array names constant (not modifiable lvalue)

c# - Visual studio solution explorer not showing form cs file -

Image
cant find user code file of windows form in solution explorer, must right click on form class , choose <>view code. there been cs file @ bottom of class. have checked default editor files? right click on form.cs file: select desired editor click set default button csharp form editor: opens form on design view. csharp editor: opens code view.

dynamic programming - Finding a Perfect English Pangram Algorithm -

the thought of pranking coworker has lead me thinking of ways find perfect english pangrams. plan write program using dynamic programming techniques try determine possible perfect pangrams, unless else knows of 1 exists, or able provide me known solution. the prank plan arrange keys on coworker's keyboard pangram makes sense, in order so, characters can appear once. as programmer, thought of interesting problem , after doing googling, have not found pangram doesn't have repeating characters. with limited number of vowels of english language, expect might impossible. if not impossible, i'm curious there sentence can create make sense. it's nice problem! if approach problem in way: find english dictionary has part of speech each word is. discard words repeating characters. find/create grammar english sentence. may this: s -> np vp, np → pronoun | proper-noun | ... reference start building sentences backtracking procedure using grammar given

dockerfile - Some RUNs won't work on docker but will when inside a container -

i've got dockerfile lua , torch related tasks , i'm trying install rocks using luarocks. from ubuntu:14.04 run rm /bin/sh && ln -s /bin/bash /bin/sh run apt-get update -y run apt-get install -y curl git run curl -s https://raw.githubusercontent.com/torch/ezinstall/master/install-deps | bash run git clone https://github.com/torch/distro.git ~/torch --recursive run cd ~/torch; ./install.sh run source ~/.bashrc run luarocks install nngraph run luarocks install optim run luarocks install nn run luarocks install cltorch run luarocks install clnn docker build runs fine until first luarocks call: run luarocks install nngraph @ point stops , throws error: /bin/sh: luarocks: command not found if comment out luarocks lines, build runs fine. using image, can create container , using bash, run luarocks expected. of course, don't particularly want have every time start container, i'm wondering if there's can make work. have feeling problem has line r

knockout.js - KnockoutJS: collecting values of checkboxes and selects in array together -

i'm pulling hair out on one. need loop on selected items, consisting both of checkboxes , select lists, , compile array of selected models. this eluding me because checked , select's value work differently. trying store selected option in parent model (with selectedoption observable). worked fine <select> because saved reference model, checkboxes, save boolean value. i tried setting flag on model itself, fine checkboxes, can't access individual options let them know they're current selection in select list. all models populating checkboxes , dropdown lists of same type, i'm displaying them differently depending on internal properties. how can collect models of selected options both checkboxes , select lists? edit: adding samples. there's item model parent option model. function itemmodel(vm, item) { var self = this; self.name = item.name; self.description = item.description; self.options = ko.observablearray(mapoptions

java NullPointerException existed Image -

what want when user selects image, image must copied specific folder , use image. this use copy image: files.copy( paths.get("c:/../img.png"), paths.get("c:/../src/bgs").resolve(array[array.length-1]), standardcopyoption.replace_existing); which works fine. problem if use image after command, nullpointerexception (i don't have problem if use thread.sleep(2500) between 2 commands). need way check if file ready used. so far used following code // copy file file f = new file(new_path); sout(f.exists()); // use file image background = toolkit.getdefaulttoolkit().getimage( getclass().getresource("/bgs/img.png")); which prints true, when use nullpointerexception again.. ideas? exception: uncaught error fetching image: java.lang.nullpointerexception @ sun.awt.image.urlimagesource.getconnection(urlimagesource.java:115) @ sun.awt.image.urlimagesource.getdecoder(urlimagesource.java:125) @ sun.awt.image.inputstre

ember.js - Specify a login only template in Ember -

is there way in emberjs have separate template login doesn't render rest of application template? ideally create login component, can't figure out how render on login route without being wrapped in application template. unfortunately there isn't. there might clever hacks, there's no way out of box. however, had same problem , solved using simple if statement. can use currentroutename property current route name, allows this: application controller isloginroute: ember.computed('currentroutename', { get() { return (this.get('currentroutename') === 'login'); } }) application template {{#if isloginroute}} {{outlet}} {{else}} <div> <span>some content</span> {{outlet}} </div> {{/if}}

c# - Not every result of IProgress<int> comes out of the task -

consider following implementation, method accepts iprogress<int> , iterates on 10000 objects. numbers array variable returns 10000 objects, iprogress<int> reports between 9970 - 9980 objects. varies per run, "lost". protected async override task<int[]> collectdataasyncimpl(iprogress<int> progress) { return await task.run<int[]>(() => { var numbers = new list<int>(); foreach (var idx in new int32range(1, 10000).asenumerable().index()) { numbers.add(idx.value); if (progress != null) { progress.report(idx.value); } } return numbers.toarray(); }); } as reference, here's test ran. fails @ third assert assert.equal(10000, result[9999]); . [fact] async void reportsprogress() { var sut = new

How to use contents of one array to set contents of other array to true in javascript? -

i've got 2 javascript arrays. 1 default array: propertytypes = [ {key:'office', value:false}, {key:'residential', value:false}, {key:'retail', value:false}, {key:'industrial', value:false}, {key:'hotel', value:false} ]; and array looks this: property_types: [ { "type": "office" }, { "type": "retail" } ] i want set values in first array true occur in second array type first array this: propertytypes = [ {key:'office', value:true}, // 1 should true {key:'residential', value:false}, {key:'retail', value:true}, // , 1 {key:'industrial', value:false}, {key:'hotel', value:false} ]; i had ideas using kind of double nested loop, none of them seem make sense. does know how can in logical way? tips welcome! you can use arr.map achieve this. map() method creates new ar

sqlite - Clearing bindings on an SQLite3 statement doesn't seem to work (PHP) -

when inserting multiple rows sqlite3 in php using prepared statement, if don't bind parameter row value previous row inserted, if "clear" statement between lines. look @ following example: $db = new sqlite3('dogsdb.sqlite'); //create database $db->exec("create table dogs (id integer primary key, breed text, name text, age integer)"); $sth = $db->prepare("insert dogs (breed, name, age) values (:breed,:name,:age)"); $sth->bindvalue(':breed', 'canis', sqlite3_text); $sth->bindvalue(':name', 'jack', sqlite3_text); $sth->bindvalue(':age', 7, sqlite3_integer); $sth->execute(); $sth->clear(); //this supposed clear bindings! $sth->reset(); $sth->bindvalue(':breed', 'russel', sqlite3_text); $sth->bindvalue(':age', 3, sqlite3_integer); $sth->execute(); even though expect second line have null value 'name' column, value 

debugging - Java reflection after invoking method the method is not throwing exception -

so created invalidinputexeption exception class , used in setter methods throw exception if there not valid input. public class kalsi.contestantinformation { public void setfirstname(string firstname) throws invalidinputexeption { checkinput(firstname, "please enter letter in first name"); this.firstname = firstname.replaceall("\\s", "").tolowercase(); } public void setlastname(string lastname) throws invalidinputexeption { checkinput(lastname, "please enter letter in last name"); this.lastname = lastname.replaceall("\\s", "").tolowercase(); } public void setstreetnumber(string streetnumber) throws invalidinputexeption { checkinput(streetnumber, "please enter numbers in street number"); this.streetnumber = streetnumber.replaceall("\\s", "").tolowercase(); } public void setstreetname(string streetname) throws inv

animation - Animating a Fractal Via OpenGL -

i working on animating fractal (triangle fractal) frame-by-frame. know need use call-back method this, not sure how implement it. wish working via left-mouse click have code: void mouse(int button, int state, int x, int y){ if(button == glut_right_button && state == glut_down){ glclear(gl_color_buffer_bit); divide_triangle(v[0], v[1], v[2], n); } //closes window on right button if(button == glut_right_button && state == glut_down){ exit(0); } } this mouse click call back, doesn't re-animate triangle each time triangle drawn. how can show process of drawing each time recurse through triangle drawing? void divide_triangle(point2 a, point2 b, point2 c, int m) { /* triangle subdivision using vertex coordinates */ point2 v0, v1, v2; int j; if(m>0){ for(j=0; j<2; j++) v0[j]=(a[j]+b[j])/2; for(j=0; j<2; j++) v1[j]=(a[j]+c[j])/2; for(j=0; j<2; j++) v2[j]=(b[j]+c[j])/2; divide_triangle(a, v0, v1, m-1); di

sql - How to select the same column twice with different order -

here problem. need order same colum in diferent ways in same select. first asc , desc. example: table1 +--------+-----+ | name | age | +--------+-----+ | coa | 20 | | bami | 12 | | alice | 50 | +--------+-----+ the results should be: +------+-----+ | age | age | +------+-----+ | 12 | 50 | | 20 | 20 | | 50 | 12 | +------+-----+ i want same column first orders ascendant , descendant. i trying query select t1.age, t2.age table1 t1 inner join table1 t2 on t1.name=t2.name order t1.age asc, t2.age desc but in result, both columns ordered in same way. anyone knows how solve problem? that weird requirement. can using row_number() , join: select t1a.age, t1b.age (select t1.*, row_number() on (order age asc) seqnum table1 t1 ) t1a join (select t1.*, row_number() on (order age desc) seqnum t1 ) t1b on t1a.seqnum = t1b.seqnum order t1a.age;

javascript - How to show set of Radio buttons based on a previous Radio Button -

i have form radio buttons on it. when user selects "unfit", want them go on indicate reason second set of radio buttons. don't want reasons displayed until have clicked on "unfit" radio button. how accomplish in javascript or jquery? here's code, sorry design <div class="col-xs-7"> <input type="radio" name="res" <?php if (isset($res) && $res=="fit") echo "checked";?> value="fit">fit <br> <input type="radio" name="res" <?php if (isset($res) && $res=="unfit") echo "checked";?> value="unfit">unfit <br> <input type="radio" name="res" <?php if (isset($res) && $res=="all") echo "checked";?>value="all">all </div> <div class="col-xs-3"> </div> </div> <div cl

python - Extra lines being printed based on earlier input datatype -

my question how program handles unexpected inputs. seems work fine except when string entered. when 1 inputs string coin, message " please enter valid input " appears , main run again, expected. when 1 of amounts in coins entered correctly, program spits out proper input, each time incorrect string entered earlier, seems 'remember' , prints " thank patronage, paid: 0 cad ". example, following terminal session occur: please select coin value in pennies (no toonies allowed): asd please enter valid input please select coin value in pennies (no toonies allowed): hmm please enter valid input please select coin value in pennies (no toonies allowed): 100 thank patronage, paid: 100 c cad thank patronage, paid: 0 c cad thank patronage, paid: 0 c cad i want statement regarding 100c show up. i don't understand causing code ' remember ' string inputs. code below, stumped why happening. when else statement in coinamount()

How to send a message in a specific port with python sockets ? No random ports -

i have test broadcast acknowledgement on localhost. have text files represent nodes , inside there list of neighbors. use localhost ip , port number of node. the problem when receive message (that sent) node 7000, python replaces random number example 65724. father 65724 instead of 7000, cannot remove 7000 list of neighbors. cannot complete algorithm , frustrating. i can send message port number want, it's not elegant. could tell me how not allow python randomize port? rmunn saved me, answer looking far bind before connect method. befor sending message bind own port , connect other one. this not python problem, per se. confused how ports work. each tcp communication (sending or receiving) has 2 ip addresses , 2 ports: host ip , host port, , destination ip , destination port. if you're communicating computer "out there" on network, host , destination ips different. in test case, host , destination ips both 127.0.0.1 (localhost). i'm going

android - MPChart BarChart: draw x axis line on zero value -

i using mpchart displaying barchart. values positive , negative. want show xaxis used in math of traditional way. using code chart display vertical lines (only 0 wanted) mxaxis = mchart.getxaxis(); mxaxis.setdrawgridlines(false); mxaxis.setenabled(false); myaxis = mchart.getaxisleft(); myaxis.setdrawaxisline(false); myaxis.setdrawgridlines(true); myaxis.setstartatzero(false); myaxisright = mchart.getaxisright(); myaxisright.setenabled(false); myaxisright.setdrawgridlines(false); please, provide sample removing horizontal lines zero edit: when yaxis.setlabelcount(1) (1 because 0 value needed shown) impl looks like: public void setlabelcount(int ycount) { if(ycount > 25) { ycount = 25; } if(ycount < 2) { ycount = 2; } this.mlabelcount = ycount; } so, recommended override implementation? i have got solution labels @ bottom use in code mxaxis = mchart.getxaxis(); mxaxis.setdrawgridlines(false); mxaxis.setenabled

javascript - Not able to access PHP variable -

i struggling/trying since last 24 hours simple thing, not able understand why not able access php variable. know doing wrong , have no idea what's that.. window.alert("variable" + <?php echo $_post; ?> ); its giving me output function array() {[native code]} , how can print values ? , think post attribute blank, can check ? why post variable blank ? i sending data file via post method <script type="text/javascript"> function callajaxaddition() { arguments0 = { arg1: $("#exampleform input[id='pac-input']").val(), arg2: ("#exampleform input[id='pac-input']").val() }; $.ajax({ type: "post", url: "processajax.php", data: { arguments: arguments0 }, success: function(data) { $("#answer").html('<ul><li>' + data + '</li></ul>'); send_apptn

javascript - Assign Module Value to Variable -

is there way use module recursive-readdir such: var recursive = require('recursive-readdir'); var files = recursive-readdir(dir); instead of: var recursive = require('recursive-readdir'); recursive('some/path', function (err, files) { // files array of filename console.log(files); }); sorry if dumb question, i'm confused. thank in advance.

javascript - How can I loop through a new generated array without overwrite it? -

i've been learning code own knowledge isn't technical you'd expect be. having saying that, i'm in project handles images , includes showing information them filelist object user, part of information shown in format: chrysanthemum.jpg (image/jpeg) - 879394 bytes, last modified: 13/7/2009 . program allows user delete preselected files before uploading remaining ones, when item deleted group information should go well. i'm not going make go crazy reading +600 lines of code can tackle down problem, therefore i'm giving simple summarized approach of issue is. in case want deleted first item when function called take peek next code: <input type='button' id='load' value='load_info' /> <div id='ok'> <ul id='pic_info'></ul> </div> <div id='message'></div> <input type='button' id='bye' value='bye[0]' /> var files = ["chrysanthemum.jpg

php - PDO Mysql data undisplayed when insert data is present -

Image
problem when displayed data database see data in page. when i'm put insert data unviewable. this code: <?php include 'db.php'; $stmt = $db->prepare('select * ' . $table); $stmt->execute(); if(isset($_post['btn-insert'])){ $prodname = $_post['prod_name']; $prodsupp = $_post['prod_supplier']; $prodprice = $_post['prod_price']; } ?> <html> <head><title></title></head> <body> <table cellpadding="4" cellspacing="2" border='1'> <tr> <th>product id</th> <th>product name</th> <th>product supplier</th> <th>product price</th> </tr> <?php while($product = $stmt->fetch(pdo::fetch_obj)) { ?>

android - Retrieve all folders using root (su) in ADB -

how retrieve folders using su in 1 command? without root use adb shell "ls -r / | grep /" and when try adb shell su "ls -r / | grep /" it doesn't work. how must syntax work? use -c option of su execute command. need 2 levels of quotes -- adb shell "su -c 'ls -r / | grep /'"

synchronization - How to use mutex to sync this secuence: (A or B)C (A or B) (A or B)C -

i'm learning sync mutex , have problem. need 3 threads, each 1 print letter , i've print secuence te tittle in infinite loop. idea , b thread make same thing except print. idea use trylock initial value 1, aorb mutex initial value 1 , c mutex initial value 0. realise work first iteration , write alway 2 (aorb)... posible solve in way? void *ruta(){ //rut b same print b while(1){ pthread_mutex_lock(&semaob); printf("a"); fflush(stdout); sleep(1); if(sem_trywait(&turnoc) == 0){//(aorb) pthread_mutex_unlock(&semc); }else{////(aorb)(aorb) sem_post(&turnoc); pthread_mutex_unlock(&mutexaob); } } pthread_exit(null); } void *rutc(){ while(1){ pthread_mutex_lock(&mutexc); printf("c"); sleep(1); fflush(stdout); pthread_mutex_unlock(&semaob); } pthread_exit(null); } you

recursion - Can every recursive algorithm be improved with dynamic programming? -

i first year undergraduate csc student looking competitive programming. recursion involves defining , solving sub problems. understand, top down dynamic programming (dp) involves memoizing solutions sub problems reduce time complexity of algorithm. can top down dp used improve efficiency of every recursive algorithm overlapping sub problems? dp fail work , how can identify this? the short answer is: yes. however, there constraints. obvious 1 recursive calls must overlap. i.e. during execution of algorithm, recursive function must called multiple times same parameters. lets truncate recursion tree memoization. can use memoization reduce number of calls. however, reduction of calls comes price. need store results somewhere. next obvious constraint need have enough memory. comes not-so obvious constraint. memory access requires time. first need find result stored , maybe copy location. in cases, might faster let recursion calculate result instead of loading somewher

asp.net - how to get only date part from date string in C# -

i need in format "2015-10-03" , im getting "10/3/2015" , "10/3/2015 12:00:00 am" both not working in query .because updateddate datatype date only fromdate = txtbox_ajaxcalfrom.text.trim();// 10/3/2015 datetime frmdt = convert.todatetime(fromdate);// 10/3/2015 12:00:00 todate = txtbox_ajaxcalto.text.trim(); datetime todt = convert.todatetime(fromdate); i want query this updateddate between '2015-10-03' , '2015-10-03' full query gvorders.datasource = getdata(string.format("select * goalsroadmap activities='{0}' , project ='" + projectname + "' , updateddate between '2015-10-03' , '2015-10-03' ", customerid)); try this: datetime frmdt = convert.todatetime(fromdate); string frmdtstring = frmdt.tostring("yyyy-mm-dd"); or @ once: string frmdt = convert.todatetime(fromdate).tostring("yyyy-mm-dd"); so code this: fromdate

docker - Advantages of a Dockerfile -

we can create docker images , push them hub without dockerfile. why useful, have dockerfile? advantages of it? dockerfile creation process high consumption of time , can made human. know main difference between base image based, committed image , dockerfile based image. dockerfile used automation of work specifying step want on docker image. a dockerfile text document contains commands user call on command line assemble image. using docker build users can create automated build executes several command-line instructions in succession. yes , can create docker images every time when want make change have change manually , test , push . or if use dockerfile dockerhub rebuild automatically , make change on every modification , if wrong rebuild fail. advantages of dockerfile dockerfile automated script of docker images manual image creation become complicated when want test same setup on different os flavor have create image flavor small changing in dock

How do you put vertical lines in between DataGrid Headers in C# WPF -

i have datagrid, i'm trying put vertical lines in headers - datagrid has feature put vertical , horizontal gridlines in.. how in world can put gridlines separate headers? right have <datagrid.resources> <style targettype="{x:type datagridcolumnheader}"> <setter property="background" value="lightblue" /> <setter property="fontweight" value="bold" /> <setter property="fontsize" value="18" /> <setter property="fontfamily" value="calibri" /> </style> </datagrid.resources> datagridcolumnheader buttonbase , can style borderthickness , borderbrush achieve want, may want header center, need set horizontalcontentalignment : <datagrid.resources> <style targettype="{x:type datagridcolumnheade

swift - How to transpose an array of strings -

i've txt includes datas following format. ayga:gka:goroka:goroka:papua new guinea:06:04:54:s:145:23:30:e:5282 ayla:lae::lae:papua new guinea:00:00:00:u:00:00:00:u:0000 aymd:mag:madang:madang:papua new guinea:05:12:25:s:145:47:19:e:0020 how disintegrate each line colons(":") , load each section arrays in example. var array1 = ["ayga", "ayla", "aymd"] var array2 = ["gka", "lae", "mag"] var array3 = ["goroka", "", "madang"] var array4 = ["goroka", "lae", "madang"] var array5 = ["papua new guinea", "papua new guinea", "papua new guinea"] var array6 = ["06", "00", "05"] var array7 = ["04", "00", "12"] var array8 = ["54", "00", "25"] var array9 = ["s", "u", "s"] var array10 = ["145", "00&

Date Filter in java -

this question has answer here: how compare dates in java? 11 answers i need filter date "from date" "to date" using "current date" filter. here code use in java application: string = "19/05/1991"; string cmp = "23/05/1991"; string = "23/12/2015"; if (from.compareto(cmp) <= 0 && to.compareto(cmp) >= 0) { system.out.println("date lies between , date"); } is code correct? you should this: string = "19/05/1991"; string cmp = "23/05/1991"; string = "23/12/2015"; dateformat format = new simpledateformat("dd/mm/yyyy"); date date1 = format.parse(from); date date2 = format.parse(cmp); date date3 = format.parse(to); if(date1.before(date2) && date3.after(date2)) { system.out.println("date lies between , date");

Linux Perf equivalent for: dtrace -n 'io:::start /execname == "kworker"/ { printf("%d %s %s", pid, execname, fileinfo_t}' -

i need like: dtrace -n 'io:::start /execname == "kworker"/ { printf("%d %s %s", pid, execname, fileinfo_t}' using perf.. how do so? where's perf language documented? problem i'm facing this: have app generating write sdc - know app kworker need figure out why kworker doing (i'm using flash disk i'm write sensitive)? i'm seeing lines in dmesg : [17621.884263] kworker/u4:2(18327): write block 794104 on sdc1 (8 sectors)

javascript - Ui-router state with state parameter not recognized on page reload -

i have extremely strange situation ui-router. have state defined so: .state('profilequestion', { url: '/profile-questions/:profilequestionid', templateurl: 'client/users/views/profile-question.ng.html', controller: 'profilequestionctrl' }) it works fine , dandy navigate through app. however, if go straight page, example localhost:3000/profile-questions/1 , app not recognize page, , tries go otherwise route. $urlrouterprovider.otherwise('/login'); what's more, goes /profile-questions/login instead of /login ! controller profile-questions never gets called. in sum, ui router works fine when navigate page another, fails when load page itself. should add if remove state parameter options :profilequestionid , /profile-questions route loads correctly. ideas? as @radim kohler , @joe lloyd suggested, issue html5 mode turned on. see server thinks looking in /profile-questions/ directory - doesn

python - Count mismatch using graph.V().count() and graph.V().has().count() -

so, simpleaddition of verteces in dataframe , edges using own python api failing. set of steps follows: step 1: cleaning db before adding anything. achieved using: g.v().drop().iterate() that followed iterating on dataframe rows add verteces: ret = g.addv(label).property(kwargs['colname'], node_val).next() i keep reference id of vertex add edges it. issue crops up. do: g.v().count() each time , returns 0 expected , want, error in first iteration itself: gremlin_python.driver.driver_remote_connection.gremlinservererror: 500: adding property key [name] , value [indiana jones] violates uniqueness constraint [name] so, do: print(g.v().has('name', 'indiana jones').count().next() print(g.v().count().next)) the output are: 1 0 isnt strange because count of verteces 0 whereas specific property vertex returning 1. why that? skeleton code follows: 1: clean db 2: use df.iterrows() add vertex in csv file iteratively. 3: created set of vertex

android - Proper way of handling messages in chat -

i have added chat feature app. storing messages , timestamps in firebase database . i trying figure out way of displaying (in current chat room) last (let's say) 60 messages. mean retrieving last 60 items of current conversation firebase using limittolast() . furthermore add load more button appear when 60 messages limit has been reached swiping , should load 60. is there proper way of handling message archive stated above? using code below retrieve whole specific message archive. find ineffective when specific chat archive has thousands of messages. mchildeventlistener = new childeventlistener() { @override public void onchildadded(datasnapshot datasnapshot, string s) { chatmessage chatmessage = datasnapshot.getvalue(chatmessage.class); mmessageadapter.add(chatmessage); } @override public void onchildchanged(datasnapshot datasnapshot, string s) { }

javascript - Looping through the text file in typescript -

i have read local file flight.txt 1 dfw bom 2016-05-20 12:20 2016-05-21 02:40 1084.00 jetairways 100 2 dfw del 2016-04-24 17:15 2016-04-25 07:20 1234.00 lufthansa 100 3 dfw fra 2016-06-05 13:30 2016-06-05 03:32 674.00 americanairlines 100 code used read file in typescript. populateflightlist() { let data = fs.readfilesync('flight.txt').tostring('utf-8'); { let textbyline = data.split("\n") console.log(textbyline); }; now want loop , read file , parse data flight objects creating new object in each iteration , adding arraylist. try { scanner fin = new scanner(file); while(fin.hasnext()) { int number = fin.nextint(); //flight numer string = fin.next(); //departure airport string = fin.next(); //arrival airport }**code in java** how do in typescript? you can use readline module read 1 line @ time. parsing data s

c++ - how to convert protobuf repeated message to std::set -

my message defines this message connection { optional string id = 1; ... } message configurations { repeated connection connections = 1; ... } there 2 configurations, , want union\intersection\difference, plan convert repeated message std::set, this: bool comp(const connection &first, const connection &sec) { return first.id() < sec.id(); } std::set <connection, comp> new_set( conf.connections().begin(), conf.connections().end()); but not work, tried other ways, failed. fresh man cpp, think coming stackoverflow more effective way. tips? thanks.

What is the word 'security value' means in AES encryption algorithm? -

Image
i studied lot trying answer these 3 questions, still can't it. in question 1: don't know definition of 'security value' . in question 2&3 : can't see security weaknesses in scheme. the terminology confusing, call value initial vector (iv). point of using random iv if encrypt same message twice, not same ciphertext twice, necessary prevent leaking of information (for example, see happens in ecb mode -- @ penguin images). to second question, general security requirement if attacker supplies number of inputs ( m_i ), should not able figure out other inputs has no control over. understand why, @ padding oracle attacks such poodle . if understand poodle, should able come similar on proposed scheme. here's hint on problems may happen. think case of m_1 = m_2 . c_2 ? i'm not going solve homework you, should point in right direction.