Posts

Showing posts from August, 2010

File does not open in C -

file not show when enter want doesn't give me error. the file is: account name balance 100 jones 24.98 200 doe 345.67 300 white 0.00 400 stone -42.16 500 rich 224.62 int main(void) { int account; char name[30]; float balance; int request; char singleline[150]; file * fpointer; fpointer = fopen("acc.txt","r"); while (!feof(fpointer)) { fgets(singleline, 150, fpointer); } if ((fpointer= fopen("acc.txt", "r"))==null) printf("file not opened\n"); else { printf("enter request\n" "1 - list accounts 0 balances\n" "2 - list accounts credit balances\n" "3 - list accounts debit balances\n" "4 - endof run\n"); scanf("%d", &request); while (request !=4) { fscanf(fpointer,"%d%s...

printing - How to repair whitespace in a Python script? -

so i'm new python , guess i've deleted spaces @ beginning of script don't know where. print("hey, i'm chatmaster! what's full name?") x = input() print(x,"died several years ago.. how did die?") y = input () print (y, "... wow.. that's terrible... how here? soul haunting mainframe??") z = input() if z == "yes": print ("*demon voice* i'll have delete you.") print ("*session has ended. terminated in 5 seconds. type cancel cancel") v = input () if v == "cancel": print ("chatmaster- nice try. you've been overriden.") print ("5") print ("4") print ("3") print ("2") print ("1") if z == "no": print (" don't believe *system shuts down.*") best guess (ps whitespace important): print("hey, i'm chatmaster! what's full name?") x = input() print(x,"died several years a...

html - Dynamic element height to match background cover dimensions -

i'm using following css set cover background image on element: .bg { background: url(images/kitteh1.jpg) no-repeat; background-size: cover; background-position: center; height: 200px; } what right, css-only, way of having element size match of background image, such image first takes 100% width, , takes height necessary fit original aspect ratio? here's playground: http://jsfiddle.net/e5ek812c/ as far know, css never aware of image size. can do, however, set padding-top or padding-bottom image's ratio (height is 56.25% of width here). explanation padding-top , when set percentage, uses element's width reference ( 100% ). unlike height . .a { background-color: #ddd; } .bg { background: url(https://prinzhorn.github.io/skrollr/examples/images/kitteh1.jpg) no-repeat; background-size: cover; background-position: center; padding-top: 56.25%; } .c { background-color: #aaa; } <div class="a"...

Filtering Inner Collection in Entity Framework -

i have teams , each team holding products collection , products holding branches collection. each of above entity having field say: isactive want retrieve teams, products, branches active ( isactive=true). system.data.entity.infrastructure.dbquery<team> query = dbcontext.teams.asnotracking(); query = query.include("products"); query = query.include("products.branches"); //filtering active teams querymod = querymod.where(b => b.isactive == active.value); //filtering active products querymod = querymod.where(b => b.products.where(c => c.isactive == active.value).all(d=>d.isactive==active.value)); //filtering active branches querymod = querymod.where(b => b.products.all(c => c.branches.all(d=>d.isactive == active.value) && c.isactive == active.value)); but looks not working expected. correct form of using statement filter inner groups direction or appreciated!. thanks

amazon s3 - Bash cron job doesn't execute like it does on command line -

i've written bash script executes python script write file directory, sends file amazon s3. when execute script command line executes perfectly, when run cron, file writes directory, never gets sent s3. must doing wrong cron. here bash script: #!/bin/bash #python script exports file home directory python some_script.py #export file created python s3 s3cmd put /home/bitnami/myfile.csv s3://location/to/put/file/myfile.csv like said before, manually executing works fine using ./bash_script.sh . when set cron job, file writes directory, never gets sent s3. my cron job is: 18 * * * * /home/bitnami/bash_script.sh am using cron incorrectly? please help. cron looks ok, path .py file not found. you have add path or home like: location=/home/bitnami/ python $location/some_script.py also s3cmd needs located correctly: /bin/s3cmd alternative might need load user environment first before executing script find username/password/ssh key s3cmd

Can't Install Cordova -

hello can't install cordova npm can me please thank you. 0 info worked if ends ok 1 verbose cli [ 'c:\\program files\\nodejs\\\\node.exe', 1 verbose cli 'c:\\program files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'install', 1 verbose cli '-g', 1 verbose cli 'cordova' ] 2 info using npm@2.5.1 3 info using node@v0.12.0 4 verbose node symlink c:\program files\nodejs\\node.exe 5 silly cache add args [ 'cordova', null ] 6 verbose cache add spec cordova 7 silly cache add parsed spec { raw: 'cordova', 7 silly cache add scope: null, 7 silly cache add name: null, 7 silly cache add rawspec: 'cordova', 7 silly cache add spec: 'c:\\users\\sarahprat\\cordova', 7 silly cache add type: 'local' } 8 silly addlocaltarball shasum (computed) da39a3ee5e6b4b0d3255bfef95601890afd80709 9 verbose addtmptarball c:\users\sarahprat\cordova not in flight; adding 10 verbose addtmptarball va...

templates - Mustache section values are overridden -

how output: <h1>colors</h1> <li><strong>red</strong></li> <li><a href="#green">green</a></li> <li><a href="#blue">blue</a></li> from template: <h1>{{header}}</h1> {{#bug}} {{/bug}} {{#items}} {{#first}} <li><strong>{{name}}</strong></li> {{/first}} {{#link}} <li><a href="{{url}}">{{name}}</a></li> {{/link}} {{/items}} {{#empty}} <p>the list empty.</p> {{/empty}} this data: { "header": "colors", "first": true, "items": [ {"name": "red", "first": true, "url": "#red"}, {"name": "green", "link": true, "url": "#green"}, {"name": "blue", "link": true, "url": "#blue"...

php - Difference between URL::to and URL::route in laravel -

what difference between <a href=" {{ url::route('/account/register') }}" >register 1 </a> and <a href=" {{ url::to('/account/register') }}" >register 2 </a> i defined routes.php route::get('/account/register','registercontroller@create'); when click on 'register 1' got following error route [/account/register] not defined. but when click on 'register 2' ,it goes registercontroller@create url::route gets url named route. in case if name route this: route::get('/account/register', [ 'name' => 'register', 'uses' => 'registercontroller@create' ]); then able use <a href="{{ url::route('register') }}" >register 1</a> in blade templates.

java - totals in a loop do not add up -

so decided skirt around card generator, poster on previous question. have had lot of ideas community , i'm trying not copy paste, , keep work genuine possible. which why problems aren't fixed yet, , others have popped up. that said, when run version, totals don't add properly, think on second hit goes bit haywire. love little more encouragement :) import java.util.random; import java.util.scanner; class blackj { public static void main(string[] args) { random r = new random(); scanner keyboard = new scanner(system.in); string name; boolean playing = true; boolean notplaying = true; int card1 = 1 + r.nextint(11); int card2 = 1 + r.nextint(11); int dcard1 = 1 + r.nextint(11); int dcard2 = 1 + r.nextint(11); int ptotal = card1 +card2; int dtotal = dcard1 +dcard2; { system.out.println("welcome blackjack ! " ); system.out.println("score close 21 without going on win "); ...

python zlib produces a -3 error when inflating data through a Decompress() object -

i have created decoder parse, decompress , extract single file zlib encoded file downloaded through urllib2 file-like object. idea utilize little memory , disk space possible, using reader / writer pattern "decoder" in middle uncompress data coming urllib2, feed cpio subprocess , write file data disk: with closing(builder.open()) reader: open(component, "w+b") writer: decoder = decoder() while true: data = reader.read(10240) if len(data) == 0: break writer.write(decoder.decode(data)) final = decoder.flush() if final not none: writer.write(final) writer.flush() the decoder pretty simple too: class decoder(object): def __init__(self): self.__zcat = zlib.decompressobj() # cpio initialisation def decode(self, data_in): return self.__consume(self.__zcat.decompress(data_in)) def __consume(self, zcat_data_in)...

plsql - Cursor for loop using a selection instead of a table ( oracle ) -

i'm writing procedure fill child table parent table. child table has more fields parent table ( should ). i've conjured cursor wich point selection, wich join of multiple tables. here's code got far : create or replace procedure pop_occ_lezione x lezione%rowtype; cursor cc y as( select codice_corso, nome_modulo, data_inizio_ed_modulo diem, giorno_lezione, ora_inizio_lezione o_i, ora_fine_lezione o_f, anno, id_cdl, nome_sede, locazione_modulo loc lezione join ( select id_cdl, anno, codice_corso corso ) using (codice_corso) join ( select codice_corso, locazione_modulo modulo ) using (codice_corso) join ( select nome_sede, id_cdl cdl ) using (id_cdl) case ...

bash - recursively append variable to result of curl -

i using curl , putting output file. following script prepends string mystring output: #!/bin/bash file=$1 ids=$(head ${file} | awk '{print $1}') in ${ids} curl -ss http://www.uniprot.org/uniprot/$i.fasta -w "mystring" >> test1.txt done which fine , get: $ ./myscript.sh mystring>q12345 mystring>p79403 mystring>q27595 however when trying prepend variable doing: #!/bin/bash file=$1 ids=$(head ${file} | awk '{print $1}') in ${ids} curl -ss http://www.uniprot.org/uniprot/$i.fasta -w "$ids" >> test1.txt done i get: $ ./myscript.sh myvar1>q12345 myvar1 myvar1 myvar1 myvar2>p79403 myvar2 myvar2 myvar2 myvar3>q27595 myvar3 myvar3 myvar3 so kind of works - it's adding lines. how should edit script? curl -ss http://www.uniprot.org/uniprot/$i.fasta -w "$ids" >> test1.txt should presumably be curl -ss "http://www.uniprot.org/uniprot/$i.fasta" -w "$i...

Design suggestion: How to add programmatically add multiple (but indeterminate) 'Views' of the same class in an Android Activity -

i have problem not able solve. an activity in android app needs build object has: a name a description zero or more items, described name, price, , other info i have tried implement functionalities related 'items' in fragment . using fragment made sense me because have been able add logic (various checks on values) in fragment , have lighter activity. built activity edittext name edittext description an imageview '+' adding fragments a linearlayout hosting added fragments i cannot use fragments because not kept during device rotation (i tried restore same views in linearlayout, same ids, not work). how implement such functionality? not find example.

if statement - PHP IF construct when dealing with a part that is an exception -

i'm having trouble getting code work. , lost overview. can give me insight? i'm looking how build if construct. if describe if construct in words: mismatchbundle = true unless (adminpass = true & user = admin) i wrote following code, didn't seem work: if (($mismatchbundle == true) && ($adminpass != true && $thisuser['rankid'] != 1) anyone knows how 'unless' part in code? what this? if (($mismatchbundle == true) && !($adminpass == true && $thisuser['rankid'] == 1) is allowed ! before () section? if (($mismatchbundle == true) && !($adminpass == true && $thisuser['rankid'] == 1) using ! on entire section within ( ) worked intended.

php - Guzzle error on parsing xml with html comment in it -

i'm getting error guzzle. xml has html comment in think breaking it. experience in relation guzzle because @ point try response @ xml error through e.g. $res->xml(). $res alone or $res->getbody() don't seem me. "uncaught exception 'exception' message 'string not parsed xml' in /home/mso/public_html/connector/vendor/guzzlehttp/guzzle/src/message/response.php:168 stack trace: #0 /home/mso/public_html/connector/vendor/guzzlehttp/guzzle/src/message/response.php(168): simplexmlelement->__construct('please use mi...', 2048, false, '', false) #1 /home/mso/public_html/connector/get_dat.php(23): guzzlehttp\message\response->xml() #2 {main} next exception 'guzzlehttp\exception\xmlparseexception' message 'unable parse response body xml: string not parsed xml' in /home/mso/public_html/connector/vendor/guzzlehttp/guzzle/src/message/response.php:174 stack trace: #0 /home/mso/public_html/connector/...

cracking - Can I run multiple instances of aircrack-ng -

if i'm using aircrack-ng on dedicated server fast can run multiple instances of aircrack-ng. split password list , have 2 instances or mess results. thanks in advance. yes, aircrack authors told here : https://forum.aircrack-ng.org/index.php?topic=938.0 ☺ if seek performance, should consider giving handshake hashcat : https://hashcat.net/wiki/doku.php?id=cracking_wpawpa2

Isaac Wasserman: How can look at all of the source code for an iOS app? -

[3/16/15, 7:38:28 pm] isaac wasserman: want make app uses similar mechanics madden mobile. want @ code using xcode, doesn’t seem can read if it’s not project. contains .viv files. you can't code app, app compiled binary. on top of encrypted getting binary difficult. even if stealing unless had explicit permission.

input - Simple data populate data with Kendo UI -

hello i'm quite new kendo ui question simple well. working datasource of kendo ui (javascript) reads simple json object remote source, works fine. struggle populating data single text fields within html page. find example on kendo ui documention talking "template", "model", "columns", "binding", etc. there nothing think can adapt needs. examples find focussed on kendo widgets or "grid", not want. example: read json "datasource" object remote source, looking this: [{"productid":"30","title":"apple"}] in html there 2 input fields, 1 id="productid" , 1 id="title" i don't need precise code solution hint/link how proceed populate json elements value attributes of 2 input fields. if possible there other way possible storing values of input fields datasource , send remote server saving/updating purposes? any hint welcome!

r - Converting a data.frame into a table -

i have data.frame , want change table. has 3 columns: number, study, classes , year. i've slitting different classes (nursery, grammar school, college), producing 9 different dataframes each bellowing different class. in end i've excluded class column maintaining number, study , year. after i've converting each of dataframes, classified classes, table, using: gt <- xtabs(g$number ~ g$study + g$year, g) however, equation continues bring class former information, 1 i've cut down. i've no clue going wrong. are dropped coloumn "class"? try this: grammar <- subset(data, data$class=="grammar", select=c("number", "study", "year") gt <- xtabs(number ~ study + year, grammar)

c++ - Time Short Functions with cpu time using RTEMS operating system -

i looking profile code in real time operating system, rtems . essentially, rtems has bunch of functions read time, useful of rtems_clock_get_ticks_since_boot . the problem here whatever reason clock ticks reported synchronized our state machine loop rate, 5khz whereas processor running @ around 200mhz (embedded system). know because recorded clock time, waited 1 sec , 5000 ticks had gone by. so question is: how can actual cpu ticks rtems? ps. clock() gnu c (has same problem) there guide have been looking here , impossible constraint in asm indicates need use different assembler keywords. maybe can point me similar? context i want profile code, essentially: start = cpu_clock_ticks() //some code time = cpu_clock_ticks() - start; the code runs in less 0.125ms 8khz counter clock() , other rtems functions get, wont cut it. accurate performance measurements can made using oscilloscope, provided there gpio, test point or pin software can write (and os...

jquery - how to set active class when user clicks on a nav-tabs -

i have following markup inside asp.net mvc web application, display 2 tabs, , using bootstrap 2.0.2:- <ul class="nav nav-tabs" id="mytab"> @if(model.hasracks) { <li> @ajax.actionlink("show related racks", "customerrack","customer", new {customerid = model.accountdefinition.org_id}, new ajaxoptions { insertionmode = insertionmode.replace, updatetargetid = "detail" , loadingelementid = "progress", onsuccess="detailsuccess" } ) </li> } @if(model.hasserver) { <li >@ajax.actionlink("show related servers", "customerserver","customer", new {customerid = model.accountdefinition.org_id}, new ajaxoptions { insertionmode = insertionmode.replace, updatetargetid = "detail" , loadingelementid = "progress", onsuccess="detailsuccess", } )</li>}</ul> what try...

jquery - JavaScript Sort to clear a sort that has already been made -

i trying create own sort function table, i'm not allowed use plugin part of university coursework. now i've got javascript mark here sort table nicely: var newdirection = 1; if ($(this).is('.sorted-asc')) { newdirection = -1; } var rows = $table.find('tbody > tr').get(); $.each(rows, function(index, row) { row.sortkey = findsortkey($(row).children('td').eq(column)); }); rows.sort(function(a, b) { if (a.sortkey < b.sortkey) return -newdirection; if (a.sortkey > b.sortkey) return newdirection; return 0; }); the sortkey variables whether sorted alpha or numeric. here change rows in table in correct order: $.each(rows, function (index, row) { $table.children('tbody').append(row); row.sortkey = null; }); now love work out, there way in can reverse sort? don't mean .reverse() reverse order of table rows clear sort , put values way were. i'd make table order default comes back. ...

api - FOSRestBundle post many to one relation -

i know how post data when entity has manytoone relation in fosrestbundle. user entity has locale (locale_id): /** * @orm\manytoone(targetentity="locale") * @orm\joincolumn(name="locale_id", referencedcolumnname="id") */ private $locale; i hoping passing like: { "user":{ "firstname":"john", "emailaddress":"somewhere@somehow.com", "lastname":"doe", "sex":"1", "locale":{ "id":"1" } } } will work, not pass validation , symfony throws: {"code":400,"message":"validation failed","errors":{"children":{"firstname":[],"lastname":[],"emailaddress":[],"sex":[],"locale":{"errors":["this value not valid."]}}}} as can see, locale still wrong. d...

automatic ref counting - Understanding ARC in iOS -

i have block of code have written test arc. set string s2 weak , assign value of s1. then, set s1 nil. assuming since background block executed @ later time, s2 dealloced then. but, when run code, nslog still prints value of s2 "123". can please explain me why happens? - (void)testarc { nsstring *s1 = [nsstring stringwithformat:@"123"]; __weak nsstring *s2 = s1; s1 = nil; dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_low, 0), ^{ // nslog print? nslog(@"s2 = %@", s2); }); } two considerations: you're creating autorelease object isn't released until pool drained. if create non-autorelease object (or use own autorelease pool), won't see behavior, e.g.: nsstring *s1 = [[nsstring alloc] initwithformat:@"123"]; __weak nsstring *s2 = s1; s1 = nil; dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_low, 0), ^{ // nslog print? nslog(@"s2 = %@...

angularjs - How to trim 0 in day but not in month with format(yyyy-dd-mm) in angular/javascript? -

how trim javascript date object. have date format (yyyy-d-m). date value 2015-03-03 , want trim first 0 in days not in months. example: when input: 2015-03-03 returned 2015-3-03 i tried following code it's trim 0 in months. $scope.date = { "start": "2015-01-26", "end": "2015-04-03" }; `var = $scope.date.from.replace(/\b0(?=\d)/g, ''); var = $scope.date.to.replace(/\b0(?=\d)/g, ''); console.log(to); //output 2015-1-26 , 2015-4-3` what should do? if want remove leading 0 day, then: $scope.date.from.replace(/-0(\d)$/,'-$1') will do. there no need lookahead or g flag (since you're replacing 1 instance). edit sorry, should have explained how regular expression , replacement works. in regular expression, -0(\d)$ matches dash, followed zero, followed digit, followed end of string. brackets ( ) capture matched digit in hold space represented in replacement string...

java - Streams Collections.toMap() from List . How to keep the order? -

i creating map list follows : map<string,itemvariant> map = itemext.getvariants() .stream().map((extvar)->{ //convert variant itemvariant itemvar = conversionservice.convert(extvar, itemvariant.class); return itemvar; }).collect(collectors.tomap(itemvariant::getsku, function.<itemvariant>identity())); i want keep same order in list: itemext.getvariants() how create linkedhashmap using these collectors.tomap() functions ? the 2 parameter version of collectors.tomap() following: public static <t, k, u> collector<t, ?, map<k,u>> tomap( function<? super t, ? extends k> keymapper, function<? super t, ? extends u> valuemapper) { return tomap(keymapper, valuemapper, throwingmerger(), hashmap::new); } so can replace: collectors.tomap(itemvariant::getsku, function.<itemvariant>identity()) with: collectors.tomap(itemvariant::getsku, function....

javascript - How to get the starting point of a seeking event in HTML5 Video? -

i find in html5 video when users perform seek action clicking controls, there no way time before seeking. what want whenever users seek video point, system know @ point before users seek. example, if user watching video untill 2:00 , click control @ 4:00, need keep track of time 2:00. have tried seeking , seeked event can't time 2:00. return me time 4:00. there solution? you should able track timeupdate event, short delay : var video = document.queryselector('video'); video.bp = 0; video.addeventlistener('timeupdate', function(e){ var = this; (function(){ settimeout(function(){ that.bp=that.currenttime; }, 500); }).call(that);} ); video.addeventlistener('seeking', function(e){ log('boringpart = '+this.bp+ " gone "+this.currenttime) }) function log(txt){document.queryselector('p').innerhtml = txt;} <video controls="true" autoplay="true" height=...

Assign the value of old column to new column using Django data migration -

i got problem when wanted change column's type int char. could't directly via django migrations. firstly added new column , wanted set value old column's, sql 'update my_app_myqpp set uuid=id'. how can via django migrations? thanks! def migrate_data(apps, schema_editor): myapp = apps.get_model('my_app', 'myapp') db_alias = schema_editor.connection.alias results = myapp.objects.using(db_alias) result in results: result.uuid = str(result.id) result.save() class migration(migrations.migration): dependencies = [ ('myq_app', '0002_auto_20150205_0501'), ] operations = [ migrations.addfield( model_name='myapp', name='uuid', field=api.fields.uuidfield(auto_created=true, default='0', editable=false, max_length=32, unique=true, verbose_name='uuid'), preserve_default=true, ), migra...

r - How add two text objects -

how add sum information 2 texts? example: obj1 <- c("a","e","i","o","u") now, how can have object “ba”, “be”,… “bu”? tried: obj2=c("b"+ obj1) but doesn't work. if in r, obj1 = c("a","e","i","o","u") obj2 = paste("b", obj1,sep='')`

python - Remove an element from list and return the result -

i want generate list looks like: ['ret-120','ret-115','ret-110',....'ret-5','ret5',....'ret240'] please note, there's no ret0 element in list. have remove list populated range function. i've tried: ['ret'+str(x) x in list(range(-120,241,5)).remove(0)] however gives out error: typeerror: 'nonetype' object not iterable is possible accomplish 1 line of code? the simplest way want add conditional inside list comprehension: lst = ['cumret'+str(x) x in xrange(-120,241,5) if x != 0] # part: ^^^^^^^^^ i removed unnecessary list creation , changed range -> xrange (note range -> xrange change python2 only)

java - field.getAnnotations() returns empty array when run on a tomcat server, but returns correct annotation when run as a standalone -

i trying dynamically create , load class in application. class has annotations on 1 of member fields ("id"). can compile , load class easily. can see compiled class in directory, , when open in eclipse, can see member field has annotation. when try read annotation, using field.getannotations(), following things happen: 1) when run application stand alone, can annotation "key". 2) when run application on tomcat server, getannotations() method returns empty list. there no "key" annotation. just note have retentionpolicy.runtime in key class. how can annotation when run on server ? possible things for, resolve issue ? ps : code @override public class<?> createindexclass(indexdefinationdata createindex) { indexdtocreator creator = new indexdtocreator(); indexgenerationresult result = creator.process(createindex); // creates source file class<?> clazz = (activateindexclass(result)); //compiles , loads class...

html - How to inline 'skewed' li's with no margin between -

i need placing 4 inline li's in div, but, li's need 'horizontally skewed'. need do: (sorry link stack won't let me place pictures) https://www.flickr.com/photos/107597387@n08/ i can't use css transform -skew tool because skew content inside element (there's image each one), , cut first , last box. i tried use polygon clip-path, cant manage clear space between boxes. html: <div id="somediv" class="colors"> <ul> <li id="c1" class="color">color1</li> <li id="c2" class="color">color2</li> <li id="c3" class="color">color3</li> <li id="c4" class="color">color4</li> </ul> </div css: .colors ul li{ display: inline-block; list-style: none; float: left; width: 25%; height: auto; margin-right: 0; padding-top: 5%; padding-bottom: 5%; cursor: point...

Any way to better structure many if else statements in Java -

here code have tax program.is there better way structure if else statements , there better way write program. apologize before hand not having comments. package joptionpane; import javax.swing.joptionpane; public class main { public static void main(string[] args) { double paycheck = double.parsedouble(joptionpane.showinputdialog("how paycheck?")); string[] options = new string[] {"yes", "no"}; int response = joptionpane.showoptiondialog(null, "are married?", "title", joptionpane.default_option, joptionpane.plain_message, null, options, options[0]); double deductions = integer.parseint(joptionpane.showinputdialog("how many deductions did claim?")); string[] payoften = new string[] {"weekly", "biweekly"}; int variability = joptionpane.showoptiondialog(null, "how paid?", "title", ...

opengl - Cost of Branching on uniforms on modern GPUs -

when using glsl on modern (gl3.3+) gpus, cost of branching on uniform? in engine i'm getting point have lot of shaders. , have several different quality presets lot of those. stands, i'm using uniforms if() in shaders choose different quality presets. i'm worried might achieve better performance recompiling shaders , using #ifdef. problem need worry tracking , resetting other uniforms when recompile shader. basically want know if fears unfounded. branching on uniform cheap on modern gpus? have done few tests myself , found little difference either way, i've tested on nvidia 680. i admit i'm not expert, perhaps speculation better nothing. i think branching on uniforms indeed cheap. it's different branching on texture or attribute data, since alus in simd follow same code path shader, "real" branch rather execution mask. i'm not sure how shader processors suffer branch bubbles in pipeline, pipeline bound more shallow in general-pur...

Excel : Split multi line text into multi line columnbvn -

i have huge data follows : row a1 : 1234 row a2 : jsdfh row a3 : dfjkgldhlf row a4 : 3448734kjfj row a5 : dfjgkldjfgkl row a7 : dfjklg;dfl row a8 : dfkgjdf;klg can break data single formula or not : column a1 : 1234 column b1 : jsdfh column c1 : dfjkgldhlf column a2 : 3448734kjfj column b2 : dfjgkldjfgkl column a3 : dfjklg;dfl column b3 : dfkgjdf;klg if want without coding, copy data in row, select empty column cell > right click > select 'paste special'> check 'transpose'> ok.

Looping of dates Javascript -

i looping inside date. below snippet sample of code i've done far. works fine except when loop start. var = new date(2015, 0, 1); var = new date(2015, 0, 10); while(from < to) { = new date(from.setdate(from.getdate()+1)); console.log(from.getdate()); } //output: 2, 3, 4, 5, 6, 7, 8, 9, 10 as can see loop start @ number 2 . want start @ 1 because date declared var = new date(2015, 0, 1); . want output 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 . happen code? why starts @ 2 ? fiddle link is: http://jsfiddle.net/grky1lwz/ you need use value before incrementing it var = new date(2015, 0, 1); var = new date(2015, 0, 10); while (from <= to) { console.log(from.getdate()); //this should last in loop //from = new date(from.setdate(from.getdate() + 1)); from.setdate(from.getdate() + 1) } demo: fiddle

javascript - elemMatch search on array of subdocument -

how search using elemmatch on array of subdocument? have document called reportcollection elements such as:- /* 0 */ { "_id" : objectid("5507bfc435e9470c9aaaa2ac"), "owner" : objectid("5507bfc31e14d78e177ceebd"), "reports" : { "xreport" : [ { "name" : "xreport", "parameters" : { "x" : { "datetime" : "2015-03-11t18:30:00.000z", "unit" : 1, "value" : 102 } }, "createdby" : objectid("5507bfc31e14d78e177ceebd"), "modifiedby" : objectid("5507bfc31e14d78e177ceebd"), "_id" : objectid("5507bfc41e14d78e177ceebf") } ] } } i got rep...

c# - WinForms passing data between Forms -

i have table named questions field name qcategory . in wfa have toolstripmenu have category named simulation , sub-category named b . so, want create mysql select select rows values equal sub-category value. (columns qcategory table has value b ). string: static string dataa = "select distinct * questions order rand() limit 1"; the problem have 2 forms. 1 menu , 1 want make select. you should try split ui-code , database code. called layering (mvvm, mvc, mvp,...) don't have to! there several ways: 1) make class both forms can reference , execute database logic there. (that cleanest way now) 2) create event in form menu , react on in other form 3) menu form holds reference other form , executes method on passing selected subitem. in code 1 public static class sqlclass { public static void executequery(string menuitem) { //execute query } } form 1 //menu changed... sqlclass.executequery(menuitem) 2 form1: public ev...

java - WARNING: No mapping found for HTTP request with URI [/Spring3MVC/hello.html] in DispatcherServlet with name 'spring' -

this question has answer here: why spring mvc respond 404 , report “no mapping found http request uri […] in dispatcherservlet”? 3 answers why happening. "warning: no mapping found http request uri [/spring3mvc/hello.html] in dispatcherservlet name 'spring' " my web.xml is <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="webapp_id" version="2.5"> <display-name>spring3mvc</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> ...

update json object in c# -

i have json object like { "name" : "sai", "age" : 22, "salary" : 25000} i want update json object by `{ "name" : "sai", "age" : 23, "gender" : "male"}` then want result { "name" : "sai", "age" : 23, "salary" : 25000, "gender" : "male"} i tried like foreach(var item in actualjson) { bool isfound = false; foreach(var newitem in newjson) { if(item == newitem) // returns false, wrong this? { isfound = true; break; } } if(!isfound) { // add json } } i not getting idea solve this? any help/guidance appreciated. with json.net can this: var json1 = "{ \"name\" : \"sai\", \"age\" : 22, \"salary\" : 25000}"; var json2 = "{ \"name\" : \"sai\", \"age\" : 23, \"gender\" : \"male\"}"; ...

How to enable billing for Google cloud storage free quota -

i m new android app developer, m still trying out different google cloud apis.google provides free quota cloud storage n datastore, why force enable billing free quota cloud storage? why have have account never pay, since m trying apis free quota. dont have international debit/credit card, not easy 1 here, how try cloud storage ( create/edit,delete bucket/object)? there public bucket or object can try testing app? credit/debit cards used purpose of verification , donot want encourage users randomly create accounts how possible in case of gmail service(since cloud platform services costs more) .there no other way out , 1 gotto register debit/credit cards access , same in case of amazon aws services .

angularjs - Adding Tags work on create page, but wont work on edit page angular -

i'm trying build app meanjs of uses angular. idea user able add tags , delete tags post. add , deleting works great on create page once try add or delete on edit post page doesn't work anymore. below html <section data-ng-controller="productscontroller" data-ng-init="findone()"> <div class="page-header"> <h1>edit product</h1> </div> <div class="col-md-12"> <form class="form-horizontal" data-ng-submit="update()" novalidate> <fieldset> <div class="form-group"> <div class="controls"> <label class="control-label" for="name">name</label> <input type="text" data-ng-model="product.name" id="name" class="form-control" placeholder="name" required> <div cla...

jquery - Unable to hide the non-selected options from a multiple select using Chosen plugin -

i using chosen plug in multiple select box. trying display selected values not able required result. <select data-placeholder="add names" name="names[]" id="inv" multiple class="chosen-select" > <?php $checked_names=array(); foreach($names_details $row) { $checked_names[] = $row->names_id; } ?> <?php foreach($names $row) { ?> <option id="invitees_id[]" value="<?php echo $row->id?>" <?php echo (in_array($row->id, $checked_names ) ? 'selected="selected"': set_select('names[]', $row->id)); ?> > <?php echo $row->firstname." ".$row->lastname;?> </option> <?php } ?> </select> this i've tried in js: 1) $('.chosen-select').chosen(); $("#inv").chosen({ display_disabled_options: true }); 2) $("#inv...

python - Difference between stack/unstack, shape and pivot in Pandas -

i pretty new python , starting read on big data analysis using pandas. i given task of getting following table long form tall form pick 'n pay woolworths spar checkers friendly 7 0 22.222222 11.111111 44.444444 nan nan 1 8.333333 5.555556 8.333333 11.111111 33.333333 2 8.982036 7.185629 11.976048 35.928144 nan 3 12.500000 37.500000 37.500000 12.500000 nan my initial thoughts should use reshaping, settled on using df.stack() . this brought question forefront of mind: difference between stacking/unstacking, reshaping , pivoting? situation should each used in?

How to get parent of a node with some specific value in xml using lxml python -

i new xml, , have problem in parsing it. have following xml: <bookstore> <book> <name>abc</name> <price>30</price> </book> <book> <name>learning xml</name> <price>56</price> </book> <book> <name>learning java</name> <price>340</price> </book> <book> <name>learning python</name> <price>560</price> </book> </bookstore> i want name of book price 30. how using lml python you can use following xpath select <name> element of <book> <price> equals 30 : //book[price=30]/name python example : from lxml import etree tree = etree.parse('path_to_your_xml.xml') result = tree.xpath('//book[price=30]/name')[0] print result.text #above printed abc

android - Navigation drawer bottom item -

i have implemented navigation drawer here material drawer https://github.com/kanytu/android-material-drawer-template my problem want add logout @ end of navigation drawer list. here xml drawer: <mynews.volume.com.mynews.materialnavigation.scriminsetsframelayout android:id="@+id/scriminsetsframelayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitssystemwindows="true" app:insetforeground="#99000000" android:elevation="10dp" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> </mynews.volume.com.mynews.materialnavigation.scriminsetsframelayout> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <include android:id="@+id/...

java - hdfs command is deprecated in hadoop -

as following below procedure: http://www.codeproject.com/articles/757934/apache-hadoop-for-windows-platform https://www.youtube.com/watch?v=vhxwig96dme . while executing command c :/hadoop-2.3.0/bin/hadoop namenode -format , got error message given below **deprecated:use of script execute hdfs command deprecated. instead use hdfs command it. exception in thread "main" java.lang.noclassdeffounterror** i using jdk-6-windows-amd64.exe . how solve issue ? use cmd c:/hadoop-2.3.0/bin/hdfs replace c:/hadoop-2.3.0/bin/hadoop a lot of hdfs cmds recommended run bin/hdfs not bin/hadoop

jquery - How to add html <br> tags into javascript -

i have button when clicked opens email , fills body variables. looks messy though appears on 1 line. chuck in br tag inbetween each variable appear on new line? thanks. here code: $("#buttonlink").click (function() { window.open('mailto:sales@beauxcadeaux.co.uk?subject=my frame&body=my frame type: ' + frametype + ' frame background: ' + framebackground + ' text: ' + yourtext + ' text design: ' + textdesign); }); i'm thinking like: $("#buttonlink").click (function() { window.open('mailto:sales@beauxcadeaux.co.uk?subject=my frame&body=my frame type: ' + frametype + <br> + ' frame background: ' + framebackground + <br> + ' text: ' + yourtext + <br> +' text design: ' + textdesign); }); use ascii code %0d%0a , this: window.open('mailto:sales@beauxcadeaux.co.uk?subject=my frame&body=my frame type: ' + frametype...

multithreading - How to run a delayed or scheduled task in Java provided you have a thread? -

suppose have thread thread pool. how execute delated/scheduled task (runnable or callable) in thread? don't use thread directly that. use, instance, scheduledexecutorservice . the executors class want create one.

android - Resources$NotFoundException: Resource is not a Drawable (color or path)? -

i have textview, when clicked, populating listview inside dialog. code used work fine, today throwing exception. this code: tvselectedfont = (textview)findviewbyid(r.id.lblquoteselectedfont); tvselectedfont.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { listview listview = new listview(context); listview.setadapter(new arrayadapter<string>(context, android.r.layout.simple_list_item_1, new string[] {"default", "serif", "monospace"})); final dialog dialog = new dialog(context); dialog.setcontentview(listview); dialog.settitle(r.string.txt_settings_quotefontname); listview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { string sel...

javascript - JSONPath exclude as separate JSON -

i have complex json structure . wan't exclude part , list in 2 buckets. 1 "inclusions" , "exclusions". sample json given below. { "item": { "items": [{ "items": [{ "category": "fruit", "item": { "items": [{ "text": "apple" }, { "text": "orange" }, { "text": "grapes" }, { "text": "guava" }], "types": ["value", "value", "value", "value"] }, "type": "or" }, { "category": "fr...