Posts

Showing posts from June, 2013

java - Draw Text in Middle of the Screen -

i'm trying draw text in middle of jframe window, , it's off little bit. here's i've tried : fontmetrics fontmetrics = g.getfontmetrics(font); // draw title g.setcolor(color.white); g.setfont(font); int titlelen = fontmetrics.stringwidth("level 1 over!"); g.drawstring("level 1 over!", (screenwidth / 2) - (titlelen / 2), 80); i've found textlayout class gives better dimensions string fontmetrics. @override public void paintcomponent(graphics g) { super.paintcomponent(g); if (font == null) { return; } graphics2d g2d = (graphics2d) g; fontrendercontext frc = g2d.getfontrendercontext(); textlayout layout = new textlayout(samplestring, font, frc); rectangle2d bounds = layout.getbounds(); int width = (int) math.round(bounds.getwidth()); int height = (int) math.round(bounds.getheight()); int x = (getwidth() - width) / 2; int y = height + (getheight() - height) / 2; layout.dra...

linux - Getting length of /proc/self/exe symlink -

as mentioned on so, readlink on /proc/self/exe can used executable path on linux. man 2 readlink recommends 1 should use lstat extract required length of path. however, when stat /proc/self/exe, st_size member set 0. how can length allocating buffer? in practice, tend use reasonable size (e.g. 256 or 1024, or path_max ) readlink of /proc/*/exe (or /proc/self/exe ) the point always, executables supposed started humans, either path (for execvp(3) or shell) or entire file path human friendly. don't know people explicitly uses long filenames (not fitting in width in terminal screen). never heard of executable programs (or scripts) filename exceeds hundred of bytes. so use local buffer of reasonable size (and perhaps strdup on success if needed). , readlink(2) returns number of meaningful bytes in buffer (so if care, grow buffer , make loop till fits). for readlink of /proc/self/exe , 256 bytes buffer @ initialization, , abort (with meaningful error message) if...

ruby on rails link_to an image -

i'm facing following problem: have small image gallery image files located in following directories app/assets/images/locale/thumbs/ app/assets/images/locale/big/ i have create hyperlink content has thumb image , target - bigger version app/assets/images/locale/big/ folder: <a href="path-to-full-size-image-001.jpg"> <img alt="first photo preview" src="/assets/locale/thumbs/001.jpg" /> </a> i'm doing means of = link_to(image_tag("locale/thumbs/001.jpg"), "locale/big/spizzicaluna001.jpg") in fact have tried many variants second argument of link_to little success - bigger file can not found. how resolve issue? there 2 approches issue. you must specify assets folder in path. link_to( image_tag("locale/thumbs/001.jpg"), "/assets/locale/big/spizzicaluna001.jpg" ) use image path allowing rails find correct image link_to( image_tag("locale/thu...

ios - Jquery Mobile - Nav images / click event not firing properly -

Image
does know if there min size / specific background style or display type images used nav items in jquery mobile ios html5 apps? i'm having problems clicking on menu items - click action triggers, nothing happens - think may icon size issue , dependant on finger selecting centre of icon - reasonable size - not sure if thats plausible - not sure! i've put app nav using high res png's have opaque backgrounds - example css below home button - .topmnu ul li a{width:35px; height:29px;display:inline-block;} a.home{background:url(../img/ico_home.png) no-repeat; background-size:27px 29px; width:27px; height:29px;margin-right:0px;} and html - <li><a href="#home" class="home" data-transition="slide"></a></li> screenshot showing segment of app nav below - any ideas / suggestions?

Why can't see session in codeigniter from another controller? -

i have 2 controllers 1-connect facebook 2-connect create when want register click on connect_facebook.php , controller info data , set in session, fill form , send data connect_create.php . problem connect_create controller can't see session ever, why? <?php /* * connect_facebook website */ class connect_facebook extends website { /** * constructor */ function __construct() { parent::__construct(); // load necessary stuff... $this->load->config('account'); $this->load->helper('form'); $this->load->helper(array('language', 'ssl', 'url')); $this->load->library(array('authentication', 'facebook_lib')); $this->load->model(array('account_model', 'account_facebook_model')); $this->load->language(array('general', 'sign_in', 'account_linked', 'connect_th...

How to convert oracle procedure into mysql with exception handling -

hi all, am new mysql.actually oracle developer converting procedure oracle mysql.in changes have doubt in mysql. in oracle:- create procudure test_proc(p_id in varchar2, p_error_code out number, p_error_msg out varchar2) begin insert test_1(a) values(p_id); commit; p_error_code:=0; exception when others p_error_code:=1; p_error_msg:=substr(sqlerrm,1,150); rollback; return; end; i need same type of procedure in mysql or sample procedure how handle exception , show error output variable sqlerrm in oracle. thanks , regards, vinoth you can use exit , continue handler. cant clear error details in oracle.

javascript - jsPDF and image loading -

i'm tryna use jspdf library. i'd load , insert image, , export pdf file. my issue image loading. i'm doing this: var imagedata = getbase64image('thinking-monkey.jpg'); , should dataurl in base64 inside imagedata . my getbase64image() function following: function getbase64image(url) { var img = new image(); var dataurl; img.src = url; img.onload = function() { var canvas = document.createelement('canvas'); canvas.width = img.width; canvas.height = img.height; var context = canvas.getcontext('2d'); context.drawimage(img, 0, 0); dataurl = canvas.todataurl('image/jpeg'); } return dataurl; } but returns 'undefined', because image 65 kb , doesn't load @ once. when @ return dataurl; variable still undefined. i've tried add settimeout() right before return dataurl; doesn't seem working. how can wait until image loaded return dataurl?...

Convert String to System.Decimal in java -

i have need of inserting variable of type system.decimal through java code. tried using float , double in java. seems not accepting. any idea equivalent datatype in java datatype of system.decimal in c#. can me out? the best equivalent bigdecimal . it't arbitrary-precision instead of fixed precision of system.decimal it's exact decimal arithmetic.

reporting services - Excel report from TFS for all testing effort including exploratory testing sessions -

we producing weekly reports on test team performance using excel via cube , these have worked now. report on weekly testing statistics test cases executed , outcome, bugs raised , work items updated, etc. with introduction of exploratory testing during sprint of testing exploratory sessions performed not included in testing statistics, , pivot table field list not seem include options exploratory sessions. could please identify if possible? after google search able locate details of how run exploratory test sessions , how view testing results test plan in test manager 2012. this has been answered on following thread http://social.msdn.microsoft.com/forums/vstudio/en-us/b1b2b0ae-a586-41da-9867-2ccf6b1e9e92/excel-cube-report-for-all-testing-effort-including-exploratory-testing-sessions reporting on exploratory testing not possible - feature request has been submitted http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/4358646-include-explora...

javascript - Node js file execution -

i having sample node js file executed in command prompt, but, not coming in browser, var http = require('http'); port = process.argv[2] || 8888; http.createserver(function(request,response){ response.writehead(200, { 'content-type': 'text/html' }); var pi = math.pi; exports.area = function (r) { var res1 = pi * r * r; response.end(res1, 'utf-8'); // alert(res1); return res1; }; exports.circumference = function (r) { var res2 = 2 * pi * r; response.end(res2, 'utf-8'); //alert(res2); return res2; }; }).listen(parseint(port, 10)); console.log("file server running at\n => hostname " + port + "/\nctrl + c shutdown"); strong text can anyone, please tell me have done mistake the problem not writing response of request. response.write() also using methods alert(); browser methods, code run executed in server side. currently declare methods not call out anything. this ex...

html - Linkable <Div> Overlay on iframe Video | Rails -

i'm on app users can upload clips vine , instagram. i'm retrieving clips on index pinterest calls pins, in masonry. but need overlay when people click on clip redirects them clips page (like link_to did in clip.title). how can overlay iframe linkable div ? i'm displaying clips on index page so: <div class="clip-box"> <% if clip.vine_link.present? %> <iframe class="vine-embed" src="https://vine.co/v/<%= clip.vine_link %>/embed/postcard" width="200" height="200" frameborder="0" allowtransparency="false"> </iframe> <% else %> <iframe src="http://instagram.com/p/<%= clip.instagram_link %>/embed/" width="190" height="200" frameborder="0" scrolling="no" allowtransparency="false"> </iframe> <% ...

sql server - How to get count of columns on temp table -

select * information_schema.columns shows columns of tables except temp tables. how can temp tables columns, aggregate table name , count them ? create table #t ( x int, y int ) select * tempdb.sys.columns object_id = object_id('tempdb..#t')

html - Anchor tag on image not working -

i designing web-page include facebook, twitter links profile. have this. <div> <a href="https://www.facebook.com/xyz"> <img src="../images/facebook.gif> </a> </div> and styling is <style> img { height:16px; width:16px; } </style> when run it, get function ajaxrequest(url) { var http_request = false; if (window.xmlhttprequest) { // mozilla, safari,... http_request = new xmlhttprequest(); if (http_request.overridemimetype) { http_request.overridemimetype('text/xml'); // see note below line } } else if (window.activexobject) { // ie //isie=true; try { http_request = new activexobject("msxml2.xmlhttp"); } catch (e) { try { http_request = new activexobject("microsoft.xmlhttp"); } catch (e) {} } } if (!http_req...

alloy - Multiline Comment Parsing Bug -

working latest alloy analyzer available @ website (4.2 build date: 2012-09-25) realized that, when put code between 2 /**/ /**/ <some code> /**/ , code <some code> seems ignored analyzer (although editor seems parse code correctly). for example, in following code snippet declaration of fact ignored analyzer: /**/ fact traces { init [first] d: dinner - last | let d' = next [d] | p,p': philosopher, f: fork | pickleftfork [d,d',p,p',f] } /**/ as put space between /**/ , is, /* */ , code behaves expected. java-style doc comments have been added alloy, in example above, /** token @ beginning starts doc comment, , **/ token @ end closes is, in between parsed comment.

python - Attaching ZMQStream with existing tornado ioloop -

i have application every websocket connection (within tornado open callback) creates zmq.sub socket existing zmq.forwarder device. idea receive data zmq callbacks, can relayed frontend clients on websocket connection. https://gist.github.com/abhinavsingh/6378134 ws.py import zmq zmq.eventloop import ioloop zmq.eventloop.zmqstream import zmqstream ioloop.install() tornado.websocket import websockethandler tornado.web import application tornado.ioloop import ioloop ioloop = ioloop.instance() class zmqpubsub(object): def __init__(self, callback): self.callback = callback def connect(self): self.context = zmq.context() self.socket = self.context.socket(zmq.sub) self.socket.connect('tcp://127.0.0.1:5560') self.stream = zmqstream(self.socket) self.stream.on_recv(self.callback) def subscribe(self, channel_id): self.socket.setsockopt(zmq.subscribe, channel_id) class mywebsocket(websockethandler): ...

c# - Using parameter for StringLength attribute -

the code generated asp.net mvc 3 membership, escpecially property newpassword of class changepasswordmodel looks like: [required] [stringlength(100, minimumlength=6)] [datatype(datatype.password)] [display("name = currentpassword")] public string newpassword { get; set; } in order to fill information external parameters using recourcetype: (in case changing oldpassword , fill attribute display additional data resource [required] [datatype(datatype.password)] [display(resourcetype = typeof(account), name = "changepasswordcurrent")] public string oldpassword { get; set; } back newpassword . how can substitute minimumlenght membership.minrequiredpasswordlength ? : attempt: [required] [stringlength(100, minimumlength=membership.minrequiredpasswordlength)] [datatype(datatype.password)] [display(resourcetype=typeof(account), name= "changepasswordnew")] public string newpassword { get; ...

javascript - How to fire render when a views collection is reset -

i'm starting play around backbone. i've got view associated collection, , want render view when collection syncs server. i've managed collection sync - var mycollection = backbone.collection.extend({ model: backbone.model, url: '/api/cart/lineitem' }); var mycollection = new mycollection(); mycollection.fetch({ success: function() { console.log('fetched ' + mycollection.length + ' objects'); } }); the console shows fetch function works. however i'm getting strange behaviour in view. can't seem render function run. var myview = backbone.view.extend({ el: $('#mini_cart'), carttpl: _.template($('#minicarttemplate').html()), initialize: function() { this.listento(this.collection, 'reset', this.render); this.listento(this.collection, 'reset', console.log('collection reset')); }, render: function(){ console.log('re...

javascript - Export function first and object subsequently -

i have custom module , provide method initialize on first require , directly return object on subsequent requires. but module gets cached when first required , therefore subsequent requires still return init function instead of returning obj directly. server.js: var module = require('./module.js'); var obj = module.init(); console.log('--debug: server.js:', obj); // <-- works: returns `obj`. require('./other.js'); other.js: var obj = require('./module.js'); console.log('--debug: other.js:', obj); // <-- problem: still returns `init` function. module.js: var obj = null; var init = function() { obj = { 'foo': 'bar' }; return obj; }; module.exports = (obj) ? obj : { init: init }; how can work around problem? or there established pattern achieving such? but keep obj cached, because real init work rather not on every require . there ways clear require cache. may check here node.js re...

Redirecting from a JSP to a controller Spring -

i have jsp want use call controller (that's linked jsp page) when url clicked, code follows: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <html> <body> <h1>spring mvc hello world example</h1> <h2>${msg}</h2> <a href="/filemonitor/resultpage/">click</a> </body> </html> the class want call @ /filemonitor/resultpage/ here: @controller @requestmapping(value="/result") public class resultcontroller extends abstractcontroller { @override protected modelandview handlerequestinternal(httpservletrequest request, httpservletresponse response) throws exception { modelandview model = new modelandview("resultpage"); model.addobject("msg", "result"); return model; } } but i'm getting 404, can see i'm doing wrong? how can access controller jsp page? ...

Magento free shipping not working -

i have enabled free-shipping system->configration->shipping methods , , set minimum order amount 50 doesn't work also wonder why condition if($request->getfreeshipping()) return false i had problem myself , stumbled on question. me because cart subtotal not being loaded in freeshipping.php file located in below path. path file: /app/code/core/mage/shipping/model/carrier/freeshipping.php now, copy file: /app/code/core/mage/shipping/model/carrier/freeshipping.php to file location /app/code/local/mage/shipping/model/carrier/freeshipping.php find line has this if (($request->getfreeshipping()) || ($request->getbasesubtotalincltax() >= $this->getconfigdata('free_shipping_subtotal')) and replace this $totals = mage::getsingleton('checkout/cart')->getquote()->gettotals(); $subtotal = $totals["subtotal"]->getvalue(); if (($request->getfreeshipping()) || ($subtotal...

xcode c++ sqlite3 symbol(s) not found for architecture x86_64 -

hi want use sqlite in c++ project in xcode 4 now getting error ld /users/jayb/library/developer/xcode/deriveddata/ems-bpigynlzjbrescadebhoiupqmtkg/build/products/debug/ems normal x86_64 cd /users/jayb/documents/developement/ems/ems setenv macosx_deployment_target 10.8 /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /applications/xcode.app/contents/developer/platforms/macosx.platform/developer/sdks/macosx10.8.sdk -l/users/jayb/library/developer/xcode/deriveddata/ems-bpigynlzjbrescadebhoiupqmtkg/build/products/debug -f/users/jayb/library/developer/xcode/deriveddata/ems-bpigynlzjbrescadebhoiupqmtkg/build/products/debug -filelist /users/jayb/library/developer/xcode/deriveddata/ems-bpigynlzjbrescadebhoiupqmtkg/build/intermediates/ems.build/debug/ems.build/objects-normal/x86_64/ems.linkfilelist -mmacosx-version-min=10.8 -o /users/jayb/library/developer/xcode/deriveddata/ems-bpigynlzj...

Does Flyway support DB2 for zOS? -

does flyway support db2 zos? information here http://flywaydb.org/documentation/database/db2.html seems indicate tested on db2 luw. this has not been tested. please give try , let me know how went! feel free file problems encounter in issue tracker.

javascript - How To Add 'Back' Parameter on Slide Transition? -

i'm using intel's appframework , have code : <div title="welcome" id="login" class="panel" selected="true"> <!-- code here --> <a href="#register" class="soc-btn gray-btn left" data-transition="slide">sign up</a> <!-- code here --> </div <div title="register" id="register" class="panel"> <!-- code here --> <a href="#login" class="soc-btn gray-btn left" data-transition="slide">cancel</a> <!-- code here --> </div> the transition #login #register works charm, page loaded right-to-left. how apply 'slide-back' transition make 'cancel' button on #register load #login left-to-right? i saw on ui/transition/all.js documentation : initiate sliding transition. sample show how transitions implemented. these registered in $ui.availabletransitions , take in 3 para...

iphone - "StopUpdatingLocation" is called but GPS Arrow doesnt disappear -

i don´t understand why gray gps arrow don´t disappear after stopupdatinglocation called. here code: - (void)viewdidload { [super viewdidload]; // additional setup after loading view nib. if (self.locationmanager == nil) { self.locationmanager = [[[cllocationmanager alloc] init]autorelease]; self.locationmanager.desiredaccuracy = kcllocationaccuracybest; self.locationmanager.delegate = self; } cllocation *location = [self.locationmanager location]; cllocationcoordinate2d coordinate = [location coordinate]; g_lat = coordinate.latitude; g_lng = coordinate.longitude; [self.locationmanager startupdatinglocation]; } and here ist didupdatelocation: - (void) locationmanager:(cllocationmanager *)manager didupdatetolocation: (cllocation *)newlocation fromlocation:(cllocation *)oldlocation { nslog(@"core location has position."); cllocationcoordinate2d coordinate = [newlocation coordinate]; global_l...

php - WooCommerce - Sum of product_id values -

i trying sum of specific product_id values in woocommerce assigned bacs payment gateway id. have array product id's , using array_sum sum of product values not working correctly. if lead me in better direction appreciated. add_action('woocommerce_before_cart_total', 'invoice_price'); <?php $available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways(); $product = new wc_product( get_the_id() ); $invoiceitems = array(522, 550, 523); $formatted_total = woocommerce_price( $this->order_total ); function invoice_price( $available_gateways ) { if ( $available_gateways == $gateways['bacs'] ) { foreach($product == in_array($values['product_id'])) { echo array_sum($invoiceitems); } $invoicetotal = $formatted_total - $invoiceitems; } echo $invoicetotal(); } ?> consider following: having array of 100, 200, , 300 add 600. $formatted_total = 5000; i substract $formatted_total $i...

Radio buttons "checked" attribute not working when adding markup dynamically jQuery Mobile 1.3.2 -

i not know if bug, if want generate list of radio buttons dynamically , have 1 selected default following not working changepage() : $(document).on("pagebeforeshow", "#radio", function(e) { html = '<fieldset data-role="controlgroup"><legend>choose pet:</legend><input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" checked="checked" /><label for="radio-choice-1">cat</label><input type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2" /><label for="radio-choice-2">dog</label><input type="radio" name="radio-choice-1" id="radio-choice-3" value="choice-3" /><label for="radio-choice-3">hamster</label><input type="radio" name="radio-choice-1" id="radio-choi...

unicode - Ancient greek roman characters -

i have extracted greek text pdf give me html output : μεταξ˜ last character in old greek font. interesting point here if view in ms-word , select last character font "oldgreekroman" character viewable original form. that baffling me.please help. i need original unicode of last character there no original unicode: character custom glyph in symbol font. has no semantic meaning—it's letter ‘a’ looking peace sign in wingdings. what glyph supposed like? there might or might not unicode character represents same letter. might possible create mapping symbols in “oldgreekroman” font unicode equivalents, or font may characters don't exist in unicode; can't tell without copy of font.

graph - Algorithms for learning user inputs, and for offering suggestions -

i'm searching algorithm respectively method learning user actions (inputs) in program, and, based on built information base of done user actions, offer suggestions future actions user. information base should built actions of multiple users using same software. user actions dependent on order in occur. means, suggestion should made based on done user actions in session. session abstract time period, in user works software. in initial approach, thought of moddeling user actions in directed graph, each node represents unique user action instance. user action, done first time, generates new node. nodes have counter representing how user did user action. transition 1 node exists, when user action done after 1 (modelling sequence of user actions). every transition, probability computed based on counters of subsequent nodes (i.e. nodes, there transition). there root node starting point, directs initial nodes (user actions done first in session). (hidden) markov model, not sure. not...

java - Top Left Coordinates of ImageView in Android displaying incorrectly -

i have imageview in activity, top left coordinates must retrieve can divide the imageview 5 touch zones. use getlocationonscreen these coordinates. the x coordinate fine y coordinate seems faulty reason, there offset , seems point top of window( verified enabling pointer touches in dev tools). here activity code: protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.requestwindowfeature(window.feature_no_title); setcontentview(r.layout.activity_main); amslerview = (imageview) findviewbyid(r.id.amsler_grid); loctext = (textview) findviewbyid(r.id.locationlabel); amslerview.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { switch (event.getaction()) { case motionevent.action_down : startx = (int) event.getrawx(); starty = (int) event.getrawy(); ...

android - How to check which architecture device is using -

i'm using library doesn't support armv6 architecture. want show users toast if armv6 architecture detected. how can this? check class: http://developer.android.com/reference/java/lang/system.html method: public static string getproperty (string propertyname) if think os.arch property you're looking for. log.i("mytag", "os.arch: " + system.getproperty("os.arch"));

jquery - How to select the text from the first <a> tag from each <td> element -

i have table of events, , need event name each. var event_names = new array(); // initialise avoid errors $('td.event_name a', '#the-list').each(function(){ console.log($(this).text()); event_names.push($(this).text()); }); however, fails because there more 1 <a> tag within td.event_name , , need first. i've tried also, i'm getting error $(this).$... not function . var event_names = new array(); // initialise avoid errors $('td.event_name', '#the-list').each(function(){ console.log($(this).$('a:first').text()); event_names.push($(this).$('a:first').text()); }); does know how round this? here source, 1 of <td> elements. cannot see obvioius selectors work off of in code (and cannot change it). <td class="event_name column-event_name"> <label><strong><a title="edit event" href="admin.php?page=dd-options-edit-event&amp;event=126...

actionscript 3 - Flash - How come I do not receive a security warning to allow cross-site requests? -

i using urlloader class send data script sends email data; urlloader used receive return data on status of request. email script located on domain ( webscript.io , in case; host scripts written in lua can perform various functions when called). don't want have them host crossdomain.xml file, when visit page use flash app, don't security warning. not default action when there cross-domain scripting in flash application without crossdomain.xml file? for reference, here application: http://www.canadadocks.ca/build-dock-app/ the cross domain issues data swf retrieving other domains. if you're sending data (via http post/get), not problem. also, unless you're using debug player, won't see security exception occurs. there various things not trigger exception: downloading , displaying image domain. however, if try access bitmap data of image, you'll security exception (unless crossdomain.xml permits it). so can depend on you're retrieving , you...

c# - WebDriver i am trying to use isElementPresent but error shows not exist in the current context -

i new webdriver , writing code in c# visual studio (code snippet below) verifying if text field present on home page using iselementpresent. error name iselementpresent not exist in current context. doing wrong? using system; using system.text; using system.text.regularexpressions; using system.collections.generic; using system.threading; using system.linq; using nunit.framework; using openqa.selenium; using openqa.selenium.firefox; using openqa.selenium.support.ui; namespace homepage_check2 { [testfixture] public class driver { iwebdriver driver; [setup] public void setup() { // create new instance of firefox driver driver = new firefoxdriver(); } [teardown] public void teardown() { driver.quit(); } [test] public void homepage() { //navigate site driver.navigate().gotourl("http://www.milkround.com");...

Difference between scanf("%c", &c) and scanf(" %c", &c) -

this question has answer here: why space in scanf statement make difference? [duplicate] 3 answers consider following c code snippet: #include <stdio.h> int main() { int a; char c; scanf("%d",&a); scanf("%c",&c); printf("int=%d\n",a); printf("char=%c\n",c); } i'm able input integer , not character.the output integer value , no value output second printf statement. however if use space before format specifier: scanf(" %c",&c); it works expected. why case? someone told me has clearing input buffer. shed light on same? the difference between scanf("%c", &c1) , scanf(" %c", &c2) format without blank reads next character, if white space, whereas 1 blank skips white space (including newlines) , reads next character not white sp...

How do I build a CSV with data returned from multiple API calls in Python? -

i'd build csv file combining data multiple api calls. i'm okay basic python, , can call api, extract json data, , write data csv. need efficiently merging data can write out csv once data extraction finished. this data looks straight api request: {u'datetime': u'2011-03-28', u'value': u'2298'}, {u'datetime': u'2011-03-29', u'value': u'2322'}, {u'datetime': u'2011-03-30', u'value': u'2309'}, {u'datetime': u'2011-03-31', u'value': u'2224'}, {u'datetime': u'2011-04-01', u'value': u'2763'}, {u'datetime': u'2011-04-02', u'value': u'3543'}, so i'd looking @ merging lots of together: >apicall1 2011-03-28,2298 2011-03-29,2322 2011-03-30,2309 >apicall2 2011-03-28,432 2011-03-29,0 2011-03-30,444 each api call result looks pretty same: date , value. date formatted same, ou...

r - Passing parameter to function in add.expr inside heatmap.2 -

i'm generating clustering heatmap heatmap.2 function (r gplots package). i'd add vertical line(s) onto image @ variable location(s) using add.expr parameter. for example, xx=replicate(10, rnorm(10)) # random matrix heatmap.2(xx, trace="none", add.expr=abline(v=c(3.5,6.5), lwd=3)) this works great. problem doesn't work if pass lines location variable: lineposition = c(3.5,6.5) heatmap.2(..., add.expr=abline(v=lineposition, lwd=3)) it looks abline function called inside heatmap.2 function , doesn't see external variables. please advice best approach. of course, don't want modify of functions except own. this seems add 2 thick lines: heatmap.2(xx, add.expr=eval( abline(v=lineposition, lwd=3)))

Having problems running my .net project after changing framework to 4.5 from 4.0 -

i opened project , changed it's framework 4.0 4.5 (due stupid firm's restrictions). there mismatch between processor architecture of project being built "msil" , processor architecture of reference "my.dataaccesslayer.dimensiondb", "x86". mismatch may cause runtime failures. please consider changing targeted processor architecture of project through configuration manager align processor architectures between project , references, or take dependency on references processor architecture matches targeted processor architecture of project. this warning. when run anyhow, gives me following errors:- the type or namespace name 'membership' not exist in namespace 'microsoft.aspnet' (are missing assembly reference?) type or namespace name 'membership' not exist in namespace 'microsoft.aspnet' (are missing assembly reference?) etc. i'll highly appreciate assistance. thanks basically, ap...

jquery ajax change div content -

i have page div in an id centeredmenu. when page first loads has menu inside div 10 options. each 1 of these options has different named id such menu2, menu3 , on blank href link. on inital load can change menu, once has completed cannot select other menu , change content of div again new menu my script is <script type="text/javascript"> $(document).ready(function(){ $("#menu2").click(function(){ $('#centeredmenu').load('menu2.php'); }); $("#menu3").click(function(){ $('#centeredmenu').load('menu3.php'); }); $("#menu4").click(function(){ $('#centeredmenu').load('menu4.php'); }); $("#menu5").click(function(){ $('#centeredmenu').load('menu5.php'); }); $("#menu6").click(function(){ $('#centeredmenu').load('menu6.php'); }); ...

Effecient Javascript Object filtering using multiple array indexes. How much data before using Node? -

i'm looking both practical, , theoretical insight application. take 50,000 js objects, 5 properties each, structured as 0: object costcenter: "1174" country: "usa" job: "110-article search" team: "financial" username: "anderson" and take 5 respective arrays (one each object property) such 'country' array 4: array[4] 0: "asia pacific" 1: "australia" 2: "brazil" 3: "canada" what efficient way filter 50,000 objects, eliminating objects have @ least 1 property has 0 matches in respective array. the max sizes arrays are: costcenter, 77 country, 27 job, 27 team, 10 username, 99 my first idea loop through 50,000 objects, , if 'costcenter' property === costcenter array item, push object temporary array of objects which might leave me 20,000 objects in temporary array. repeat process each property , respective f...

Django `if` statement isn't working? -

in template, added following debugging statement: <script> console.log("leaderboard? {{ client_settings.leaderboard_enabled }}"); </script> on console, see: [14:09:20.026] "leaderboard? false" later in code, have following code: {% if client_settings.leaderboard_enabled %} <button data-theme='a' onclick="$('.leaderboard').slidedown();">leaderboard</button> {% endif %} which think cause leaderboard button not appear... does! can see why is? the python value boolean false stringified "false" capital f. since console statement has "false" lowercase f, value of client_settings.leaderboard_enabled string "false" , interpreted boolean true. the pythonic way change use true , false when setting leaderboard_enabled variable, instead of strings "true" , "false" . if not feasible, change template test to: {% if client_settings.leaderboard_ena...

How to apply different width stored in PHP to 3 identical DIVs (using same CSS) -

i have graph has css styling. it's width set in wordpress, need use php apply it. at first have applied width adding inline css in html. worked for few graphs on 1 page. when wanted add responsivness occured inline css overwriting mediaquries , breaking responsivness. decided applying php variables directly css in way described here: http://css-tricks.com/css-variables-with-php/ the problem when following situation happens: i have rule: .graph { width: <?php echo $graph-width; ?>; } i have 3 graphs on 1 page using class. each graph has different width specified in wordpress admin panel. how apply different widths stored in php 3 graphs on page. please note never know how many graphs on 1 page. i don't have time test here's approach might work. have divs created class contains incrementing numbers, ie. container-1, container-2, container-n. then jquery this: var = 1; function widthadder() { if(i % 2 === 0) { //this every ...

android - Trouble with making a method into an AsyncTask -

i'm have frustratingly tough time figuring out. guess i'm not understanding how correctly assemble asynctask. have method in class want run asynctask instead of bogging down when gets called. can help? in advance. private void getdatesnames() { jsonparser jparser = new jsonparser(); jsonobject json = jparser.getjsonfromurl(url); arraylist<string> dates = new arraylist<string>(); arraylist<string> teams = new arraylist<string>(); try { contacts = json.getjsonarray(tag_contacts); for(int = 0; < contacts.length(); i++){ jsonobject c = contacts.getjsonobject(i); if ((c.getstring(tag_email1)).contains(league)) { // storing each json item in variable string id = c.getstring(tag_id); string email1 = c.getstring(tag_email1); string email2 = c.getstring(tag_email2); dates.add(id); teams.add(email1); teams.add(email2); } }...

java - Custom JOptionPane Icon -

Image
java's "how make dialogs" tutorial shows code: //custom title, custom icon joptionpane.showmessagedialog(frame, "eggs not supposed green.", "inane custom dialog", joptionpane.information_message, icon); which create following dialog: why joptionpane.information_message needed when icon changed icon parameter? the flag indicates message style use on window decorations, see http://nadeausoftware.com/node/91#usinglookandfeelspecificwindowdecorations from joptionpane class source code: private static int stylefrommessagetype(int messagetype) { switch (messagetype) { case error_message: return jrootpane.error_dialog; case question_message: return jrootpane.question_dialog; case warning_message: return jrootpane.warning_dialog; case information_message: return jrootpane.information_dialog; case plain_message: default: return jrootpane.plain_dialog; } }...

ruby on rails - jQuery function works in partial but not show -

Image
i have jquery code counts current rows in table (and arithmetic) , adds them column. i've used script in _form/_partial , works great. however, when use same script inside show.html.erb (to setup same table again) not work. here _form <table id="mytable"> <th>rownumber</th> <th>header2</th> <th>header3</th> <th>header4</th> <%= f.nested_fields_for :partial |f| render 'partial', f: f end -%> <caption align = "bottom"><%= link_to_add_fields "add field", f, :manual_iops %></caption> </table> _partial.html.erb <tr> <td> <!-- nothing goes here --> </td> <td> <%= f.text_field :data1 %> </td> <td> <%= f.text_field :data2 %> </td> <td> <%= f.text_field :data3 %> </td> </tr> <script>...

c - Strange behaviour when using pointers -

i have file binary data follows. aa 55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 55 aa 55 36 65 fb 5f 1e 92 d8 1b 55 f7 fb 5f 1e 92 d8 1b i want extract values 55 36 65 fb 5f 1e . if use following code. temp_1 = (data_ptr[offset]); val = temp_1 << 40; temp_1 = (data_ptr[offset + 1]); val |= temp_1 << 32; temp_1 = (data_ptr[offset + 2]); val |= temp_1 << 24; temp_1 = (data_ptr[ts_offset + 3]); val |= temp_1 << 16; temp_1 = (data_ptr[ts_offset + 4]); val |= temp_1 << 8; temp_1 = (data_ptr[ts_offset + 5]); val |= temp << 0; printf("read value %"prix64" \n",val); the outupt of printf 3665fb5f1e92 now try calculate same value using single 64-bit ptr cast operation. val = *(uint64_t*)(data_ptr + ts_offset); printf("read value %"prix64" \n",val); the output of above code 1bd8921e5ffb6536 if check least significant 48-bits here 921e5ffb6536 it inverted compared fi...

go - Golang concurrency: how to append to the same slice from different goroutines -

i have concurrent goroutines want append (pointer a) struct same slice. how write in go make concurrency-safe? this concurrency-unsafe code, using wait group: var wg sync.waitgroup myslice = make([]*mystruct) _, param := range params { wg.add(1) go func(param string) { defer wg.done() oneofmystructs := getmystruct(param) myslice = append(myslice, &oneofmystructs) }(param) } wg.wait() i guess need use go channels concurrency-safety. can contribute example? there nothing wrong guarding myslice = append(myslice, &oneofmystructs) sync.mutex. of course can have result channel buffer size len(params) goroutines send answers , once work finished collect result channel. if params has fixed size: myslice = make([]*mystruct, len(params)) i, param := range params { wg.add(1) go func(i int, param string) { defer wg.done() oneofmystructs := getmystruct(param) myslice[i] = &oneofmystructs ...