Posts

Showing posts from January, 2015

regex - Grep with ruby the gemlist -

i'm trying grep gem list. list with bundlelist = `bundle show` result "gems included bundle:\n * cfpropertylist (2.3.1)\n * abstract_type (0.0.7)\n * actionmailer (4.2.3)\n * actionpack (4.2.3)\n" i like: => ["cfpropertylist", "abstract_type", "actionmailer", "actionpack"] when try grep on it, bundlelist.scan(/\*.*\(/) . result is: => ["* cfpropertylist (", "* abstract_type (", "* actionmailer (", "* actionpack ("] use lookbehind , lookahead instead: /(?<=\* ).*?(?= \()/ what means minimum thing preceded star + space , followed space + opening bracket .

java - XPath contains returning IndexOutOfBounds Exception -

i new xpath. following piece of code checking ? check both these class "a b" when retrieving span elements. htmlspan resultsspan = (htmlspan) page.getbyxpath("//span[contains(@class,'a b')]").get(0); thanks this xpath //span[contains(@class,'a b')]" looks span class contains substring "a b". f.e. <span class="ba ba"></span> or <span class="a b"></span> if want span class "a" or class "b" should use //span[@class="a" or @class="b")]

c# - Displaying typed characters on new line -

may funny question, newbie in c# class program { static void main(string[] args) { int a; = convert.toint32(console.readline()); console.writeline(a); console.readkey(); } } i expected after typing character, these character written on new line in console, though these printed on 1 line. wrong? p.s. console.writeline("asd"); console.writeline("dsa"); this displayed expected: asd dsa every call of console.writeline() method prints new line. example take input , print input single time. you try instead: class program { static void main(string[] args) { int a; while(true) { = convert.toint32(console.readline()); console.writeline(a); } } } edit: included version uses char , console.read() seems more appropriate class program { static void main(string[] args) { char a; while(true) { = (cha...

SQL Server 2008 - Add to string in particular position within name column -

i have been asked job beyond sql skills little , having done research online, cannot quite find write solution done in sql server 2008 , not mysql. i have table need update specific names adding additional string after point whilst keeping rest of string right intact. e.g. current name = 'name - location - 0005' new name = 'name (west) - location - 0005' as can see need add text (west), have table lists codes (e.g. 0005) , need link clause update relevant names. so questions are: 1 - how can update name adding additional text @ set location (5th character), whilst maintaining whatever text right of names 2 - there way can sort of in check code, tried using contains table not full-text indexed. not massive issue can manually create update statement using each row within table, nice know add knowledge base. with of stuff can achieve this stuff ( character_expression , start , length , replacewith_expression ) select stuff('name - location ...

python - Subplots grid, legend outside, savefig does not work -

i have same problem guy here , want put legend outside plot, savefig not work. additionally, working subplots environment. let me phrase problem here general possible: fig, axarr = plt.subplots(n,m) #... (plotting)... axarr[k,l].legend(loc=(x,y)) # x , y such outside of plot plt.savefig("test.pdf") by way, me keyword 'bbox_inches' not work. you can try may work lgd = axarr[k,l].legend(loc=(x,y)) # x , y such outside of plot plt.savefig("test.pdf", bbox_inches='tight', bbox_extra_artists=(lgd,))

How to change image tracking with Git? -

in git repository i've got quite lot of images (changing other vcs git out of question). part of images, duplicates different size, these created imagemagick. time time, have regenerate images, ok, however, though image didn't change [size same etc] git marks file modified. assume because of last modified dates, right? there chance, change way git tracks changes of images? there anyway add imagemagick's compare functionality? thanks, krystian edited i wrong, git avoid checking file content , prefer using faster methods described in related post: how git detect file has been modified? if files not modified, i'm not sure if understand well, maybe using git update-index --assume-unchanged might help. however not mean files not modified when re-run generation step, , should check git diff or follow advices of post how can diff binary files in git? but think problem not lie git , better review work-flow. can see 2 options: either not re-generate ...

algorithm - Word breaking in python doesn't work -

i have string list of words. want keywords in list exists in string. doesn't work more 1 keyword ks = ['voices', 'home'] def find_tag(long_string, size, result): idx, s in enumerate(range(0, size + 1)): prefix = long_string[0:idx + 1] if prefix in ks: if idx + 1 == size: result += prefix print(result) find_tag(long_string[idx: size - idx], size - idx, result + prefix + ' ') find_tag('voices', len('voices'), '') text = 'voicesandhome' find_tag(text, len(text), '') the sample input string 'iliveinlondonandiusedtogotonewyork' given dictionary ['london', 'new york'] output london , new york a few comments code: for idx, s in enumerate(range(0, size + 1)): does not make sense, because enumerate(range(0,k+1)) yield (0,0) , (1,1) , ..., (k,k) (why having same value in idx , s ? your code appe...

android - How to get Test and Production values for Fabric crashlytics? -

Image
i used plugin install crashlytics both ios , android applications. 1 difference noticed comes on portal fabric provides. ios there 2 environments, 1 test (green icon) , other production (normal icon). android not this. i attempted create 2 different environments adding following in application class fabric.with(this, new crashlytics()); if (constants.debug) { crashlytics.setstring("version", "production"); } else { crashlytics.setstring("version", "test"); } i thought create 2 different version did not anything. how create multiple environments android? in advance there no difference between release , debug other signature in android. don't think separate products there. did is, i've 2 flavors, 1 dev , other 1 main flavor goes google play. dev flavor has different package name, creates 2 different products in fabric itself, don't need if separate them package names.

Filter ArrayList<Object> based on based between two intervals android -

in arraylist, how can 1 filtered arraylist rows between 2 dates. for example, find students in arraylist october december 2015. new student ("12/05/2015",john, level2); new student ("13/05/2015",bisnet, level2); new student ("5/05/2015",tube, level2); new student ("7/05/2015",eros, level2); new student ("4/05/2015",mackay, level2); new student ("8/05/2015",walnet, level2); here working. if date between start , ending date. must display true else false public boolean systemdate(date startdate, date enddate, string exps) { simpledateformat sdf = new simpledateformat("yyyy-mm-dd"); date expenselsdate=null; try { expenselsdate = sdf.parse(exps.substring(0,10)); } catch (parseexception e) {} // date expenselsdate = datefortmat(exps); //simpledateformat dateformat = new simpledateformat("dd-mmm-yyyy");//dd-mmm-yyyy hh:mm:ss aa ...

javascript - HTML content underneath WebGL animation not clickable -

i trying figure out why html content underneath webgl animation cannot clicked or interact with. please see example . currently div containing animation set to: .webgl-glitch { position: absolute; z-index: 2; overflow: hidden; opacity: 0.5; } ..otherwise not display @ all. i have tried setting z-index: 1; property on header/container div, not seem help. here html section of header including animation div: <!-- begin header animation --> <div class="webgl-glitch"></div> <!-- end header animation --> <header id="principalheader" class="centercontainer aligncenter fullscreen tintbackground stonebackground" style="z-index:1"> <div> <div class="container"> <!-- site logo--> <a href="#" class="logo"><img alt="kubo" src="img/logo.png"></a> <!-- site prin...

python - What is the best way to handle datetime value overflow -

i attempting build program handle alerts. want able handle specific dates 8/23/2015 7:00 , relative dates 5 days , 7 hours now. specific dates fine relative dates if try , add 5 days , 7 hours date time can overflow values intended spot import datetime dt = datetime.datetime.now() dayslater = 5 hourslater = 7 minuteslater = 30 alarmtime = datetime.datetime(dt.year, dt.month, dt.day + dayslater, dt.hour + hourslater, dt.minute + minuteslater, 0,0) this fine if dayslater 40 days overflow value. did set simple if hours >= 24: hours -= 24 days++ however won't work overflowing months length in days isn't consistent. use datetime.timedelta() object , leave calculations datetime library: import datetime delta = datetime.timedelta(days=dayslater, hours=hourslater, minutes=minuteslater) alarmtime = datetime.datetime.now() + delta demo: >>> import datetime >>> dt = dat...

php - ACF file download not working, added screenshots -

Image
i trying use acf add files able download. , using following code: <?php if( get_field('jesmond_breakfast') ):?> <a href="<?php the_field('jesmond_breakfast'); ?>" target="_blank"><strong>brochure</strong></a> <?php endif;?> then have set in acf. but reason, having no luck. can see issue? <?php if( get_field('jesmond_breakfast') ):?> <a href="<?php the_field('jesmond_breakfast'); ?>" target="_blank"><strong>brochure</strong></a> <?php endif;?> instead of can store in variable after given in <?php if( get_field('jesmond_breakfast') ): $link= the_field('jesmond_breakfast');?> <a href="<?php echo $link; ?>" target="_blank"><strong>brochure</strong></a> <?php endif;?>

javascript - How can I make a list of show/hide sections? -

for website, i'm making list of show/hide links (java script , css), , want each 1 different. however, when try that, show/hide links after first 1 don't work. help? suggestions? thanks! function showhide(shid) { if (document.getelementbyid(shid)) { if (document.getelementbyid(shid+'-show').style.display != 'none') { document.getelementbyid(shid+'-show').style.display = 'none'; document.getelementbyid(shid).style.display = 'block'; } else { document.getelementbyid(shid+'-show').style.display = 'inline'; document.getelementbyid(shid).style.display = 'none'; } } } .more { display: none; a.showlink, a.hidelink { text-decoration: none; color: #36f; padding-left: 8px; background: transparent url(down.gif) no-repeat left; } a.hidelink { background: transparent url(up.gif) no-repea...

express - Capturing the source or line number of uncaught exception in node.js -

i've node.js express app running in iis. found app crashing due uncaught exception. hence used process.on('uncaughtexception') restart service in case of uncaught exception. i'm able error "econnreset" i'm unable happened. there way capture error source or line number caused exception? use process.on('uncaughtexception'… event provides error object contains call stack process.on('uncaughtexception', function(err){ console.error(err.stack); process.exit(); });

php - Including and excluding globbing patterns in bash -

i trying use phpcompatibility standard php codesniffer test specific set of files. i'm using find this. find ./path1 ./path2 ./path3 ./path4 \ -type f \ -name '*.php' \ -not -path './path4/dontwantthis/*' \ -exec ./vendor/bin/phpcs \ --standard=phpcompatibility --runtime-set testversion 5.6 {} \; however, slow , inefficient because startup script runs every single file. the phpcs script takes in path ./vendor/bin/phpcs --standard=phpcompatibility --runtime-set testversion 5.6 <path-of-your-php-files> , i'd find way replicate find stuff globbing pattern in place of <path-of-your-php-files> one of major problems havi...

angularjs - Angular nested resources data -

i have following code: //routes .state('app.parent', { url: '/parent', templateurl: 'parent.html', controller: 'parentctrl' }) .state('app.parent.child', { url: '/child', controller: 'childctrl', templateurl: 'child.html', }) //controllers .controller('parentctrl', ['$scope', 'someresource', function ($scope, someresource) { $scope.resources = []; someresource.query({}, function(data) { $scope.resources = data; }); }]) .controller('childctrl', ['$scope', 'otherresource', function ($scope, otherresource) { $scope.other = {}; ... }]) <!-- viewss --> <!-- parent.html --> ... <div ui-view> <table class="table table-hover table-striped"> <tbody> <tr ng-repeat="resource in resources"> ... </tr> </tbody> <...

c++ - Why allow function declarations inside function bodies -

why syntax allow function declarations inside function bodies? it create lot of questions here on function declarations mistaken variable initializations , like. a object(); not mention vexing parse. is there use-case not achieved more common scope hiding means namespaces , members? is historical reasons? addendum: if historical reasons, inherited c limit scope, problem banning them? whilst many c++ applications written solely in c++ code, there lot of code mixture of c , c++ code. mixture of c++'s important part of usefulness (including "easy" interfacing existing api's, opengl or curl custom hardware drivers written in c, can pretty used directly little effort, trying interface custom hardware c driver basic interpreter pretty diffcult) if start breaking compatibility removing things "for no particular value", c++ no longer useful. aside giving better error messages in condition confusing, of course useful in itself, it's har...

c# - Why create Nlog Logger for every class -

is there other benefit besides being able filter class later? i'm thinking creating static method in class have 1 instance of logger classes avoid having call logger = logmanager.getcurrentclasslogger for every class. there no benefits other ability configure , filter log class name. if not rely on having ability, having 1 logger classes valid choice.

Installing Magento security patch SUPEE 6285 - v 1.9.0.1 -

i trying install supee 6285 on magento v 1.9.0.1 we not have ssh our server. when try method 1 found on magecomp.com/blog/how-to-install-magento-security-patches/ blank page when run patch on browser. after looking @ faqs see should have install.php file under app/code/core/mage/install/controller/router/install.php don't have router directory. any advise on how install patch? first solution (recommended): use magento connect , upgrade store latest magento version check upgrades . latest version contains security patch (supee 6285) , features together. second solution (install patch manually): download supee 6285 - v 1.9.0.1_ v2 use ftp client upload specific patch root of magento folder. create php file called applypatch.php run patch you. upload root of magento folder. make sure use right patch name here. <?php print("<pre>"); passthru("/bin/bash patch_supee-6285_ce_1.9.0.1_v2.sh"); print("</pre>"); ?...

javascript - slice on array U32 on chrome -

im using library "zen photon garden" , have problem (if resize canvas) on chrome: "uncaught typeerror: this.z32.slice not function rayworker-asm.js:461" this.u32.set(this.z32.slice(0, l >> 2), begin >> 2); i discovered slice, in case, supported firefox, how can fix it? this.heap = new arraybuffer(0x800000); this.f32 = new float32array(this.heap); this.u32 = new uint32array(this.heap); this.zeroes = new arraybuffer(0x10000); this.z32 = new uint32array(this.zeroes);

triggers - Store Mysql CASE select statement result in a variable -

i have following mysql trigger: create trigger `upd_interim_final` after insert on `oee_main_interim` each row insert `oee_main_interim_final` (id,name,ts,left_io,left_nio,recovery,right_io,right_nio,runmode,s_type,shift,std,curr_s_type) values(null, new.name, new.ts, new.left_io, new.left_nio, new.recovery, new.right_io, new.right_nio, new.runmode, new.s_type, ( select (case when ((curtime() > oee_machinenames.shift1) , (curtime() < oee_machinenames.shift2)) 'shift1' when ((curtime() > oee_machinenames.shift2) , (curtime() < oee_machinenames.shift3)) 'shift2' when ((curtime() > oee_machinenames.shift3) or (curtime() < oee_machinenames.shift1)) 'shift3' end) curr_shift oee_machinenames oee_machinenames.id = new.name group oee_machinenames.id), (select `std` `oee_variant` `machine_id` = new.name , `s_type` = (select `s_type` `v_getmaxid` `name` = new.name , v_getmaxid.max_id in...

python - How to make a function accept runtime arguments -

i want define function such want accept command line arguments below code def tc1(resloc): uiautomator import device; 'do activity' open(resloc, 'a') text_file: text_file.write('tc1 passed \n') text_file.close() else: open(resloc, 'a') text_file: text_file.write('tc1 failed \n') text_file.close() if __name__ == '__main__': tc1("c:\\<pathtoautomation>\\results\results.txt") now when execute same using command line python continues refer path mentioned here tc1("c:\\<pathtoautomation>\\results\results.txt") , doesn't consider pass in runtime command line \scripts>python.exe trail.py c:\\<pathtoautomationresults>\\results\results.txt what looking sys.argv the list of command line arguments passed python script. argv[0] script name (it operating system dependent whether full pathname or ...

scala - Why should calling a currying function with non-complete args with underscore -

according scalabyexample: a curried function definition def f (args1) ... (argsn) = e n > 1 expands to def f (args1) ... (argsn−1) = { def g (argsn) = e ; g } or, shorter, using anonymous function: def f (args1) ... (argsn−1) = ( argsn ) => e uncurried version: def f(x: int): int => int = { y: int => x * y } //> f: (x: int)int => int def f1 = f(10) //> f1: => int => int f1(5) curried version: def g(x: int)(y: int) = { x * y } //> g: (x: int)(y: int)int def g1 = g(10) _ //> g1: => int => int g1(5) the question is, why curried required underscore in line #5 in second code snippet. you can find explanation @ martin odersky book: http://www.artima.com/pins1ed/functions-and-closures.html (search "why trailing underscore"). in sho...

node.js - npm brunch stop functioning on ubuntu 12.04, 14.04, 14.10 -

i have been using brunch more 1 year in application, yesterday has been observed has stopped functioning. getting error in return attempt run command "brunch watch" no command 'brunch' found, did mean: command 'crunch' package 'crunch' (universe) command 'branch' package 'rheolef' (universe) brunch: command not found so, tried install brunch again command sudo npm install -g brunch resulted in error: npm warn optional dep failed, continuing fsevents@0.3.7 npm err! error: failed fetch registry: https://registry.npmjs.org/ansi-color npm err! @ regclient.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:159:18) npm err! @ cb (/usr/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:57:9) npm err! @ regclient.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:137:16) npm err! @ cb (/usr/lib/node_modules/npm/node_mod...

python - Install PyYAML on linux (centos 7) to for Python3.3 -

i have python2.6 , python3.3 on machine centos 7. installed pyyaml using "yum install pyyaml", can import yaml in python2.6, not working in python3.3. idea how fix this? want able use pyyaml in python3.3 on centos 7. thanks! just install using pip: pip3 install pyyaml

r - How to add two titles for a wrapped legend in ggplo2? -

Image
i add 1 title per row in wrapped legend of ggplot2 chart. something this: the code i'm using generate legend: library(ggplot2) df <- data.frame(x=letters[1:6], y=rnorm(6, mean=10, sd=1)) p <- ggplot(df, aes(x=x, y=y, fill=x)) + geom_bar(stat="identity") + scale_fill_manual( values=c('#a6cee3','#1f78b4','#b2df8a','#33a02c','#a94774','#941751','#ffd479','#bead01'), name="", labels=c("1", "2", "3", "4", '5', '6', '7', '8'), guide=guide_legend(nrow=2, byrow=t, title='') ) + theme(legend.position='bottom') p thanks! add theme(legend.position='bottom') move legend bottom. use guide_legend(nrow=2, byrow=t, title='row 1\nrow 2' make legend wrap 2 lines , add "row 1" on top followed "row 2" underneath. ...

multithreading - Spring Batch thread-safe ItemReader (process indicator pattern) -

i'm implemented remote chunking using amqp (rabbitmq). need run parallel jobs within web container. my simple controller ( testjob use remote chunking): @controller public class jobcontroller { @autowired private joblauncher joblauncher; @autowired private job testjob; @requestmapping("/job/test") public void test() { jobparametersbuilder jobparametersbuilder = new jobparametersbuilder(); jobparametersbuilder.adddate("date",new date()); try { joblauncher.run(personjob,jobparametersbuilder.tojobparameters()); } catch (jobexecutionalreadyrunningexception | jobrestartexception | jobparametersinvalidexception | jobinstancealreadycompleteexception e) { e.printstacktrace(); } } } testjob reads data filesystem (master chunk) , send remote chunk (slave chunk). problem itemreader not thread safe. there practical limitations of using multi-threaded steps com...

Test if the first character is a number using awk -

how check if first character of string number using awk. have tried below keep getting syntax error. awk ' { if (substr($1,1,1) == [0-9] ) print $0 }' da.txt i suggest use @hek2mgl solution. have pointed out of problems. problems: you should use regex inside /..regex../ . use ~ instead of == . valid: awk '{ if (substr($1,1,1) ~ /^[0-9]/ ) print $0 }' file.txt

python - Using a break statement in a loop -

write program uses while loop repeatedly prompt user numbers , adds numbers running total. when blank line entered, program should print average of numbers entered. you need use break statement exit while loop . here have gotten far: number_of_entries = int(input('please enter number of numbers: ')) entries = [] count = 0 while count < number_of_entries: entry = float(input('entry:')) entries.append(entry) count = count + 1 average = sum(entries)/number_of_entries print(average) this first prompts user enter number of numbers prompts them entries while loop continues prompting numbers until count of numbers equals number of numbers user inputted. entries saved list , sum of numbers in list used average stored in average variable. if user doesn't input (just press enter) supposed find average of numbers inputted rather result in error code. know have use break statement can't figure out. break if user presses enter or cast , append...

Why CASE statement in Where clause for MS Sql server -

doing performance tuning on 3rd party vendor system in ms sql server 2012. they lot of clauses this: where ( case when @searchid = '' 1 when ((c.sapcustomernumber = @searchid ) or (c.sapcustomernumber = @sapid)) 1 else 0 end = 1 ) other confusing query plan, advantage if there case 1 or 0 in clause? thanks the common, far, cause sort of code appear new sql, case expressions or both. somehow become fixated on case , decide should used conditional evaluations. this mistake , can replaced simpler boolean logical, @bogdan suggested in comments: ((c.sapcustomernumber = @searchid ) or (c.sapcustomernumber = @sapid) or (@searchid = '' )) the second reason can done if attempting enforce order of evaluation of predicates 1 . case documented evaluate when conditions in order (provided scalar expressions, not aggregates). i'd not recommend writes code though - it's mistaken first form instead. , if ...

c# - Issue with changing Gridview cell color depending on condition -

Image
i trying change cell color of gridview, if dot < today's date. issue changes red rows dot column though dot column > today's date. here code protected void onrowdatabound_gvtest(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { label lbldot = (label)e.row.findcontrol("dot"); datetime dotdate = datetime.parse(lbldot.text); if (dotdate < datetime.now) { //e.row.backcolor = system.drawing.color.red; gvdriverstatus.columns[3].itemstyle.forecolor = system.drawing.color.red; } } } this: gvdriverstatus.columns[3].itemstyle.forecolor = ... will change color of whole column. change cell color, use: e.row.cells[3].forecolor = ...

indexing - sqlite INDEXED BY with same plan is slower -

so have 2 queries, 1 specifies indexed each table in query, , specifies one. explain query plan output both identical minus indexed addition in 1 plan. issue specified query runs slower, why be? in situations when data in db going change on time , can't run analyze (should run periodically?) locking indexes down indexed seems prudent idea if test well. thoughts?

sqlite3 - How do I add range to one of my query requirments? -

i have 2 tables. first has series of data 3 columns [z, s, c] call tblbaseline. second table has same structure [z,s,c] call tbldatalog. want find records in tblbaseline match tbldatalog using column s , similar in tbldatalog not identical. can pull matching records based on column s, how additionally filter column c given want record tblbaseline plus or minus 5 of corresponding record in tbldatalog. this code gives me matching records based on column s , c: select baseline.count baseline left join data_log baseline.sample=data_log.sample , baseline.count=data_log.count; this code not work... select baseline.count baseline left join data_log baseline.sample=data_log.sample , baseline.count>= data_log.count -3 or baseline.count<= data_log.count +3; here table structure: create table baseline (id integer primary key, zone integer, sample integer, count integer, sqltimestamp datetime default current_timestamp); create table data_log (id integer primary key, zone ...

Streaming ipcam from Raspberry PI using Python/Flask -

i trying stream internal ip camera home using flask in raspberry pi (os raspbian). in python side cameras.py , used from camera_pi import camera @app.route('/cameras/') def index_cameras(): """video streaming home page""" return render_template('cameras.html') and in cameras.hmtl side used <img src='http://192.168.10.1/videostream.cgi?stream=1'> inside internal network, worked perfectly. however, outside not stream. not allowed use ddns. also, requirement streaming handled flask application. how should in order stream outside? you'll need setup dynamic dns 192.168.10.1 device (or device, on pc, if it's behind same router mentioned device) , open firewall rules communicate dynamic dns provider. once have dynamic dns url, you'll need replace 192.168.10.1 uri 1 dynamic dns in cameras.html file. here's instructions rolling own dynamic dns service using aws: http://wil...

c# - Automapper Ignore Auto Flattening -

i have entity in legacy system has format public guid id {get;set;} public int duration {get;set;} public bool durationtype {get;set;} in viewmodel have following public guid id {get; set;} public int duration {get;set;} mapping entity view model works fine, when try , map viewmodel entity dies. what appears doing trying call non existing property duration.type in reverse mapping (i.e it's trying auto-flatten). results in error cannot map int32 bool . does have suggestions on how disable auto-flattening in automapper or manually set fields maps happen using attributes. to have ignore durationtype property when mapping viewmodel entity add mapping configuration: mapper.createmap<viewmodel,entity>() .formember(dest => dest.durationtype, options => options.ignore());

php - Calculate pair occurrences -

let's have following string: foo,bar,baz bar,foo quux,baz,foo i'd generate list of pairs occur more 1 you'll following array: [['foo', 'bar'], ['foo', 'baz']], maybe sounds silly, i've been banging head time on how this. problem set couple of mb's large and, if possible code needs efficient. can push me in right direction? maybe kind of algorithm efficiency or sample code? a lot of in advance!!! divide , conquer. prepare list of pairs of 1 line , concatenate lines list of pairs , find out repeating. $string = <<<string foo,bar,baz bar,foo quux,baz,foo string; $lines = array_map(function ($line) { // split lines words $words = explode(',', $line); // filter repeats $words = array_unique($words); // sort words sort($words); return $words; }, preg_split('/\r/', $string)); function pairs($words) { $length = count($words); if ($length < 2) { ...

sql - DynamoDB for bank transactions -

i thinking simulate bank account transaction in dynamodb being nosql type database, use case suited dynamodb? or should stick sql based database? does know how banks handles this? use dynamodb or keep our transaction in separate table? a sql based system allows transactions across multiple tables, while dynamodb allows transactions @ individual item. however, there dynamodb transaction library java allows atomic transactions across multiple items @ expense of speed , substantially more writes per request. dynamodb support atomic counters , bank-account-like (the example on documentation page along line). dynamodb provides conditional writes can avoid type of race conditions when item attempted updated concurrently. could build suitable system on top of dynamodb? maybe, depends on specific requirements , how go implementing such system. said, dynamodb provide functionality outlined above address types of concerns arise when building such system.

php - Laravel 4: 502 Bad Gateway with Nginx only in one view -

i have strange error in server nginx because working on project many months , working fine except 1 view/page added because showing me 502 bad gateway don't why. i deleted whole html of view print simple text same i removed whole functionality controller render view same i changed route , name of controller same i have tried many things problem still persisting , in log of server block showing this: nginx server block error log 2015/08/05 08:25:42 [error] 2423#0: *885 recv() failed (104: connection reset peer) while reading response header upstream, client: 187.189.190.62, server: stage.mywebsite.com, request: "get /business/user/site.com/edit http/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "stage.mywebsite.com", referrer: "http://stage.mywebsite.com/business" php-fpm error log [05-aug-2015 08:25:42] warning: [pool www] child 6825 exited on signal 11 (sigsegv) after 28731.872473 seconds start [05-aug-2015 08:25:42...

ide - How are you supposed to use text editors without debugging tools? -

the thing haven't been able understand how supposed use plain ol' text editor textwrangler or atom code, opposed full-blow ide xcode or visual studio. there no debugging tools, can't know if made error, , isn't autocomplete (prebugging, heh heh) makes easier make mistakes. feel missing something; how people debug text editor workflow? using text editor without debug tools forces write beautiful code works first time 100% of time. each line of code crafted , expect do. i use vim programming, takes while learn it's worth it. end writing code easy read, because have read , re-read code before run it. debugging more pressing button , else software tells whats wrong yours. it's understanding code , doing. i'll admit finding missing comma can pain, tradeoff worth it. at end of day depends on whether want turn out 800 line of code hour, or if want build software robust , extendable anybody.

image - Downloading pics via R Programming -

i trying download image of website listed below via r programming http://www.ebay.com/itm/2pk-hp-60xl-ink-cartridge-combo-pack-cc641wn-cc644wn-/271805060791?sspagename=strk:mese:it which package should use , how should process it? objective: download image in page folder , / or find image url. i used url2 <- "http://www.ebay.co.uk/itm/381164104651" url_content <- html(url2) node1 <- html_node(url_content, "#icimg") node1 has image url, when trying edit content error saying non-character element. this solved problem html_node(url_content, "#icimg") %>% xml_attr("src")

Jquery autocomplete not updating -

i'm making ajax call populate input field autocomplete. autocomplete not being updated, json response being generated correctly, problem results of autocomplete not being updated. strange autocomplete works on localhost, when try on web server, doesn't work. below code: <input name="label" class="form-control ui-autocomplete-input ui-autocomplete-loading" type="text" id="label" autocomplete="off"> here javascript of autocomplete: $(document).ready(function() { $('#label').autocomplete({ minlength: 3, source: function(request, response){ var loadtitles = "<?php echo $this->html->url(array('controller' => 'titles', 'action' => 'getajax'))?>/" + request.term; $.getjson(loadtitles, function(data){ response(data); }); }, focus: function(event, ui){ ...

html - Keep space / padding between Divs -

Image
how able keep space between inlined div elements without counting space 'pixels'? for example, i'm using margin-right (as padding between elements) counting pixels (the result shows off ugly, see jsfiddle, div element gets pushed down). #parent .child { position: relative; display: inline-block; height: 100%; width: 16.5%; background-color: green; margin-right: 15px; } jsfiddle basically, have first item floaten left , last item floaten right. know many of guys thinking, why not use feature 'justify'? i've tried using it, isn't option since amount of elements can (10, 5, 8, etc). help appericiated! edit: feature i'd achieve multiple elements (instead of having 1 row, there 2-16 rows. you can use text-align: justify . won't justify last line, can force new line pseudo-element: #parent { text-align: justify; background-color: red; } #parent:after { content: ''; display: inline...

bootloader lock failure standard unlocking commands not working thinking its hash failure or sst key corrupted -

i not know why when y friend gets inebriated hook phone pc , play it. has basic knowledge of adb , fastboot commmand , verified thrown. when went re-lock bootloader did not thisi did. downloaded google minimal sdk tools updated adb , fastboot went way , got mfastboot motorola insure parsing flashing. of these fastboot packages tested on mac , linux ubuntu, on windows 8.1 pro n update 1 , windows 7 professional n sp2 (all x64). resulted in same errors. super thorough , taught here how manually erase , flash no scripts or tool kits. fastboot oem lock and returned. (bootloader) fail: please run fastboot oem lock begin first! (bootloader) sst lock failure! failed (remote failure) finished. total time: 0.014s then tried again, again, , yep again. @ this point either read log , followed it. though think based on point starts playing phones more started panic because needs bootloader locked work , started attempting flash. fastboot oem lock begin ...

css - Keep div's from pushing each other -

Image
the picture layout want when hover, gets messed up. div's start shifting around , moving horizontally when next div italicizes. how can maintain exact layout 100% of time? .project-link { font-family: 'utopiastd'; color:#010202; font-size:5.6vw; white-space:nowrap; text-decoration:none; margin-right: 3%; line-height:125%; border-bottom: solid transparent 2px; } https://jsfiddle.net/zjkouzbo/1/ solution 1: you had right idea trying white-space:nowrap . keep first 2 links , keep them on 1 line, wrap them in parent element , apply white-space:nowrap parent element. if have on both anchor elements , parent elements, won't break lines in middle of link or between them. <div class="line"> <a class="project-link" id="one" href="#modal1">maru speaker design <span> (1) </span> </a> <a class="project-link" id="two" href="#modal2">lights — out ...

math - Bezier curve arc lengths -

i have code calculates length of bezier curves. i'm trying write unit tests it. other trivial cases (straight line beziers) don't know actual correct values lengths. i've looked online , been unable find any. does have info? i'm looking link table few rows containing 4 bezier control points , length, or possibly create couple of beziers in drawing program calculates length (i've tried using blender , inkscape info , they're quite complicated). solution. download pomax's bezier javascript code here , open html in web browser: <html> <head> <script src="bezier.js"></script> </head> <body> <script> curve = new bezier([4.0, 0.0, 4.0, 4.0, 0.0, 12.0, 16.0, 0.0, 12.0, 16.0, 0.0, 4.0]); document.write(curve.length()); </script> </body> </html> if want actual arc lengths test against, implement https://githu...

objective c - Is there a way to show warning on not using weak self? -

every few months, same problem of viewcontroller not getting dealloced because of not using weak-self in block. there way of making xcode warn me this? thanks. this might -warc-retain-cycles also, if instead of build , choose analyze in xcode, give more information bad practices in code includes information using weak variables. another level further use infer , static analyzer ios/android facebook open sourced: www.fbinfer.com also, see: http://fuckingclangwarnings.com/ other warnings. have '-w' set on project standard warnings

How to determine the zodiac symbol in R? -

i did statistics today using excel , r . part of work requires determine zodiac symbol according date of birth. did in excel: sample data: dob 25-jan-1985 25-jul-1983 28-aug-1982 24-feb-1984 13-jan-1985 24-jan-1982 15-feb-1984 14-oct-1983 08-sep-1984 04-mar-1983 04-apr-1984 31-mar-1985 04-aug-1984 29-jan-1984 20-jul-1984 ... here rule determine zodiac symbols: dec. 22 - jan. 19 - capricorn jan. 20 - feb. 17 - aquarius feb. 18 - mar. 19 - pisces march 20 - april 19 - aries april 20 - may 19 - taurus may 20 - june 20 - gemini june 21 - july 21 - cancer july 22 - aug. 22 - leo aug 23 - sept. 21 - virgo sept. 22 - oct. 22 - libran oct. 23 - nov. 21 - scorpio nov. 22 - dec. 21 - sagittarius excel formula: =lookup(--text(a2,"mdd"),{101,"capricorn";120,"aquarius";219,"pisces";321,"aries";420,"taurus";521,"gemini";621,"cancer";723,"leo";823,"virgo";923,"libran...

c++ - MinGW g++ 4.8.1-4 doesn't recognize -std=c++14 -

i installed mingw following home page sourceforge , using mingw-get-setup.exe. installed g++ 4.8.1-4. gcc 4.8 supposed to support c++14 command-line switch, "unrecognized option" error. is bug mingw? gcc? can it? since know ask, want c++14 for-each loops. i'm using iterators now, for-each improve both readability , writability. edit: found out g++ build supports c++11, can use for-each. still no luck on c++14 support. g++ 4.8 not support c++14, mingw quite outdated when there more new versions of gcc. alternatives can use if want use c++11 or c++14 on windows gcc should using 1 of following options: https://msys2.github.io/ (uses mingw-w64 internally). http://mingw-w64.org/doku.php (it supports 32-bits too). http://tdm-gcc.tdragon.net/ .

java - How to parse String containing '+' symbol -

this question has answer here: integer.parseint in java, exception when '+' comes first 6 answers i have string has numbers. i have code this, string tempstr = "+123"; numberformat numformat = numberformat.getnumberinstance(); numformat.setparseintegeronly(true); try { int ageindays = integer.parseint(tempstr); system.out.println("the age in days "+ageindays); } catch (numberformatexception e) { // todo auto-generated catch block e.printstacktrace(); } } it working fine number negative symbols.but can't number '+' symbol. throws numberformatexception. so how can parse number '+' symbol string? in case using java 7 or higher recommend using java.lang.long; or java.lang.integer; (if sure have parse integers). it works both cases. later edit: didn...

Form CollectionType with radio buttons fails after Symfony 2.7 upgrade -

getting below error.. an exception has been thrown during rendering of template ("the form's view data expected of type scalar, array or instance of \arrayaccess, instance of class proxies__cg__\bla\mybundle\entity\transporttype. can avoid error setting "data_class" option "proxies__cg__\bla\mybundle\entity\transporttype" or adding view transformer transforms instance of class proxies__cg__\bla\mybundle\entity\transporttype scalar, array or instance of \arrayaccess.") in mybundle:shipping:form.html.twig @ line 8. $builder->add('variables','collection', array( 'type' => new abctype(), 'options' => array( 'required' => true, ), 'constraints' => new notnull())); abctype.php class abctype extends abstracttype { /** * build form * * @param formbuilder $builder * @param array $optio...

c++ - Visual Studio 2013: linker errors with custom enumerations? -

i'm using following code, written james mcnellis, simplify declaring more-functional c++2011 enums: #pragma once #include <stdexcept> #include <boost/preprocessor.hpp> #include <vector> // internal helper provide partial specialization checked_enum_cast template <typename target, typename source> struct checked_enum_cast_impl; // exception thrown checked_enum_cast on cast failure struct invalid_enum_cast : std::out_of_range { invalid_enum_cast(const char* s) : std::out_of_range(s) { } }; // checked cast function template <typename target, typename source> target checked_enum_cast(source s) { return checked_enum_cast_impl<target, source>::do_cast(s); } // internal helper declare case labels in checked cast function #define x_define_safe_cast_case(r, data, elem) case elem: // how this? question asked on stackoverflow 11/30/14 -- check again soon. #define x_add_to_toret(r, data, elem) toret.push_back(elem) // defines enum...

javascript - Ext.ux.panel.PDF with Ext JS 3.4 -

i've planned use https://github.com/sunbox/ext_ux_pdf_panel view pdf files in project. but version i'm using 3.4. can version stuff? i have got error in ext-all.js uncaught typeerror: b[(d.xtype || e)] not functionext.componentmgr.create @ ext-all.js:7