Posts

Showing posts from May, 2013

python - App as foreign key -

so , have django project 2 apps ├───blog post comment └───user profile user (basic authentification , profile dashboards) blog (having basic blog models : post,comment) i need give users possbility create 1 or more blogs within same project, don't see how can treat app model. the solution figured out , add foreign key user id every model withn blog app.but there better way ? i think should that: # blog/models.py class blog(model): owner = foreignkey(user, related_name="blogs") name = charfield() class post(model): blog = foreignkey(blog, related_name="posts") #other fields ... class comment(model): post = foreignkey(post, related_name="comments") #other fields ...

objective c - How to retrieve proxy password stored in iOS -

in os x can retrieve username , password proxy using keychain function seckeychainfindinternetpassword . in ios there cfnetworkcopysystemproxysettings , cfnetworkcopyproxiesforurl return proxy hostname , username, not password. how can retrieve proxy password stored in user settings in ios?

authentication - How to configure Jenkins login with google apps -

i had installed jenkins in ubuntu machine , making build successfully. want have authentication of google apps. feel better, searched plugin respective this, can't find it. whether can attained means of plugin or otherways? please let me know ways do. in advance you can achieve single sign on google apps using openid plugin . it's easy set up, install plugin, select "google apps sso (with openid)" , enter domain. note users will have have google apps account login after that. tip: might consider using in combination role strategy plugin

android - ListView "coming back" when scrolling -

i'm getting strange behavior in listview, , 1 listview, have lot of listviews in app, in happening. i try explain, when scroll bottom, right, scrolls go , stop in end. when scroll top, it's scroll splash in top , come bottom. i have this video showing problem. this xml of listview: <listview android:id="@+id/lv_resultado_produtos" android:layout_width="fill_parent" android:layout_height="fill_parent" android:divider="@color/black" android:dividerheight="1dip" android:fastscrollenabled="true" android:scrollx="0dip" android:scrolly="0dip" android:scrollbarsize="22dip" android:scrollbarstyle="outsideoverlay" /> and programmatically set adapter customadapter, nothing more. i tested in others listviews , didn't behavior. i glad if me on this. [edit] here adapter, it's little complex, sorry, tried keep have li...

configuration - Rails 4, reload lib/ directory in developer mode -

what add configuration in rails 4 reload lib/ directory if file changed in developer mode? the best way extend classes coding gem. if dont want code gem because effort oversized can monkeypatch classes placing code in initializers folder. both wont solve problem because gems , initializers loaded once. when want code reloaded after every change have place in app directory. place code in helper includes in classes want extend.

Git: what exactly causes remote branches to update? -

according pro git (3.5): [remote branches are] local branches can’t move; they’re moved automatically whenever network communication. however, doesn't seem correct in practise. i've arrived @ situation branch ahead of 'origin/branch-x' 23 commits. but haven't done commits, fetched /pulled modifications other people have pushed origin. if statement of pro git correct expect remote branch same local one, since every fetch or pull communication origin. what exact operations update remote branches? i suspect issue might rooted in special twist git pull has in semantics — let's cite git pull manual: some short-cut notations supported. ... parameter <ref> without colon equivalent <ref>: when pulling/fetching, merges <ref> current branch without storing remote branch anywhere locally this means when do git pull or git pull origin (which rely on branch.<name>.remote , branch.<name>.merge...

regex - Creating a keyword based search in python -

i have giant csv file close 6k entries , file looks this: pdb id ndb id structure title citation title abstract 1et4 1et4 structure of solution structure research performed , haemoglobin mrna of mrna aptamer structure of mrna obtained aptamer. my end goal display output given keyword so: keyword: mrna pdb id ndb id structure title citation title abstract location of first hit struc/citation/abstract what starting point me? also, have use called regex this? disclaimer: part of research project, not school homework. a pseudocode or template great me. you parse csv file , create 2 data structures. both dictionaries. one dictionary contain each line, keyed on pdb id . other dictionary store sets of pdb id s , keyed on keywords. below example code because i'm ignoring headers. want parse csv properly... from collections import defa...

Mahout Recommendation performance issues -

i have been working mahout create recommendation engine based on following data: 100k users 10k items 4m ratings i'm running on tomcat following jvm arguments : -xms1024m -xmx1024m -da -dsa -xx:newratio=9 -server recommendations took 6s, seems slow ! how improve mahout performances ? i'm using following code : this part run once @ startup : jdbcdatamodel jdbcdatamodel = new mysqljdbcdatamodel(datasource); datamodel = new reloadfromjdbcdatamodel(jdbcdatamodel); itemsimilarity similarity = new cachingitemsimilarity(new euclideandistancesimilarity(model), model); samplingcandidateitemsstrategy strategy = new samplingcandidateitemsstrategy(10, 5); recommender = new cachingrecommender(new genericitembasedrecommender(model, similarity, strategy, strategy)); and, every user request : recommender.recommend(userid, howmany); i suggest different approach. use nightly job, pre-calculate recommendations users, , load results nightly mysql table. make sho...

Emacs not loading package at startup -

emacs not load package window-number have following in .emacs file: ;;;windows (require 'window-number) (window-number-mode) however, once emacs started if type: m-x load-file return .emacs window-number-mode loaded. what going on here , why won't window-number load on startup? note downloaded window-number elpa edit window-number-mode works, won't start when emacs starts. have type m-x window-number-mode . tried inserting (window-number-mode) .emacs file did not fix problem. if loaded package elpa, make sure have (package-initialize) before use package. function (among other things) updates load-path include directories of downloaded packages. the "require" might unnecessary, elpa packages typically have autoloads, makes no harm.

java - Hibernate query not finding "pending" entites in same transaction -

i've got app importing data manytomany structure. @table(name="content") class content { @column(.., unqiue=true) string str; } @table(name="group") class group { @jointable("group_content"..) list<content> contentlist; } the content has unique column str (as seen above) used app identify content exist in database - , if re-use entity rather adding again. this done findbystr(string str) method in contentdao implementation. it's implemented namedquery ( from content c c.str = :str ). when run import both groups , content new , groups refeer same (new) content seem findbystr query returns null . the query works fine outside of scenario seems when content objects has been created, not committed, query not detect them. currently work around i'm keeping map<string, content> double check against if query returns null . hibernate not execute insert statements...

sorting - Orderby() on observablecollections in silverlight does not work -

my code is, destmenu.add(selectedmenu); observablecollection<menumodel> temp = (observablecollection<menumodel>)destmenu.orderby(p =>(p.menuname)); destmenu = temp; here, selectedmenu new item added collection. temp dummy collection swap. and, when try convert sorted collection, if any, observablecollection, throws exception. can me sort collection , make me understand problem in code? thanks manikandan i got trick. destmenu.add(selectedmenu); ienumerable<menumodel> temp = destmenu.orderby(p =>(p.menuname)); destmenu = new observablecollection<menumodel>(temp); this works , destmenu has sorted collection now. thanks manikandan

javascript - How can I compute a dragged div's position -

http://jsfiddle.net/prince4prodigy/vr2du/7/ the jsfiddle edited, please see again. how can compute dragged div's position? if re-size window can see 'left' & 'top' property of div if drag div, 'left' & 'top' property don't computing (real time) htnl: <div id="container" class="container-container-fluid"> if drag div, 'left' & 'top' property dont computing (real time) <div id="div1" class="item drag">div</div> </div> <div id="left"></div> <div id="right"></div> js: $(function(){ $( ".drag" ).draggable({ containment : '#container' }); function wresize() { var winw = $(window).width(); var body = $('body'); var d = $('#div1').position(); $('#div1').css({ posit...

why my cannot edit/update database using PHP? -

here code. in code, when edit , "update" data in database using php, doesn't change data in database or myphpadmin. take @ below code: <?php include("dataconn.php"); //connect database external php. if($_session["loggedin"]!="true") header("location:admin_login.php"); $aid=$_session["userid"]; $admin_info="select * admin ad_id='".$aid."'"; if(isset($_post["savebtn"])) { $adname=$_post["name"]; $adaddress=$_post["address"]; $ademail=$_post["email"]; $adcontact=$_post["contact"]; mysql_query("update admin set ad_name='".$ad_name."',address='".$adaddress."',email='".$ademail."',contact_num='".$adcontact."' ad_id=$aid"); header("location:profile.php"); } ?> <body> <form name=...

ruby on rails - Rspec Controller Test No Route Matches Error -

rspec not recognising controller routes. using versionist gem version api , using path version (so /v1/ version api shown below.). constraints :subdomain => "api" api_version(:module => "v1", :path => {:value => "v1"}, :defaults => {:format => :json}, :default => true) match '/orders' => 'orders#index', :via => :get the route in rake routes shown as: get /v1/orders(.:format) v1/orders#index {:subdomain=>"api", :format=>:json} my controller located in app/controller/v1/orders_controller.rb . for rspec test, have orders_controller_spec.rb , have: require 'spec_helper' module v1 describe orderscontroller describe "get #index" "throws error on incorrect params" :index end end end end the error is: 1) v1::ordersapicontroller #index throws error on incorrect param failure/error: :index actioncontroller::routing...

knockout.js - Knockout JS - display template based on clicked link -

i have single page application mocked data. displaying unordered list. list nested. when click on item in list depending on item clicked sets 2 properties in vm, either "selectedlayer" or "selectedprogramme". layer nested under programme. when layer clicked call function sets "selectedprogramme" parent - fine point. want display different content based on type of layer. have 3 templates want show 1 one template based on value of "layertype" of "selectedlayer". hopefully clear - have put code in following jsfiddle: http://jsfiddle.net/azvbr/9/ typically can't data display in fiddle, can see have following html determine layer type , somehow use correct template: <div id="layerdetails" data-bind="template: { name: $root.displaylayertype }"> </div> i did try passing 2 parameters, programme object , $data wasn't sure doing. any assistance appreciated. edit : changed js fiddle link w...

parsing - How to convert multiple lists to dictionaries in python? -

['*a*', '*b*', '*c*', '*d*', '*f*','*g*'] ['11', '22', '33', '44', '', '55'] ['66', '77', '88', '', '99', '10'] ['23', '24', 'sac', 'cfg', 'dfg', ''] need put in dictionary as: {a : ('11','66','23'),b : ('22','77','24'),c : ('33','88','sac'),d :('44','','cfg')} the rows read csv file: import csv csvfile = csv.reader(open("sach.csv", "rb")) row in csvfile: print row code tried shown above, output of row shown above has many lists. please me put in dictionary format shown above. zip rows: with open("sach.csv", "rb") csv_infile: reader = csv.reader(csv_infile) yourdict = {r[0].replace('*', ''): r[1:] r in zip(*read...

c# - What does 'value type that is initialized to all 0's' mean? -

i wondering sentence in book c# i'm reading currently. sentence is: 'value type initialized 0's'. probably don't understand because i'm not native speaker. in understanding of language mean variable has multiple values when gets initialized? doesn't makes sense me. me understand means? consider value type: public struct point { public int x; public int y; } "all 0's" here means x = 0 , y = 0. update: discovered example used in msdn documentation struct . throw in constructor.

How do I implement this java pattern in JavaScript (using inheritance)? -

here working java code provide base engine class handles balance listener registration, number of engine implementations used various games. e.g. there demo engine maintains demo balance demo game , cash version of same engine gets balance office etc. crux here not actual java, how implement kind of pattern in javascript. have tried 30 different ways it, including using john resigs "simple javascript inheritance" , extend() sugar defined in "javascript: definitive guide", using various module patterns, using that=this etc. none of worked problem. here working java code: file engine.java: package com.test; public abstract class engine { balancelistener externalbalancelistener = null; double balance = 0; public void registerbalancelistener(balancelistener balancelistener) { externalbalancelistener = balancelistener; balancelistener.update(balance); // call once when first register } public double getbalance() { ...

html - Extra padding only in Chrome -

Image
i strange padding in h3 tag in chrome. strangest thing can't prevent or control through css , when select text of h3 seems selection expands right , bottom of text. preview in chrome: preview in other browsers: this padding in chrome causes misalignments , expands height of container, undesired. here's fiddle . can please me locate problem? note: use css reset, tried line-height , margin instead of padding no luck. try adding line-height: 0; div: #mailing div { line-height: 0; } try adding: #mailing .moduletable { display: table; } updated jsfiddle: http://jsfiddle.net/bbjhe/12/

javascript - Button clicks count as pageviews -

my client has single page website , want each click on main menu site area count pageview in google analytics. possible? advised him use events. yes, call _trackpageview in javascript. _trackpageview() _trackpageview(opt_pageurl) main logic gatc (google analytic tracker code). if linker functionalities enabled, attempts extract cookie values url. otherwise, tries extract cookie values document.cookie. updates or creates cookies necessary, writes them document object. gathers appropriate metrics send ucfe (urchin collector front-end). async snippet (recommended) https://developers.google.com/analytics/devguides/collection/gajs/methods/gajsapibasicconfiguration#_gat.ga_tracker_._trackpageview

asp.net mvc - How to detect a shutdown and run code before shutdown execution in MVC .NET -

i have web server cluster (windows 2008) collects usage data clients. servers batch data , send after time or amount of data. problem using aws auto-scaling, , machine can shut down @ time. detect shutdown event , send usage data database before application killed. know if possible? i say, can perform these tasks (in code/ yourself) when server goes up. otherwise here http://social.technet.microsoft.com/forums/windowsserver/en-us/bd8ea190-9bf4-4915-8ed9-96ee5d6f336a/when-are-windows-server-20032008-shutdown-scripts-run-in-the-shutdown-process

php - Use twitter bootstrap span in foreach -

how use twitter spans within foreach loop? this code: <div class="row-fluid"> <?foreach ($photos $photo) { ?> <div class="span4"> stuff </div> <? }?> </div> but problem 4th output (which on 2nd row) off center - due margin/padding left. i'm trying avoid having add counter , manually insert new 'row' after each 3rd loop - surely there cleaner way via bootstrap/css? by using css3's nth-child selector, can target elements using math. .span4:nth-child(3n+1) { /* css here */ } the 3n+1 math function n incrementing 1, target elements #1 (3x0 + 1), #4 (3x1 + 1), #7 (3x2 + 1), etc.

enums - C# byte find string representation of all bits set/not set -

sorry if repeat question, tried searching couldn't find relates problem. i have byte value in each bit (or group of bits) means something. have enum custom attribute define bits, so: [flags] public enum config4 { [stringvalue("enable good-read beep")] goodreadbeep = 1 << 0, [stringvalue("low beeper volume")] lowbeep = 1 << 1, [stringvalue("medium beeper volume")] mediumbeep = 1 << 2, [stringvalue("low beeper frequency")] lowfrequency = 1 << 3, [stringvalue("medium beeper frequency")] mediumfrequency = 1 << 4, [stringvalue("medium beeper duration")] mediumduration = 1 << 5, [stringvalue("long beeper duration")] longduration = 1 << 6, [stringvalue("reserved")] reserved = 1 << 7 } the catch apart these individual definitions, pairs (or groups) of bits defined else. example, (lowbeep | m...

jquery - JavaScript: Memory leak on canvas (not in Chrome) -

i'm trying draw gradient lines on canvas, using jcanvas plugin , jquery code leads memory leak in firefox (reserved ram increases infinity). internet explorer deals ram usage quite whole thing incredibly slow. google chrome displays canvas without lag. tell me doing wrong? parts of code: declarations: var i, i1, i2, p; var r=[], g=[], b=[], a=[]; var gradient=[]; var w=$("body").width(); var w2=math.floor(w/2), w3=w2-1; var h=$("body").height(); drawing: function draw() { $('#bg').clearcanvas(); (i=0; i<w2; i++) { $('#bg').drawline({ strokestyle: gradient[i], strokewidth: 2, x1: i*2, y1: 0, x2: i*2, y2: 700, }); } } recalculating values of lines colours function mixer() { (i=0; i<w2; i++) { p = math.random(); if (p<0.997) { i1 = (i>1)?i-1:w3; i2 = (i<w3)?i+1:0; r[i] = math.floor(( r[i1] + r[i2] ) / 2); ...

Parsing C switch-case and for Statement in AWK -

how parse switch-case statement below awk? want create simple c syntax checker awk. checker must read code , return whether there syntax error or not. if there is, awk should print error on it. switch(number) { case 1 : number = 'a'; break; case 2 : number = 'b'; break; default : number = 'x'; } and for() statement, this: for(i=0;i<10;i++) { number = 'a'; } my current code switch-case statement was: #parser_switchcase.awk { for(i=1; i<=nf; i++) { if($i~/switch\([[:alnum:]]+\)/) print("switch(valid_variable)") } } result first c switch-case code above: master@master:~/dokumen/root$ awk -f parser_switchcase.awk soalswitch switch(valid_variable) but needs many improvements. not complete. i need awk suggestion reading , checking code examples have typed above. exactly, need awk parsing code those, not outside possibility such additional function, additional code, mentioned on co...

ruby - Heroku App Crash H10 - bash: bin/rails: No such file or directory -

this question has answer here: “bin/rails: no such file or directory” w/ ruby 2 & rails 4 on heroku 7 answers i having issue deployment. test env locally works great no errors. when push heroku this: 2013-07-17t15:54:04.619297+00:00 app[web.1]: bash: bin/rails: no such file or directory 2013-07-17t15:54:07.240398+00:00 heroku[web.1]: process exited status 127 2013-07-17t15:54:07.255379+00:00 heroku[web.1]: state changed starting crashed 2013-07-17t15:54:13.467325+00:00 heroku[web.1]: error r99 (platform error) -> failed launch dyno within 10 seconds 2013-07-17t15:54:13.467325+00:00 heroku[web.1]: stopping process sigkill 2013-07-17t15:54:58.714647+00:00 heroku[router]: at=error code=h10 desc="app crashed" method=get path=/ host=radiant-thicket-1062.herokuapp.com fwd="174.4.33.188" dyno= connect= service= status=503 bytes= i unsure calli...

Connecting to a MySQL DB from a WPF app -

i have been trying connect c# wpf app mysql database. database on linux machine in network. have lot of experience connecting php have never done .net product. have read through have found online. have downloaded , installed mysql connect stuff , attached project. have gone db , made sure accept queries work pc using phpmyadmin. have tried wide variety of code call db. have changed order of in connstr. have changed labels , formatting try have come across. able connect db of web based tools tie app know have right info. have never posted on here sorry formatting. have read make sound quite straightforward. , using this: string connstr = "user=admin;database=test;server=192.168.0.37;password=******;"; mysqlconnection conn = new mysqlconnection(connstr); try { console.writeline("trying connect to: ..." + connstr); console.writeline("connecting mysql..."); conn.open(...

Cakephp sending UTF-8 Emails and lineLength -

i'm trying send emails utf8 characters. email looks how suspect, randomly there garbage characters. believe garbage characters happen when new line inserted in middle of 1 of characters. suspect cakephp's email component culprit since reading has feature insert new lines according linelength property. there way fix this? i'm using cakephp 1.3. $this->email->to = $sendemail; $this->email->from = empty($this->data['contact']['email']) ? $sendemail : $this->data['contact']['email']; $this->email->subject = $subject; $this->email->sendas = 'text'; $this->email->template = 'contact' $this->set('fields', $this->data['contact']); $this->email->charset = "utf-8"; $this->email->headercharset = "utf-8"; return $this->email->send(); from email header: content-type: text/plain; charset=utf-8 content-transfer-encoding: 7bit ...

ruby on rails - How can I get instance method parameters? -

i'm trying retrieve parameters couple instance methods. idiomatic ruby way so: class def test(id) puts id end end a.instance_method(:test).parameters #=> [[:req, :id]] this approach works of time, strange returns methods , have no idea why. module events class repository def find(id) #code end def delete(id) #code end end end events::repository.instance_method(:find).parameters #=> [[:req, :id]] events::repository.instance_method(:delete).parameters #=> [[:rest, :args], [:block, :block_for_method]] is ruby bug? note: i'm typing above rails console. i don't know why getting behavior, if answer questions earlier comment can figure out. however, answer question can not bug in ruby. here example of small ruby program give same kind of output getting: module x def delete(*args, &block) end end class y prepend x end class y # reopen existing class def delete(x) end end p y.inst...

jquery - My nested slider isn't displaying the images -

i'm having issue displaying slider inside of main slider. have linked correctly , seems functioning correctly except fact images won't display. i'm pretty sure it's not z-index issue because have checked using firebug. link: http://toughguppyproductions.com/2013 the slide i'm referring 4th circle computer icon called "graphic design". when click on you'll see slide i'm referring to. on right of slide you'll see 2 arrows slider dots displaying how many images in slider. please help, i've been racking brain week trying figure out. theres inline css height: 1px;width: 1px; in #featured div. :)

How do I get jQuery to re-render a partial from Ruby and then place it in a div? -

i have button looks this: <%= link_to "join", "#", :id => "joinleave", :class => "buttonrefresh small join button expand", :'project-id' => @project.id %> i have jquery called when gets clicked. changes text in button , button function , that, need re-render partial ruby <div> . <div class="content" id="peoplerender" data-section-content> <%= render 'people' %> </div> the .js in "assets/javascript" , view in "apps/views/projects". partials in same folder , work fine when page loads. need update when button pressed. using jquery, have ajax return update $(".content") : your controller def show @people = whatever_people_logic_you_already_have respond_to |format| format.html format.json render :json => @people.to_json, :layout => false end end end your ajax : $.ajax({ url: your_...

jquery - Cross Domain AJAX Request IE Issue -

if($.support.opacity == false && window.xdomainrequest) { var xdr = new xdomainrequest(); alert(ajaxstatusurl); xdr.open("get", ajaxstatusurl); xdr.onload = function () { alert(1); var json = $.parsejson(xdr.responsetext); if(json == null || typeof(json) == undefined) { json = $.parsejson(data.firstchild.textcontent); } processdata(json); }; xdr.send(); } else { alert(2); $.ajax({ type: "get", url: ajaxstatusurl, processdata: true, data: {}, datatype: "json", success: function (data) { processdata(data); } }); } have couple of issues 1. in browserstack ie 9 $.support.opacity alerting true when should false 2. major issue when run code in ie 7 or 8 xdr.onload function not fire. please not header in backend set allow origin. can cross domain requests via ajax pl...

iphone - Horizontally repositioning a UIBarButtonItem -

is possible reposition uibarbuttonitem that's in uinavigationbar horizontally? i've seen barbuttonitem setbackgroundverticalpositionadjustment:forbarmetrics: method (but that's vertical positioning), , know how if make custom button, how take uibarbuttonitem style uibarbuttonitemstylebordered , horizontally reposition (that is, move left or right)? thanks in advance! you can create fixed size button 'filler' , add beside existing button: uibarbuttonitem *fixedspace = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemfixedspace target:nil action:nil]; (then set width desired value)

Nginx overwrites general symfony errors with 502 Bad Gateway -

when try access non-existing route or make mistake inside twig template, instead of getting symfony error page debug information, redirected default nginx 502 bad gateway. the log shows interesting line: 013/07/17 16:11:41 [error] 16952#0: *187 upstream sent big header while reading response header upstream, client: 127.0.0.1, server: ftwo.localhost, request: "get /heasd http/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "ftwo.localhost" any ideas? increase buffer size in nginx configuration , restart nginx afterwards suggested here . proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; further increase fastcgi buffer in php section of configuration ( location ~ .php$ ) fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; referenced answer question codeigniter user here .

jquery - How do i get the image dimensions (height, width) from a file by using javascript -

i being very stupid. cant work life. trying set imgwidth same width image width of file (pic_real_width). function calculate() { var pic_real_width, pic_real_height; $("<img/>").attr("src", $("#pp_photo_popup")[0].src).load(function() { pic_real_width = this.width; // note: $(this).width() not pic_real_height = this.height; // work in memory images. }); var imgwidth = } all in trying make function real dimensions of file on hard disk. bind load event first, , processing needs image loaded inside of load event. function calculate(callback) { $("<img/>").load(function() { var pic_real_width = this.width; // note: $(this).width() not var pic_real_height = this.height; // work in memory images. callback(pic_real_width,pic_real_height); }).attr("src", $("#pp_photo_popup")[0].src); } calculate(function(width,height) { console.l...

datetime - how to create a date object in python representing a set number of days -

i define variable datetime object representing number of days entered user. example. numdays = #input user deltadatetime = #this i'm trying figure out how str(datetime.datetime.now() + deltadatetime) this code print out datetime representing 3 days today if user entered 3 input. idea how this? i'm lost effective approach problem. edit: because of how system set up, variable storing "deltadatetime" value must datetime value. said in comments, 3 days becomes year 0, january 3rd. it's straightforward using timedelta standard datetime library: import datetime numdays = 5 # heh, removed 'var' in front of (braincramp) print datetime.datetime.now() + datetime.timedelta(days=numdays)

javascript - Execute a script in phantomjs interactive (REPL) mode -

this question has answer here: phantomjs: page.open() not respond when running in repl 1 answer i have file runs , prints output screen when run in phantomjs non-interactive mode $ phantomjs file.js <stuff printed screen> in phantonjs interactive (repl) mode there way run js file, run('file.js') . want open phantomjs pipe , send multiple files execute before closing pipe save on startup overhead. looks repl mode borked , and overhaul underway: https://github.com/ariya/phantomjs/issues/11180

java - JPA - @OneToMany with JoinTable -

i hope can explain first attempt. have 2 entities: person , address. 1 person can have many addresses, person entity composed of list of addresses. note addresses can shared among different people, address entity not need reference person entity. also, each address entity have rank attribute. my table structure follows: person ( person_id, etc, primary key (person_id) ) address ( address_id, etc, primary key (address_id) ) person_address_map ( person_id, address_id, rank, foreign key (person_id) references person (person_id), foreign key (address_id) references address (address_id), primary key (person_id, address_id, rank) ) given above, i'm not sure how annotate list of addresses in person, or rank attribute in address. suspect person follows: @entity public class person { @onetomany(cascade = cascadetype.all, fetch=fetchtype.eager) @jointable(name="person_address_map", joincolumns=@joincolumn(name="person_id"), inver...

What kind of array is this in JavaScript? -

i have array looks this: var locationsarray = [['title1','description1','12'],['title2','description2','7'],['title3','description3','57']]; i can't figure out type of array is. more importantly, i'm gonna have create 1 based on info there. so, if number on end greater 10 create brand new array in same exact style, title , description. var newarray = []; // guess if(locationsarray[0,2]>10){ //add newarray : ['title1','description1'],['title3','description3'] ? } how can it? try below, var newarray = []; (var = 0; < locationsarray.length; i++) { if (parseint(locationsarray[i][2], 10) > 10) { newarray.push([locationsarray[i][0], locationsarray[i][1]]); } } demo: http://jsfiddle.net/ct6nv/

wix - Preventing uninstallation of DIFxApp-installed drivers -

i’m creating installer software application interfaces hardware device. hardware device uses ftdi usb serial interface . need install ftdi usb drivers (if user doesn’t have them) along software, , i’m using wix , difxapp extension accomplish this. so far, good. works fine. have separate msi packages software , 32-bit , 64-bit flavors of drivers, , i’m using burn bundle them single installer. driver msi packages deploy driver files subdirectory of application installation folder, , difxapp installs drivers appropriate system locations there. (which seems silly – they’re used during install; why keep them hanging around after that? a copy kept in system driver store, after all. preferable extract them temporary folder, install drivers, , clean them up. evidently, that’s way difxapp works .) but ftdi chipset used lot of different devices, , user own other devices require ftdi drivers. in testing, have found difxapp uninstalls drivers when software uninstalled. undesi...

asp.net - how do you pull XML data from a C# file -

if have xml data in c# file, instead of using setxmlurl(/blah.blah.xml); retrieve xml information xml file, function or code need pull xml data c# file used in asp.net? this code is: mychart.setxmlurl("/controls/taskorder/tasksummary.asc/tasksummary.ascx.cs"); i rendering chart in setxmlurl(""); area data being read from. xml file this: mychart.setxmlurl("data/data.xml"); but since xml data appended in c# file, can't use setxmlurl since not referencing xml directly. here updated @ code behind: public void setline3chart(dataset exdt) { stringbuilder xmldata = new stringbuilder(); xmldata.append("<chart caption='current period: total months: 12' chartbottommargin='8' charttopmargin='04' captionpadding='01' xaxisnamepadding='-20' yaxisnamepadding='05' chartrightmargin='20' showborder='0' yaxisname='' xaxisname='' numberprefix=...