Posts

Showing posts from February, 2010

rust - How does the lifetime work on constant strings? -

i read tutorial on official website , have questions on lifetime of constant strings. i error when write following code: fn get_str() -> &str { "hello world" } error: test.rs:1:17: 1:21 error: missing lifetime specifier [e0106] test.rs:1 fn get_str() -> &str { ^~~~ test.rs:1:17: 1:21 help: run `rustc --explain e0106` see detailed explanation test.rs:1:17: 1:21 help: function's return type contains borrowed value, there no value borrowed test.rs:1:17: 1:21 help: consider giving 'static lifetime error: aborting due previous error however it's ok when add parameter: fn get_str(s: &str) -> &str { "hello world" } why work? how "hello world" borrow parameter s , though has nothing 's'? lifetime elision infers full type of fn get_str(s: &str) -> &str is fn get_str<'a>(s: &'a str) -> &'a str which means return

Function not being called through delegate in Swift -

i can't app execute changecard() after abc() finishes executing. 2 functions in different classes. here code below. appreciated! protocol networkcontrollerdelegate { func changecard() } class networkcontroller { var networkcontrollerdelegate: networkcontrollerdelegate? func abc () { //do here networkcontrollerdelegate?.changecard() } } class view: uiviewcontroller, networkcontrollerdelegate { var networkcontroller = networkcontroller() func changecard() { //do here networkcontroller.networkcontrollerdelegate = self } } i've read similar questions on stackoverflow past few hours still can't figure out. thanks! try moving following line viewdidload of view controller delegate set prior use. networkcontroller.networkcontrollerdelegate = self also, might want think making networkcontrollerdelegate variable in networkcontroller weak avoid retain cycles.

node.js - MQTT-over-Websockets doent work on remote server -

i'm using deploy https://medium.com/@lelylan/how-to-build-an-high-availability-mqtt-cluster-for-the-internet-of-things-8011a06bd000 now want send message form browser device (for fake in localhost) if both broker client.hmtl , client.js on localhost client.html <html> <head> <meta charset="utf-8" /> </head> <body> <script src="./browsermqtt.js"></script> <script> var device = { nickname: 'wbk0da8v9l2wewmi', secret: 'mysecret' }; var msg = 'devices/' + device.nickname + '/msg' ; var var client = mqtt.connect( { host: 'localhost', port: 3000, username: device.nickname, password: device.secret }); client.subscribe(msg); client.on('message', function(topic, payload) { console.log('my message ',[topic, payload].join(": ")); client.end(); }); client.publish(msg, "hell

ios - Is the order of SKNode.nodesAtPoint guaranteed? -

sknode has method nodesatpoint returns array of children nodes intersect given point. order of elements in such array deterministic (e.g. drawing order)? i not find answer in documentation, answer "no", verify. nope, sprite kit not take account z-position when traversing node-tree (definitely performance reasons). can see adding few nodes scene in-order , changing z-positions. order based on position of node within node-tree, rather z-position.

java - Connect with Google Drive without add account to android.accounts.AccountManager? -

please tell me whether possible? connect google drive, not want add account android accountmanager. credential = googleaccountcredential.usingoauth2( activity, arrays.aslist(scopes)) .setbackoff(new exponentialbackoff()) .setselectedaccountname(pref_account_name); it not work because account not added android.accounts.accountmanager. i not want show user account application connected , taking files. thanks

Share and update docker data containers across containers -

i have following containers: data container build directly in quay.io github repo, website. fpm container nginx container the 3 of them linked , working fine. problem every time change in website (data container) rebuilt (of course) , have remove container , fpm , nginx , recreate them able read new content. i started "backup approach" i'm copying data container host directory , mounting fpm , nginx containers, way can update data without restarting/removing service. but idea of moving data data container host, doesn't me. wondering if there "docker way" or better way of doing it. thanks! update: adding more context dockerfile d`ata container definition from debian add data/* /home/mustela/ volume /home/mustela/ where data has 2 files: hello.1 , hello.2 compiling image: docker build -t="mustela/data" . running data container: docker run --name mustela-data mustela/data creating container link previous one:

int - Rounding to Nearest Even Number in C++ -

i wondering if c++ included way round nearest number. i've looked around , can't seem find on subject. write own method, using built-in 1 faster. thanks. there no built-in function this. straightforward way might like: even = round(x / 2) * 2;

JSON-like data format -

i have strange data format need parse. looks quite similar json, it's not - , json parsers crash when trying parse it. wondering if knows data format is. looks this: {key1, [{1, 'some_value'}]}. {'key2', [{key3, "value"}, {key4, [{key5, "some_value"}, {key6, 24}, {key7, "some_value"}, {key8, "some_value"}]} ] }. thanks!

node.js - Passport-http bad request -

i wanna make simple authentication passport-http (digeststrategy). like: var digeststrategy = require('passport-http').digeststrategy; passport.use('login', new digeststrategy({ qop: 'auth' }, function(login, password, done) { user.findone({ login: login }, function(err, user) { if (err) { return done(err); } if (!user) { return done(null, false); } user.matchpassword(password, function(err, ismatch) { if (!ismatch) { return done(null, false); } return done(null, user); }) }); } )); and in post /login router.post('/', passport.authenticate('login', {session: false}), function(req, res) { if (req.user) { var expires = moment().add('hours', 1).valueof(); res.json({ expires: expires, user: req.user

android - How can I run the Search Activity in a different thread? -

i writing app has searchview widget, , i'm using searchable.xml configuration , searchactivity search , display results pending on query searchview widget according tutorial: http://developer.android.com/guide/topics/search/search-dialog.html works fine, there delay between time user presses enter button search, , time searchactivity displayed. commented out search algorithm , left textview in searchactivity, lag still there. possible run searchactivity in different thread or else display searchactivity when initialized? asynctask used process want seperate ui , display result in ui refer: async task

javascript - How to loop through the 'key' value of an object with AngularJS? -

i have following data , html template (and other code in app.js obviously). code in "tbody" works perfectly, , displays table this: current output -------------------- | aapl | 127 | 128 | -------------------- | goog | 523 | 522 | -------------------- | twtr | 35 | 36 | -------------------- now i'm trying loop through 'keys' of first object , display them in 'thead' so: desired output -------------------- | name | jan | feb | -------------------- | aapl | 127 | 128 | -------------------- | goog | 523 | 522 | -------------------- | twtr | 35 | 36 | -------------------- data $scope.data = [ { "name": "aapl", "jan": "127", "feb": "128" }, { "name": "goog", "jan": "523", "feb": "522" }, { "name": "twtr", "jan": "35", "feb": "36&q

asp.net - REST WebService C# is not accepting Emoticons -

i have rest webservice accepts feedback windows 8.1 app. works until user inserts emoticon text. example: awesome!! 😃 when happens get:{statuscode: 400, reasonphrase: 'bad request', version: 1.1, content: system.net.http.streamcontent, headers: { date: thu, 16 jul 2015 21:05:54 gmt server: microsoft-iis/10.0 x-powered-by: asp.net content-length: 1806 content-type: text/html }} i have no idea why happening. here code service: [operationcontract] [webinvoke( method = "post", responseformat = webmessageformat.json, requestformat = webmessageformat.json, uritemplate = "postfeedback")] void capturefeedback(feedback tmpfeedback); the processing code: public void capturefeedback(feedback myfeedback) { using (dbemployeedirectoryentities entities = new dbemployeedirectoryentities()) { feedback tmpfeedback = new feedback(); tmpfeedback.feedbackgu

c# - Get text from dynamically-generated textbox to insert with button -

i creating divs textbox , button on each one. being created this: textbox txtgosto = new textbox(); txtgosto.id = "txtgosto_" + postid; then, button after eventhandler submit text. btninsertpost.id = "btninsertpost_" + postid; btninsertpost.click += (sender, e) => { insertpost(sender, e, postid); }; the postid working , being passed argument, wondering how can text dynamic generated textbox , submit too. think might after txtgosto.text property. https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.text(v=vs.110).aspx

Android: align labels and buttons in multiple lines -

Image
i go nuts on layout. here's i'm trying achieve. simple layout having label (textview) or edit field (edittext) on left side , button on right side. want labels , buttons vertically adjusted - meaning buttons of same width , labels too. but how this? tried linearlayout vertical orientation , each line linearlayout horizontal orientation , inside label has layout_weight of 8 , button 1. still not guarantee want! this current result. can see buttons not nicely aligned. this layout: here's xml: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content"

sql server ce - MS Sync framework "Enumerating Inserts for Table xxxx" is suddenly extremely slow -

edited new info. i inherited project utilizes ms sync framework 2.1 sync sql server ce 3.5 db sql server 2008 r2. there 1 million rows spread on dozen tables. 2 of tables account ~75% of total rows. few dozen rows change per day, , there less 10 users / installations in spoke-and-hub arrangement. sync has little work each day . the previous version of project complete "do-nothing" sync (zero rows inserted, updated, or deleted on either end) in 1-2 minutes. since re-generated .sdf (including data), taking 9 minutes minimum, , far longer users. by enabling verbose sync logging, , comparing new log files older ones, narrowed problem down 1 type of operation. time accounted in steps logged "enumerating inserts table xxxxx" (client-side inserts waiting go server). bigger tables take longer smaller tables, of them have increased proportionally, , dramatically, 1 operation, if result 0 rows. edit: appeared unsupported query syntax (for sql server ce) appear

random forest - How to get the probability per instance in classifications models in spark.mllib -

i'm using spark.mllib.classification.{logisticregressionmodel, logisticregressionwithsgd} , spark.mllib.tree.randomforest classification. using these packages produce classification models. these models predict specific class per instance. in weka, can exact probability each instance of each class. how can using these packages? in logisticregressionmodel can set threshold. i've created function check results each point on different threshold. cannot done randomforest (see how set cutoff while training data in random forest in spark ) unfortunately, mllib can't probabilities per instance classification models till version 1.4.1. there jira issues ( spark-4362 , spark-6885 ) concerning exact topic in progress i'm writing answer now. nevertheless, issue seems on hold since november 2014 there no way posterior probability of prediction naive baye's model during prediction. should made available along label. and here note @sean-owen on mailing l

ios - Apple Watch Static Notification View Insets -

Image
i noticed difference between push notification iphone-only application , apple watch compatible app, , wish make watch-compatible app display notification normal iphone-only app push notification. watch-compatible app: iphone-only app: in watch app, notification view (this screenshot actual apple watch) has weird insets (spacing between actual text , box), whereas iphone-only app has spaced insets. tried setting width of label of notification text size smaller border , worked (sort of, seen above), unable set top , bottom insets (the spacing between top , bottom boundaries of box , text) of options available me in interface builder. how should go setting top insets apple watch ensure coherent rest of watchos? cheers. you add group static notification , drag label inside it.

sdn - pkg_resources.DistributionNotFound for Ryu-oe -

my goal have optical linc switch running , use ryu-oe control it. receive following error when try run ryu-oe instruction this link . ryu-oe ryu controller optical extensions. file "/usr/local/bin/ryu-manager", line 5, in <module> pkg_resources import load_entry_point file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2749, in <module> working_set = workingset._build_master() file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 446, in _build_master return cls._build_from_requirements(__requires__) file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 459, in _build_from_requirements dists = ws.resolve(reqs, environment()) file "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 628, in resolve raise distributionnotfound(req) pkg_resources.distributionnotfound: msgpack-python>=0.4.0 anyone knows how can solve error? ok seems problem s

save indexed images in MATLAB -

Image
i have image point curse shows x ,y index rgb the index values important me , want save image , use later. when using imwrite(im, 'importantim.png' , 'png') the created image not have index value. here resulting saved image (png format); i produce im , below im=zeros([1204 1204]); with loop add data it.

c# - Passing parameters to Windows Service during installation -

i creating windows service suppose data in specific table , process record based status. i want pass db credentials while install service using installutill parameters , save them inside registry. have tried doing using code bellow, keep getting error on event "onbeforeinstall". i believe either passing parameters incorrectly or writing code in wrong event. need figure doing wrong. protected override void onbeforeinstall(idictionary savedstate) { base.onbeforeinstall(savedstate); _eventlog.writeentry("onbeforeinstall started"); try { registrykey key = registry.currentuser.createsubkey(@"software\ryterms"); if (key != null) { _eventlog.writeentry("write data registry key"); key.setvalue("dbtype", this.context.parameters["dbtype"].tostring()); // throws error, assuming above event entry visible. key.setvalue("datasource", this.context

How to access Delayed Job instance inside Active Job - Rails 4.2 -

i'm using activejob delayed_job (4.0.6) in background , want find scheduled job deleted it. for instance, if have class myclass def my_method perform_stuff myjob.set(wait: 1.month.from_now).perform_later(current_user) end end then, if edit myclass instance , call my_method again, want cancel job , schedule new one. as suggested in post http://www.sitepoint.com/delayed-jobs-best-practices , added 2 columns delayed job table: table.integer :delayed_reference_id table.string :delayed_reference_type add_index :delayed_jobs, [:delayed_reference_id], :name => 'delayed_jobs_delayed_reference_id' add_index :delayed_jobs, [:delayed_reference_type], :name => 'delayed_jobs_delayed_reference_type' so way may find delayed job , destroy it. wanted inside activejob class, maintain pattern of jobs in project. i wanted like: class myjob < activejob::base after_enqueue |job| user = self.arguments.first job.delayed_reference_id

ios - Target without some of the classes of the scenes in the Storyboard -

i have number of targets in project, each using same storyboard selection of classes linked in it. xcode not complain, @ least not on iphone version, nor in targets. yet specific 1 complaints 2 specific classes with: unknown class ****** in interface builder file. unknown class $$$$$$ in interface builder file. notwithstanding there many other scenes in storyboard class of not included in target, in specific case. it happens when execute app on ipad (simulator) , after while crashes on uiapplicationmain; not know if 2 things connected, though. is there way in xcode decides check scenes of storyboard , other not existence of corresponding class? the problem swift module based. each target module. class defined in specific module, , namespaced module. thus, viewcontroller in myfirsttarget different viewcontroller in mysecondtarget - myfirsttarget.viewcontroller , mysecondtarget.viewcontroller . if in storyboard's identity inspector, see in fact tel

c# - Why isn't it faster to update a struct array than a class array? -

in order prepare optimization in existing software framework, performed standalone performance test, assess potential gains before spending large amount of time on it. the situation there n different types of components, of implement iupdatable interface - interesting ones. grouped in m objects, each maintaining list of components. updating them works this: foreach (groupobject obj in objects) { foreach (component comp in obj.components) { iupdatable updatable = comp iupdatable; if (updatable != null) updatable.update(); } } the optimization my goal optimize these updates large amounts of grouping objects , components. first, make sure update components of 1 kind in row, caching them in 1 array per kind. essentially, this: foreach (iupdatable[] compoftype in typesortedcomponents) { foreach (iupdatable updatable in compoftype) { updatable.update(); } } the thought behind jit or cpu might have easier time op

unit testing - How do local static objects govern compilation in C++? -

i have been learning effective c++ , in 1 of guidelines meyer mentions if declare non-local static object in 1 translation unit definition in translation unit results in undefined behaviour. problem fixed writing function returns reference local static object. my question that: how local static objects govern compilation of various translation units? how compiler know translation unit execute first? and apologies if asked question in bit incorrect way. hope understood meant. how local static objects govern compilation of various translation units? it's storage durations , privacy. static objects need persist duration of program execution. placed in different area of memory stack or heap. other translation units may have static objects. having compiler tag these items, linker can throw them same area of memory. static objects need privacy. when other translation units use variable identifiers (of static objects in other modules), can't be

c# - how can i round off my value based on user input? -

i have code in updatetobill code. im planning round off nearest tenth think? example price 123456.123456, want have 123456.12 because since price, need cents. in advance :) private void updatetotalbill() { double vat = 0; double totalprice = 0; long totalproducts = 0; foreach (datalistitem item in dlcartproducts.items) { label pricelabel = item.findcontrol("lblprice") label; // price textbox productquantity = item.findcontrol("txtproductquantity") textbox; // quantity double productprice = convert.toint64(pricelabel.text) * convert.toint64(productquantity.text); //computation fro product price. price * quantity vat = (totalprice + productprice) * 0.12; // computation total price. total price + product price totalprice = totalprice + productprice+40 +vat; totalproducts = totalproducts + convert.toint32(productquantity.text); } la

wordpress - How to get site's name from WP API -

Image
i'm trying wordpress website title using javascript , wp api plugin i didn't find example on how site's name found variable name under entities section in developer guide function _updatetitle(documenttitle) { document.queryselector('title').innerhtml = documenttitle + ' | '+ $http.get('wp-json/name'); } the output string of $http.get('wp-json/name') [object object] does know how use fix this? you didn't enough context. what's $http ? happens when go wp-json/name directly in browser? here's see: [{ "code":"json_no_route", "message":"no route found matching url , request method" }] here's simple example title: var sitename; $.getjson( "/wp-json", function( data ) { sitename = data.name; });

javascript - Parallax not working in materialize css -

i using materialize framework create phonegap app. http://materializecss.com they have parallax setting can see notation here: http://materializecss.com/parallax.html when run it, image not show @ all. html looks this: <div class="row"> <div class="col s12 m7"> <div class="card"> <div class="parallax-container" style = "height:100px;"> <div class="parallax"><img src="/img.png"></div> </div> <div class="card-content"> <h5> test</h5> <h6> test</h6> <h6> test </h6> </br> <p> test</p> </div> <div class="card-action"> <a href="#">this link</a> </div> </div> </div> </div> look example: http://jsfiddle.net/yhgj48

javascript - Can I use iron-localstorage and iron-ajax with highcharts -

i have polymer element uses iron-ajax create highchart. incorporate iron-localstorage chart render data in ls unless ls empty in case call iron-ajax load data api? my working element follows: <dom-module id="sales-chart"> <template> <iron-ajax id="ajax" url="{{url}}" last-response="{{data}}"></iron-ajax> <div id="container" style="max-width: 600px; height: 360px;"></div> </template> <script> polymer({ is: "sales-chart", properties: { url: string, data: object }, observers: [ // these functions run once observed properties contain // other undefined. '_requestdata(url)', '_chartdata(data)' ], _requestdata: function(url) { // note: use `generaterequest()` instead of `auto` property // because `url` may not available when ele

java - Activity onStart() being called before Fragment's onActivityCreated() -

Image
i'm having issue fragment's onactivitycreated() method being called after activity's onstart() method called. seems imply activity's oncreate() method finishing after onstart() ? can't case ... can it? when in activity's lifecycle fragment's onactivitycreated() called? furthermore, if have multiple fragments, how can control order of fragments' onactivitycreated() calls? in activity: @override protected void onstart() { super.onstart(); methoda(); // called ... } in fragment: @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); methodb(); // ... before } onactivitycreated() method being called after activity's onstart() method called remember onactivitycreated() method callback fragment activity. this seems imply activity's oncreate() method finishing after onstart()? can't case ... can it? wrong! activity , fragment s

html - Why can't I use nth-child on mark tags? -

nothing in code overwrites selector, i'm confused why it's not working. i've googled , asked few friends , don't know. checked server wasn't taking while update page updating text , seems fine. css mark { color: #ccc; background: #333; padding: 5px; margin: 5px; } mark:nth-child(even) { background: #000; } html <p><mark>warri0r</mark>yes</p> <p><mark>j3w1sh</mark>no</p> <p><mark>mrguy</mark>i don't know</p> <p><mark>explode_</mark>maybe...</p> <p><mark>usausausa</mark>why not?</p> <p><mark>samuel01</mark>absolutely</p> mark:nth-child(even) doesn't work because child of <p> . rewrite css: p:nth-child(even) mark { background: #000; } (select <mark> of <p> ) http://jsfiddle.net/hbxk3owh/

How to create site using SharePoint Designer 2013 and SharePoint Server 2013? -

when i'm trying create new 'blank site' in sharepoint designer 2013 tells me this web site must created on server running microsoft sharepoint foundation. please choose location. i'm run microsoft sharepoint server 2013 . should install microsoft sharepoint foundation 2013 or what? it sounds you're pointing new blank site template @ location sharepoint isn't installed. best way test if case first try opening site, put in location of new sharepoint installation , see if resolves. if not problem lays in sharepoint installation , should review documentation that.

mp3 - "MPEG audio header not found" error when opening with TagLib after converting with ffmpeg -

i converted wma file doing this... ffmpeg -i song.wma -f mp3 song.mp3 i can play mp3 file in windows media player, looks conversion worked. however, if try open file in taglib, error "mpeg audio header not found" on following line... taglib.file tf = taglib.file.create("song.mp3"); i've tried on few wma files, it's not 1 that's @ fault. anyone have idea did wrong? find docs ffmpeg pretty overwhelming, , complete ignoramus in field of audio encoding, haven't clue of means. i'm missing in conversion, although wouldn't explain why wmp can play taglib can't open it. whilst not strictly answer original question, managed way of doing wanted. please see corey's answer my question here , in shows how use naudio package convert file in code. better approach anyway, doesn't rely on running external programs, causing own problems. converted file produced package ran through taglib without issues.

How to get the file absolute path in JAVA project -

hi need read file using fileinputstream didn't right path. file location @ c:\users\tester\documents\java project\samples\projectone\src\pdfreader when used below code, wrong path "/c:/users/tester/documents/java%20project/samples/projectone/bin/projectone/testfile.txt" there code: string filepath; filepath=mainform.class.getresource("testfile.txt").getpath(); would tell me how file path? you using eclipse , have saved file testfile.txt inside source folder being copied bin folder, output folder of project. therefore, path not wrong. in code use getresource method, file retrieved same directory mainform.class found. http://docs.oracle.com/javase/7/docs/api/java/lang/class.html#getresource(java.lang.string) if want such file source folder, should this: system.out.println(new file("src/pdfreader/testfile.txt").getabsolutepath()); however, if planning distribute application better store kind of file in resources folder bec

javascript - Angularjs ng-href Bug? -

i came across strange , wanted see if had same problem. using angularjs ng-href directive within ng-repeat below. issue encountered if ng-href tag contains {{var}}, nothing. <li ng-repeat="app in apps"> <a ng-href="{{app.name}}">{{app.name}}</a> <--this not work </li> if add space (or else) before or after {{var}} illustrated below links expected. <li ng-repeat="app in apps"> <!-- note bug? here ... without leading or trailing character, doesn't work!! --> <a ng-href=" {{app.name}}">{{app.name}}</a> <--this works (added leading space) </li> am missing here? expected functionality? bug? tested in chrome , firefox same result... there seem ticket bug. ticket contains workarounds , fixes.

PDF doc view emacs doesn't render properly -

i configured emacs display pdfs using doc view. problem display flickers continuously. seems doc view refreshing frame leading unpleasant display. how stop doing this? also, haven't done customization doc view in .emacs yet. i'm using emacs 24.4 on windows 8.1 64 bit. note: repost original question pdf doc view flickers continously on emacs stackexchange. didn't answers have reposted here better hopes.

Is it possible to increment iterator in loop in Python? -

i increment iterator in loop in python. code below: for in range(0,10): print(i, end="") if % 3 == 0: += 2 else if % 3 == 0: += 3 in such way output of code is: 0123456789 but should different. thanks. i reassigned @ every iteration; that's how for loop works. if want skip every second number (i.e. iterate in steps of 2), you'll need this: for in range(0, 10, 2): print(i, end="") that third parameter of range function, called step , determines i incremented in each iteration.

vb.net - Store things like Color, font, location in a dataset -

i know how mysettings can choose many different types. however, i'm working untyped dataset, , i'm looking store more custom types color, font etc. example of class attributes i'm looking store , retrieve: mynetmarquee .marqueetext = marqueeeditor._gamebio .scrolllefttoright = scrollingmarquee.direction.left .scrollspeed = 3 .forecolor = color.blue .shadowcolor = color.black .shadowoffset = 5 .strokesize = 4 .strokecolor = color.yellow .font = new drawing.font("centuriqua-ultra", 40, fontstyle.regular) .location = new point(100, 300) end i'm setting dataset via designer, loathe go designer code experiment code in there because know can mess things up. however, when set specific datatable store these in, have basic types (string, int32 etc). there 1 called "system.object" - bit of mystery me. have read msndn artcile on it, ever, left me non wiser. o

How do I pass a variable(Date) as a parameter in python into SQL? -

could please guide me how can pass variable(date) parameter below sql (postgre sql database) in python script ? last_execution_date = datetime.datetime.now().strftime("%y-%m-%d") the query: select distinct researcherid, username, firstname, lastname, researcher r inner join principals p on p.researcherid = r.researcherid r.lastmodifieddate > 'last_execution_date' i need pass last_execution_date parameter above sql statement. please tell me correct syntax? not quite sure whether possible pass outside variable parameter because sql statement runs on database , returns data. try like: say: last_execution_date = datetime.datetime.now()<br> then, cursor.execute('select distinct researcherid , username, firstname, lastname,from researcher r inner join principals p on p.researcherid = r.researcherid r.las

Java- How to modify existing object with new value available in array list? -

i have 1 value object set 10 rows after retrieved values db. i want update 1 of value in existing 10 rows(objects) new values. new values available in list. how set these values ? you can given for(int i=0;i<arraylist.size();i++) { object object = arraylist.get(i); object.setfield(newvalue); }

osx - Python: source code string cannot contain null bytes -

i'm using max os x 10.10.3, , got graphics.py show in python 3, before saying no module existed. however, when try import graphics , or from graphics import * , message: "source code string cannot contain null bytes" does mac user (using python 3) perhaps know wrong? has used zelle book , graphics.py module? thanks. for posterity: had same problem , fixed using, sed -i 's/\x0//g' filename the file seemed messed in numerous ways (wrong endings, etc); no idea how... see https://stackoverflow.com/a/2399817/230468

Heroku - Error H10 (App crashed) Ruby on rails -

no idea im doing wrong. app works fine locally, keep getting application error page , h10 error . ill post rails console output because read more useful heroku logs, can put here if needed. hope not going ignored @ total lose right now. rails console: running `rails console` attached terminal... up, run.8093 /app/vendor/bundle/ruby/2.1.0/gems/activerecord-4.2.1/lib/active_record/dynamic_ matchers.rb:26:in `method_missing': undefined local variable or method `request' session (call 'session.connection' establish connection):class (nameer ror) /app/app/models/session.rb:3:in `<class:session>' /app/app/models/session.rb:1:in `<top (required)>' /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.1/lib/active_s upport/dependencies.rb:274:in `require' /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.1/lib/active_s upport/dependencies.rb:274:in `block in require' /app/vendor/bundle/ruby/2.1.0/ge

java - I want to retrieve image from database and display it in JSP using <img> tag. I am using my sql -

i want retrieve image database , display in jsp using img tag. using mysql. public class displayimage extends httpservlet { public void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { //printwriter pw = response.getwriter(); string connectionurl = "jdbc:mysql://localhost:3306/demodb";; java.sql.connection con=null; try{ class.forname("com.mysql.jdbc.driver").newinstance(); con=drivermanager.getconnection(connectionurl,"root","0321"); statement st1=con.createstatement(); resultset rs1 = st1.executequery("select photo contacts contact_id='2'"); string imglen=""; if(rs1.next()){ imglen = rs1.getstring(1); system.out.println(imglen.length()); } rs1 = st1.executequery("select photo contact

android - How to add ListPreference in this Activity? -

i newbie @ android development , trying implement settings activity can take user preferences. settings activity includes code handle edit preference changes.the module implemented android 3.0 , above hence settings fragment used. public class settingsactivity extends preferenceactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getfragmentmanager().begintransaction().replace(android.r.id.content, new settingsfragment()).commit(); } public static class settingsfragment extends preferencefragment implements sharedpreferences.onsharedpreferencechangelistener{ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // load preferences xml resource addpreferencesfromresource(r.xml.pref_general); } @override public void onresume(){ super.onresume(); getpreferencescreen().getsharedpreferences().registeronsharedprefere

javascript - fullpage.js animation with onLeave and afterLoad -

i'm using fullpage.js , i'd animate 2 images second section. looks can't make work css only, picked js code documentation. check jsfiddle: http://jsfiddle.net/67oe1jvn/9/ the thing is: if scroll down second section, 2 images animated , fade in left , right sides. if change section, nothing happens... want "disappear" leave second section. i used afterload , onload said in documentation, this: $.fn.fullpage({ afterload: function(anchorlink, index){ var loadedsection = $(this); if(index == 1){ $('#slidetext1 #rock').animate({right:"0px"}); $('#slidetext1 #deer').animate({left:"0px"}); } }, onleave: function(index, nextindex, direction){ var leavingsection = $(this); if(index == 2 && direction =='up'){ $('#slidetext1 #rock').animate({right:"-271px"}); $('#slidetext1 #deer').animate({left: