Posts

Showing posts from June, 2013

ruby on rails - Installing mysql2 gem - HAVE_UINT (ushort, uint type redefinition errors) -

yes, yet question installing mysql2 gem use in ruby on rails. it's error haven't been able find listed in question. i've got 64 bit mysql , rvm installed on os x mountain lion. when trying install mysql2 gem, keep getting error make redefinition of ushort , uint in mysql2_ext.h. found file in couple of different places (apparently cached, because changing file did nothing when reran gem install mysql2 command) , found these lines in it: #ifndef have_uint #define have_uint typedef unsigned short ushort; typedef unsigned int uint; #endif it indeed trying redefine ushort , uint though still has them. how tell symbols defined? turns out there's way specify cflags force recognize have_uint definition. not (apparently gem installation manages ignore environment variables set way): sudo env cflags="-dhave_uint" gem install mysql2 see this question how this: gem install mysql2 -- --with-cflags=\"-dhave_uint\"

python - Why only some Tkinter callback functions need to have an argument but others don't -

i'm using python 2.7, if matters. here code wrote fun: def p(): root = tk() def cmd(event): print int(slider.get()) slider = scale(root, orient = "horizontal", from_ = 0, = 100, command = cmd, state = "disabled") def enable(): slider.config(state = "active") b = button(root, text = "enable slider", command = enable) b.grid() slider.grid(row = 1) root.mainloop() for code, i'm wondering why command scale requires event, button not. seems widgets in tkinter commands need have "event" argument, , other don't. why? how distinguish them? thanks. scale doesn't take event. takes current value. try this: def cmd(value): print int(value) if read tk tutorial , explains this: there "command" configuration option, lets specify script call whenever scale changed. tk automatically append current value of scale parameter each time invok

java - Editing an alert dialog inside an on-click listener -

the following alert dialog has title , 4 items (i.e red, green, blue , black). change icon every time 1 of these items selected. here's code: final alertdialog.builder alertdialog = new alertdialog.builder(this); final charsequence[] items = {"red", "green", "blue", "black"}; alertdialog.settitle("pick color"); alertdialog.setsinglechoiceitems(items, 1, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface arg0, int num) { switch(num) { case 0: alertdialog.seticon(r.drawable.red); break; case 1: alertdialog.seticon(r.drawable.green); break; case 2: alertdialog.seticon(r.drawable.blue); break; case 3: alertdialog.seticon(r.drawable.black); break; } } }); i can attest fact .seticon() methods being called; there no changes made aesthetics of alert dialog. effecti

vb.net - How to write this LINQ/EF query? -

so have entity framework 5 model includes many-to-many relationship. categoryvalues --< coursecategoryvalues >-- courses i have linq query selects every course in database. modify select courses belong specific categoryvalue . attempt far has failed? can me figure out? this have tried: using database sitedatacontext = new sitedatacontext database.configuration.proxycreationenabled = false database.courses.include("classes") database.courses.include("coursecategoryvalues") query = (from c in database.courses select c order c.name).where( function(c) 0 < c.classes.where(function([class]) [class].status.tolower = "open").count ).include(function(r) r.classes).include(function(r) r.coursecategoryvalues) ' here trying narrow down query results if (pid.hasvalue) andalso (0 <

How can I change global variables in javascript? -

my html page displays button calls function when clicked. checked make sure button works displaying message when clicked , worked. created function change global varible when click button on html page show value of varibles varibles have not changed value set them using function. find problem in code below? var = 5; var b = 16; var c = 27; function reset(){ = 0; b = 0; c = 0; } my html code call function: <!doctype html> <html> <center> <script type="text/javascript" src="game.js" > </script> <form> <input type="button" value="reset variables" style="width:250px;height:50px" onclick="reset()" > </form> </html> javascript code show variables: function display(){ document.write("a equal " + + "<br/>"); document.write("b equal " + b + "<br/>"

java - Lock dependencies by secure checksum in Maven -

when distribute source project pom can define dependencies version strings. build download dependencies if not in local repository, verify checksums of downloaded files metadata same repository ( -c ). however build download dependencies number of public repositories (and proxies) , users @ mercy of public services if return unmodified files. i have way record checksums of build dependencies , ship them pom (so sure files unaltered dont need ship copy of local repository builders). is there maven way this? similiar that, there easy way archive dependencies (copy of local repository used artifacts , metadata files) can repeat build when central repositories fail or ship them offline customers? (both without need repository proxy if possible. know can build that, wonder if there infrastructure in maven already. maybe shipping local repository contain metadata files or similiar?) nb: not looking createchecksum on generated artifacts, on locking checksums of used dependencie

.net - Generating completely dynamic SQL with linq -

i've been using linq entity framework while , have been loving it. however, in situation need query dynamic database table on sql server. not know table name, structure or column names @ compile time. is there way of using linq syntax compile sql query? given table name , column names @ runtime, , need complex searches (e.g. cola = x , (cola = y or colb = z) or (colc in n..p)), order by's , potentially group bys i have found looks promising, http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx , don't understand a) how dynamically choose arbitrary table b) how prevent injection. author says there more in "part 2" - can't find links , blog 2008. i imagining syntax like public void selectpizzascheaperthan(int price) { var table = con.selectdb(tablename); var result = table.where(x => x.field<string>("food") = "pizza"); result = result.where(x => x

Check Variable Value in File and Replace If Needed Bash Script -

this question related post: setting variables value in file in different directory using loops , sed bash script i'm looking way check variable value in file , update needed. change value following: #!/bin/bash cd '/home/me/' source server.properties server_var="$server_name" echo "$server_var" echo "$application_name" if [ "$server_var" != "server1" ]; echo "uncorrect value" sed -i -e 's@server_name=$server_var@server_name=server1@g' server.properties fi cd '/home/test/' thank suggestion, if statement work, sed command doesnt update variable value in file. can please point me in right direction regarding issue? thank you, if [ -n "$server_name" ] sed ... fi btw, don't think set command can set $server_name . set $1 , $2 , etc.

c++ - Is a 2D integer coordinate in a set? -

i have list of 2d integer coordinates (coordinate pairs). i'd read these in and, later, determine if point has been read. the integer data may fall anywhere within range offered integer data type, number of actual data points small. therefore, using 2d array track points have been read impractical. set seems way of doing this. my current code accomplish follows: #include <set> #include <iostream> using namespace std; class grid_cell{ public: int x,y; grid_cell(int x, int y) : x(x), y(y) {} grid_cell(){} bool operator< (const grid_cell& a) const { return y<a.y || x<a.x; } }; int main(){ set<grid_cell> bob; bob.insert(grid_cell(1,1)); bob.insert(grid_cell(-1,1)); bob.insert(grid_cell(1,-1)); bob.insert(grid_cell(-1,-1)); cout<<bob.count(grid_cell(1,1))<<endl; cout<<bob.count(grid_cell(-1,1))<<endl; cout<<bob.count(grid_cell(1,-1))<<endl; cout<<b

javascript - Formatting JSON document to specification needed for visualization -

i'm attempting create google chart based on data in elastic search. json document needs in following format: { "cols": [ {"id":"","label":"lane","type":"string"}, {"id":"","label":"routes","type":"number"} ], "rows": [ {"c":[{"v":"m01"},{"v":4657}]}, {"c":[{"v":"m02"},{"v":4419}]}, {"c":[{"v":"m03"},{"v":4611}]}, {"c":[{"v":"m04"},{"v":4326}]}, {"c":[{"v":"m05"},{"v":4337}]}, {"c":[{"v":"m06"},{"v":5363}]} ] } my query (via ajax command) returns following data: $ curl http://localhost:9200/wcs/routes/_search?p

Send message to another PHP file -

Image
is possible have 1 php file send "message" specific users on php file? note "message" needs able received php file running, calling other files doesn't make difference. image below demonstrates want do: in example, user 1 calls "send.php", subsequently sends message "receive.php" instances of users 1,2, , 4. possible accomplish? additional information i cannot log messages in central location file or database because end querying messages once every 100 ms, overload database/filesystem. need instantaneous. additionally, cannot use sessions or cookies because mentioned message needs sent several users. finally, receiving php file doesn't terminate until user leaves page (it's html5 eventsource file). you can persist data across pages using sessions or database .

perforce - How to get list of changelists not yet integrated using P4J API? -

i'm converting python script calls 'p4 interchanges' (ie command returns changes not yet integrated branch) use jvm language. p4j ( http://www.perforce.com/perforce/doc.current/manuals/p4java-javadoc/ ) api can used reproduce same functionality? from perforce support: getinterchangesoptions passing flags interchanges command, if needed. use 1 of server.getinterchanges() methods. recommend using ioptionsserver interface rather iserver . for p4 command line: p4 interchanges //depot/merges/main/... //depot/merges/release/... i have p4java equivalent: ioptionsserver server = serverfactory.getoptionsserver("p4java://perforce:1666", null, null); list<ichangelist> changes = server.getinterchanges( null, filespecbuilder.makefilespeclist(new string[] {"//depot/merges/main/..."}), filespecbuilder.makefilespeclist(new string[] {"//depot/merges/release/..."}), null); for(ichangelist change : changes)

Clearing OffscreenPage in Android ViewPager -

i have viewpager , multiple tabs. 1 of these tabs controls settings, affects every other tabs. updates fine when change settings, except pages kept in memory. in order these update have select tab far enough it, come back. is there way force these tabs recreate themselves? thank you according this question on so, can reset adapter reload pages: viewpage.setadapter( adapter ); the duplicate that question linked to gives helpful information, such calling .notifydatasetchanged() on viewpager adapter.

java - Multiple calls of paintComponent() -

i have these 2 classes: public class pencil extends jcomponent implements mouselistener, mousemotionlistener{ plansa plansa; graphics g; public pencil(plansa newcanvas){ this.plansa = newcanvas; this.plansa.setflagshape(false); } @override public void mousedragged(mouseevent arg0) { plansa.setmousedragged(arg0); this.plansa.setflagshape(false); plansa.paintcomponent(plansa.getgraphics()); } @override public void mouseclicked(mouseevent e) { } @override public void mousepressed(mouseevent arg0) { plansa.setmousepressed(arg0); } @override public void mousereleased(mouseevent arg0) { // todo auto-generated method stub plansa.setmousereleased(arg0); this.plansa.setflagshape(true); plansa.paintcomponent(plansa.getgraphics()); } @override public void mouseentered(mouseevent e) { } @override public void mouseexited(mouseevent e) { } @override public void mousemoved(mouseevent e) { } } and one: public class plansa extends jpanel{ image

postgresql - Can I use the ubuntu default postgres with heroku? -

i'm writing web app run on heroku using postgresql. on servers, environment variable provided like: export database_url=postgresql://localhost:5432/iqtest they advise when running app locally, should disable usual postgres setup used in debian/ubuntu, , run server locally 'to avoid permissions issues'. you can create database like: /usr/lib/postgresql/9.1/bin/initdb pg and run server like: /usr/lib/postgresql/9.1/bin/postgres -d pg this works fine, wonder if it's possible system setup instead. i can't find simple explanation of how debian/ubuntu standard setup supposed work or how you're supposed use it, , experiments have ended demanding password, , warning me it's going write disk plaintext. has managed standard setup work heroku-style app without having appalling? as secondary question, there graphical (or text ui) browser/editor postgres tables? can use psql , sql commands, point , click nicer. pgadmin3 won't connect database

javascript - get hash via url in nodejs -

i have reset password hash generated bcrypt... hash = $2a$11$ro/y5gnki6v1dkewwzacbezy7q2a9872nugduxxes4j5swfeqghvg the problem hash have slash... in router app.get('/gethash/:hash',routes.getresethash); i 404 error! think problem slash between $ro , y5g in hash because hash try search url this app.get('/gethash/$2a$11$ro/y5gnki6v1dkewwzacbezy7q2a9872nugduxxes4j5swfeqghvg'..... how can stringify hash... ??? you want url escape hash. javascript has 2 functions encodeuri , encodeuricomponent ... want latter since want encode single part of including slashes: uri_safe_hash = encodeuricomponent(hash)

php - MYSQL Query to Codeigniter Query -

i have query below works fine when use in phpmyadmin, bit unsure how within ci framework when have m.id etc in place. query: select distinct m.name, m.id, c.id, c.name `default_ps_products` p inner join `default_ps_products_manufacturers` m on p.manufacturer_id = m.id inner join `default_ps_product_x_cats` x on p.id = x.product_id inner join `default_ps_products_categories` c on x.category_id = c.id there many ways. example 1: $result = $this->db ->select('m.name, m.id, c.id, c.name') ->distinct() ->join('default_ps_products_manufacturers m', 'p.manufacturer_id=m.id') ->join('default_ps_product_x_cats x', 'p.id=x.product_id') ->join('default_ps_products_categories c', 'x.category_id=c.id') ->get('default_ps_products p') ->result(); echo $this->db->last_query(); sometimes active record can't produce query want. can write yourself.

javascript - Using Marionette CollectionView to create multiple views per item -

i have marionette.collectionview items (models) need create 2 views run on model, can marionette.collectionview.builditemview return 2 views? edit : i don't want create wrapperitemview, have solution running right want make more standart. i want code this, there simple way make work? builditemview: function(item){ // create 2 views based on item type return [view1, view2]; }, appendhtml: function(collectionview, itemview, index){ if (itemview.type === "x" ) collectionview.$el.find(".a").append(itemview.el); if (itemview.type === "y" ) collectionview.$el.find(".b").append(itemview.el); } why dont itemview acts father of second view, can create second view in initialize function of item view. edit i still create perent view time make parent of 2 views, collection create parent , parent create 2 views inside of it. this way more natural me.

php - Install ffmpeg in windows 7 x64 -

i have problem install ffmpeg, tried several tutorials did not. tried using dll , executables not result always. "fatal error: call undefined function dl ()" i went on official website , downloaded dlls did procedure in playing in system32 , php / ex , declared extension in php.ini not work. using version of php 5.3.13. thinking version of php think? i'm using wampserver observation i used ffmpeg-20130318-git-519ebb5-win64-static.7z http://partisans9.alamaree.com/chan-5973786/all_p2.html it working, though used through command line file format conversion only.

c# - How can I implement effective Undo/Redo into my WinForms application? -

i have winform text editor. i able allow user undo , redo changes in rich text box, can in microsoft word. i have spent past week or researching how this, , results seem regarding graphics applications. the standard richtextbox1.undo(); gives disappointing results, undoes user has written. does have idea how implement effective undo/redo? preferably 1 undoes/redoes action word-by-word opposed character-by-character. this basic idea, , i'm sure many improvements made. i create string array , incrementally store value of richtextbox (in textchanged event, under own conditions) in array. store value, increment value of counter, stackcount . when user undoes, decrement stackcount , set richtextbox.text = array(stackcount) . if redo, increment value of counter , set value again. if undo , change text, clear values onwards. i sure many other people may have better suggestions/changes this, please post in comments , update, or edit yourself! example in c#

c# - MenusItems of WebDataMenu No Event Fires on the server -

i'm using remote webdatamenus dynamically add items; through access forms , trigger events execution of function or logic defined. the problem arises when want run vb.net code via itemclick type event, event not working properly; or @ least can't work on server-side (it not fire), works great client-side through javascript. it worth mentioning when click on items of menus run, vb.net code gives me javascript error '__dopostback' undefined - how can make work , run event vb.net code? ps: make work now, i'm running vb.net function javascript through instruction pagemethods.webdatamenu2_itemclick (eventargs.getitem (). get_key ()); setting enablepagemethods = true property on scriptmanager . however, not allow me use other controls method run, gives me initialization error in each of controls. i add menus , menus items. -code html <ig:webdatamenu id="webdatamenu2" runat="server" font-bold="false" font-na

ruby on rails - Can't figure out Delayed::DeserializationError -

i running delayed_job 3.0.5 (delayed_job_active_record 0.4.1) rails 3.2.12. having problems of jobs failing because of "deserialization". here simple example of 1 of failing handlers: --- !ruby/struct:delayed::performablemethod object: load;project;924951 method: :send_project_open_close_without_delay args: [] when try invoke job: delayed::deserializationerror: job failed load: undefined method `members' nil:nilclass. everyone seems think caused ar object no longer exists. in case, can run handler fine: project.find(924951).send_open_close_without_delay what else causing error? i think experienced issue when upgrade rails 3.2. error got caused yaml handler used delayed job. try adding following config/boot.rb require 'rubygems' require 'yaml' yaml::engine.yamler = 'syck'

Ideal way to read, process then write a file in python -

there lot of files, each of them need read text content, processing of text, write text (replacing old content). know can first open files rt read , process content, , close , reopen them wt , not way. can open file once read , write? how? see: http://docs.python.org/2/library/functions.html#open the commonly-used values of mode 'r' reading, 'w' writing (truncating file if exists), , 'a' appending (which on unix systems means writes append end of file regardless of current seek position). if mode omitted, defaults 'r'. default use text mode, may convert '\n' characters platform-specific representation on writing , on reading. thus, when opening binary file, should append 'b' mode value open file in binary mode, improve portability. (appending 'b' useful on systems don’t treat binary , text files differently, serves documentation.) see below more possible values of mode. modes 'r+', 'w+' ,

ios simulator - Keep safari remote debugging open on navigation -

i'm using safari's remote debugging inspect webview in iphone app in simulator. problem remote debugging window closes app does. i have action switches app , can't read console.log messages before switch because i'm not quick enough , can't read logs after coming app because have re-open console first. is there way keep open can @ least see last logs before switching apps? here applescript launches safari inspector. can export executable application , have sitting in dock inspector single click or launch in build phase in xcode. tell application "safari" activate delay 2 tell application "system events" tell process "safari" set frontmost true click menu item 2 of menu 1 of menu item "ipad simulator" of menu 1 of menu bar item "develop" of menu bar 1 end tell end tell end tell

excel function to find last number in column -

i record value of stocks each day in columns , long spreadsheet. in top cell of each column, want use function display last entry in column automatically. i've tried index function , index function combined counta function no success. suggestions? try using lookup , assuming @ 1000 rows of data (adjust required) use formula in a1 last number in a2:a1000 =lookup(9.99e+307,a2:a1000) you can have blanks or other data in range (even errors) , still return last number

wpf - Simple dialog based application using C# -

i want develop simple windows application (using c#) follows: a simple dialog based application 3 screens the first screen screen welcome user , give explanations on how proceed the second 1 drop screen user can drop files on (image files) it performs operations on provided images , displays live results list view status , percentage of completion i have image manipulation code , easy part me, i'm quite lost application itself... here questions: should develop using winforms or wpf? i'd add own font, have transparency on images use , display custom listview cells , controls... what best way of having multiple screens in dialog based application? thinking of using tabcontrol, hide headers , programaticaly switch first screen second 1 once user has clicked on 'next' button, third screen once files have been dropped on window... and best way have background process performs operations on image files, giving user feedback (progress bars percents) withou

converting SOAP XML response to a PHP object or array -

i'm using curl send request soap service, send in post body xml containing parameters, in response receive: web service: http://lcbtestxmlv2.ivector.co.uk/soap/book.asmx?wsdl <?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <soap:body> <searchresponse xmlns="http://ivectorbookingxml/"> <searchresult> <returnstatus> <success>true</success> <exception /> </returnstatus> <searchurl>http://www.lowcostholidays.fr/dl.aspx?p=0,8,5,0&amp;date=10/05/2013&amp;duration=15&amp;room1=2,1,0_5&amp;regionid=9</searchurl> <propertyresults>

objective c - iOS Load Previous Selected Values in Dependent UIPickerview load -

this first post , hoping community can me. i have view contains dependent uipicker has 2 components. when selected in component 1 of uipicker a1, a2, a3 visible in component 2. component 1 component 2 a1 component 2 a2 component 2 a3 component 1 b component 2 b1 component 2 b2 component 2 b3 component 2 b4 component 1 c component 2 c1 component 2 c2 i retrieve selected rows both of dependent components uipicker , write them plist file. example if select b3 save rowvalue "1" selecting b in first component, save rowvalue "2" selecting b3. my problem occurring when restart app, load values , try set selected rows second dependent component. the following code have: - (void) viewdidappear:(bool)animated { [self.dependentpicker selectrow:component1value incomponent:0 animated:yes]; [self.dependentpicker selectrow:component2value incomponent:1 animated:yes]; } the code setting row in first component. second componen

How do you configure Mathematica 9 to automatically evaluate all notebooks? -

i have mathematica 6 course using in mathematica 9; there no updated version. every time open notebook have go evaluation menu , click on "evaluate notebook". there way me set automatically evaluates notebook upon opening it? you can setup initialization cells. check this , this . afterwards, can open notebook , evaluate cell (e.g. 2+2 -> shift+enter) , accept run initialization cells. 1 thing helped me checking notebookevaluate in docs - way can evaluate cells in notebook without having open it. you may find further information options cells in here .

c# - Build Banshee: Missing dependencies -

i'm trying build banshee source. ran autogen.sh , here's (some of) output: configure: error: package requirements (gstreamer-0.10 >= 0.10.26 gstreamer-base-0.10 >= 0.10.26 gstreamer-plugins-base-0.10 >= 0.10.26 gstreamer-controller-0.10 >= 0.10.26 gstreamer-dataprotocol-0.10 >= 0.10.26 gstreamer-fft-0.10 >= 0.10.26) not met: no package 'gstreamer-0.10' found no package 'gstreamer-base-0.10' found no package 'gstreamer-plugins-base-0.10' found no package 'gstreamer-controller-0.10' found no package 'gstreamer-dataprotocol-0.10' found no package 'gstreamer-fft-0.10' found consider adjusting pkg_config_path environment variable if installed software in non-standard prefix. alternatively, may set environment variables gst_cflags , gst_libs avoid need call pkg-config. see pkg-config man page more details. error: not run ./configure, required configure banshee i've ran sudo apt-get b

android - How to fetch the E Mail ID of A contact -

i trying fetch e mail address of contact. found how contact email id? not use this. i have written following code fetch email cursor c1; c1 = getcontentresolver().query(contactscontract.contacts.content_uri, null, null, null, contactscontract.contacts.display_name); if(c1==null) return; if(c1.getcount() > 0) { while(c1.movetonext()) { string id = c1.getstring(c1.getcolumnindex(contacts._id)); if(id==null) continue; cursor email_crsr = getcontentresolver().query(commondatakinds.email.content_uri, null, commondatakinds.phone.contact_id +" = ?", new string[]{id}, null); if(email_crsr!=null) email = phone_crsr.getstring(phone_crsr.getcolum

ant not working on Ubuntu -

i have installed ant on ubuntu 12.10 using following command: sudo apt-get install ant but when try access, getting following error: /usr/bin/ant: 1: eval: syntax error: unterminated quoted string please help.

Calling Rails action from Javascript -

i have link_to in calls update action in controller: <%= link_to((image_tag("lock_closed.svg", :class => "edit")), :controller => "sections", :action => "update",:id => section.id, :remote => true) %> but call update action through javascript ordinary image tag. so like: <%= image_tag("lock_closed.svg", :class => "edit")%> and: $(".edit").click(function(){ if ($(this).hasclass("update")){ // call update action } else { //do else }; }) is possible call action way? i've been finding bit on using get & post or ajax methods i'm not sure how utilise them target specific controller & action. send ajax call $(".edit").click(function(){ if ($(this).hasclass("update")){ $.ajax({ type: "put", url: "/sections/<%= section.id %>" }); } e

How to pass values to AsyncTask Android -

this first time using asynctask , little confused well, passing values. i have 4 arraylist<string> s, contain data should inserted database. want insertion done in background. there minimum of 50 rows inserted database , 1 row inserted @ time, taking passing values 4 arraylists have. can guide me on how this? now create subclass insertdata extends asynctask ::: private class insertdata extends asynctask<params, progress, result>{ @override protected result doinbackground(params... params) { // todo auto-generated method stub return null; } } i have values in 4 arraylists, in need retrieve 1 entry each arraylist , pass 4 values database. how pass these 4 values asynctask , also, how repeat till there entries in arraylists. here database method inserts 1 row database ::: public void insert_row(int count, string image_url, string name, string number) { // todo auto-generated method stub db.

networking - How to learn if a remote linux machine has booted? -

i have windows development machine, , linux target on company network. after booting target board, how learn if has booted ? ping dig host nslookup utilities target name not resolve ip address , hence not reply. board has busy box utilities only. i have seen this post, problem still stands. do know ip address or hostname target board ? if yes, does respond ssh host_name_or_ip_here command ? if yes , if busybox utilities installed, can execute ssh remote_target "/bin/busybox uptime" and parse output on windows machine see if board short time, means rebooted recently. i hope looking for

ruby on rails 3 - Contextual validations in ActiveRecord using with_options and an array -

moving datamapper activerecord , 1 cool feature using contextual validations , using with_options pass array below: with_options when: [:started, :completed] |v| v.validates_with_method :has_data, method: :check_data_started? end which fire validations within block if .valid?(:started) or .valid?(:completed) called. is there way active record, tried: with_options on: [:started, :completed] |v| v.validate :check_data_started? end which looks blows error saying can't pass array within with_options call, it's expecting 1 context: /home/vagrant/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:414: syntax error, unexpected '[', expecting tstring_content or tstring_dbeg or tstring_dvar or tstring_end ...ue && (validation_context == :[:started, :complet... has done before? figured out. if else runs problem, please see below solution: with_options if: -> {[:started, :completed]

listview - Arguments not optional in vb6 -

why getting error? code right why? private sub loademployee() frmemployee.lvemployee.listitems call connect 'sql = "select * tblemployee " rs.open "select * tblemployee ", conn, adopendynamic, adlockoptimistic if not rs.eof rs.movelast set item = lvemployee.listitems.add(1, , rs!id) item.subitems(2) = rs!firstname 'item.subitems(2) = rs!middlename item.subitems(3) = rs!lastname item.subitems(4) = rs!agename item.subitems(5) = rs!gender item.subitems(6) = rs!address item.subitems(7) = rs!datehired item.subitems(8) = rs!birthdate item.subitems(9) = rs!birthplace item.subitems(10) = rs!citizenship item.subitems(11) = rs!cellno item.subitems(12) = rs!status item.subitems(13) = rs!basicsalary item.subitems(14) = rs!designation item.subitems(15) = rs!department 'item.subitems(16) = rs!m_name 'item.subitems(

ios - UIImageView Annotation -

i trying capture image camera show on uiimageview. after have buttons e.g. "paint brush", "eraser", "undo", "save". using brush want mark items on image captured. what best way accomplish annotation , save image. i not sure should used. should use touchesbegan/end etc.. or other alternative. regards, nirav u need understand bézier path basics.search on google or apple documentation. the uibezierpath class objective-c wrapper path-related features in core graphics framework. can use class define simple shapes, such ovals , rectangles, complex shapes incorporate multiple straight , curved line segments.

ListView on TOP of Ads - Android -

i'm having troubles showing ads on bottom of listview, on main activity ads works, difference there use viewpager instead of listview. this layout: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > <com.google.ads.adview xmlns:app="http://schemas.android.com/apk/lib/com.google.ads" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/adview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentbottom="true" ads:loadadoncreate="true" android:background="#313131" app:adsize="smart_banner" app:adunitid="my_id" />

unit testing - How can I run ignored tests with TeamCity's NUnit runner? -

i want run ignored tests in solution in different build configuration in teamcity. didn't see explicit why in build step configuration page. can done? the ignore attribute wrong thing use here. should used tests not wish run @ all. try using categories instead. teamcity has 2 properties can set within nunit build step. nunit categories include , nunit categories exclude control tests run.

Equivalent of pwd.h lib of c++ in java -

i have found link illustrates use of getting pwd based in uid of user. i have similar requirement in java running script different user needs implemetation. the code snippet in c++ below: static void su(const char* user) { struct passwd* pwentry=getpwnam(user); if(!pwentry) cout<<"su:getpwnam:couldnot pwd entry user %s",user; uid_t new_uid=pwentry->pw_uid; struct passwd* pwentry_nmsadm=getpwnam("nmsadm"); if(!pwentry_nmsadm) cout<<"su:getpwnam:could not pwd nmsadm"); gid_t new_gid=pwentry->pw_gid; if(chdir(pwentry->pw_dir)<0) cout<<"su:chdir"; uid_t current_uid=geteuid(); gid_t current_gid=getegid(); if(current_gid!=new_gid) { if(setgid(new_gid)<0) cout<<"su:setgid"; } if(current_uid!=new_uid) { if(setuid(new_uid)<0) cout<<"su: setuid"; } please suggest

backbone.js with backgrid.js to populate JSON -

This summary is not available. Please click here to view the post.

cakephp - Export Excel file using xlsHelper -

i using xlshelper of cakephp export in excel format.it working fine in major browser , opening file in operating system except "mac" operating system? may you.. <?php $this->layout=""; $filename=strtotime("now"); header ("expires: 0"); header ("last-modified: " . gmdate("d,d m yh:i:s") . " gmt"); header ("cache-control: no-cache, must-revalidate"); header ("pragma: no-cache"); header ("content-type: application/vnd.ms-excel"); header ("content-disposition: attachment; filename=".$filename.".xls"); header ("content-description: generated report" ); // echo 'number of rows::'."\t" . count($test)."\n"; // echo "\n"; echo 'id' . "\t" . 'enrollmentid' . "\t" . 'ids' . "\t" .

android - Getting invalid Authtoken for gmail login? -

in android application have created gmail login.the user can login gmail credentials in phone.the problem not getting valid token in android gingerbread os.but in case of ics , jelly bean , getting correct token. have tested in 5 devices. for checking validity of token used link finally solved it.the problem token not getting updated. when ever accessing token using getauthtoken string authtoken=accountmanager.getauthtoken(account, scope, false, new ontokenacquired(), null); the authtoken should validated using accountmanager.invalidateauthtoken("com.google", bundle.getstring(accountmanager.key_authtoken)); then again after should call string authtokennew=accountmanager.getauthtoken(account, scope, false, new ontokenacquired(), null); this valied token. can check validity of token link

iphone - Unable to resign keyboard when using PopOver -

in ipad app there 3 textboxes using popoverview controller on second text box. here 2 cases in first case: as finish editing first textbox , click next button on keyboard time keyboard resigning , popoverview controller opened on second text box.here had written code when next button of first textbox click @ time second textbox should became firstresponder. in second case: here actual problem, when finish editing first textbox , directly touches second textbox without clicking next button on keyboard, time popoverview controller menu opened on second textbox , keyboard unable resign , keyboard strucking on code resigning keyboard not working. write code used on next button event of keyboard in bellow method... - (bool)textfieldshouldendediting:(uitextfield *)textfield { if (textfield == yourfirsttextbox) { // write code here } return yes; }

javascript - Highcharts: Cannot get example to display chart -

i cannot following chart display. following jquery. i've tried other examples replacing jquery , works. have files in same folder, including data.csv. $(document).ready(function () { var options = { chart: { renderto: 'container', defaultseriestype: 'column' }, < ...more options here... > }; $.get('./data.csv', function (data) { // split lines var lines = data.split('\n'); $.each(lines, function (lineno, line) { var items = line.split(','); // header line containes categories if (lineno == 0) { $.each(items, function (itemno, item) { if (itemno > 0) options.xaxis.categories.push(item); }); } // rest of lines contain data name in first position else { var series = { data: []

c# - Validate uploaded file as image and then get the dimensions of it -

i want upload image file ftp server, have asyncfileupload control on asp.net page. using following code type of asyncfileupload1.postedfile , trying dimensions of having no luck far. string ctype =asyncfu.postedfile.contenttype; if (ctype.contains("image")) { stream ipstream = asyncfu.postedfile.inputstream; image img = system.drawing.image.fromstream(ipstream); //error comes here, can't think work around this. int w = img.physicaldimension.width; int h = img.physicaldimension.height; } as can see, errors message says cannot convert system.drawing.image system.web.ui.webcontrols.image . understand error, cannot think work around this. i have asyncfileupload control unknown file uploaded, saved ftp server if image file. any suggestions? try : stream ipstream = fuattachment.postedfile.inputstream; using (var image = system.drawing.image.fromstream(ipstream)) { float w = image.physicaldime

python - How to check if relation item is null -

how can check if related object null in openerp? i have my_object has supplier_invoice field. my_object declared as: _columns = { 'supplier_invoice': fields.many2one('account.invoice', 'commission invoice', ondelete='set null'), } and want this: if my_object.supplier_invoice: do_something() but doesn't work s returns browse_record if empty. i using openerp 7 ok, had test : if my_object.supplier_invoice.id: do_this() the id false when record not exist

amazon web services - designing for failure when polling/retrying/queueing is not possible -

i'm designing website/web service hosted in cloud (specifically aws although that's irrelevant), , i'm spending lot of time thinking "designing failure". want system seamlessly handle node failures, i.e. without significant user impact or engineer intervention. in cases, it's easy see how handle sudden node failure. if app has api handled 4 servers behind load balancer, polled ajax or iphone app, poller can detect failed tcp/ip transmission , retry... assuming load balancer behaves correctly, hit healthy instance. if app more processing-oriented, queue service sqs can used allow stateless nodes pick failed nodes left off. the difficulty see "points of entry", no retry/polling possible because application hasn't been loaded yet, , failure means app never starts. example, index.html on webpage... if node fails while transmitting file, user's browser hang , not automatically retry (they need refresh). the load balancer single "p

javascript - How can I know a 2 last pressed key on a keyboard -

is possible know, 2 last keys pressed on keyboard? how can it? need compare keys, , if same - make function. example, if press enter - first function, if after enter press space- second function. if after enter press ctrl - third function. so, hink onw way - make 2 var current , previous key value, , make if else if function :-) way, how current key value $('#text').keydown(function(event) { $('#show').text(event.keycode); }); or, better question! (i saw right now) directly in editor, after press doublespace - jump anothe line in live-preview. how works? i'm not sure, thinks need same. thank much! you start very simple jquery plugin: (function($) { $.fn.keywatcher = function() { return this.keydown(function(evt){ var $this = $(this); var prevevt = $this.data('prevevt'); $this.trigger('multikeydown',[prevevt,evt]); $this.data('prevevt',evt); });

interpolation - using interp1 in R for matrix -

i trying use interp1 function in r linearly interpolating matrix without using loop. far have tried: bthd <- c(0,2,3,4,5) # original depth vector btha <- c(4000,3500,3200,3000,2800) # original array of area temp <- c(4.5,4.2,4.2,4,5,5,4.5,4.2,4.2,4) temp <- matrix(temp,2) # matrix temperature measurements # -- interpolating bathymetry data -- depthtemp <- c(0.5,1,2,3,4) layerz <- seq(depthtemp[1],depthtemp[5],0.1) library(signal) layera <- interp1(bthd,btha,layerz); # -- interpolate= matrix -- layert <- list() (i in 1:2){ t <- temp[i,] layert[[i]] <- interp1(depthtemp,t,layerz) } layert <- do.call(rbind,layert) so, here have used interp1 on each row of matrix in loop. know how without using loop. can in matlab transposing matrix follows: layert = interp1(depthtemp,temp',layerz)'; % matlab code but when attempt in r layert <- interp1(depthtemp,t(temp),layerz) it not return matrix of interpolated results, numeric arra

workflow - Dynamics CRM 2011 - attach file to email before send -

i have pretty standard workflow in dynamics crm 2011, sends email when new entity created. now, before email sent, i'd attach attachments plugin. is possible capture before-send event on email activity, create plugin before email sent, check on created message, attach files , send it? edit: files fetched web service system, not attachements of other entities in crm. crm create email , send it, 2 separate actions. should able add code post-create plugin on email entity adds attachment. presumably workflow add flag email plugin knows attachment add email.

sql - MYSQL statement together OR and AND -

i have table in mysql named sale 3 columns below : sale: id|customers|type i want select sales has type!=2 or sales has type=2 , customers!=0 i write statement : sale.type != 2 or (sale.type = 2 , sale.customers != 0 ) but doesn`t give me correct rows . also have use , other columns in query operators between of them , , here use or . just remember rule: bracket or! where foo = 'bar' , (sale.type != 2 or (sale.type = 2 , sale.customers != 0 ) ) , blah = 3 actually condition can simplified to: ( sale.type != 2 or sale.customers != 0 ) because logically checking sale.type = 2 redundant.

android - ASP.NET MVC4 Web API & Session variables -

in asp.net mvc4 project, using apicontrollers serve both web clients , mobile clients. secure web services, using [authorize] annotation. now, web client working fine. however, when tend invoke web api mobile application (e.g. android), got error. when looked @ code snippet: [authorize] public list<double> getsomeinfo(int param1, string param2) { user user = sessiondata.currentuser; // using user.userid // .... } session data hold user connected properties when connected web app. in case of mobile clients, session data null. so, there appropriate method resolve problem. in opinion, think userid should provided parameter web api may need achieve treatment. think ? you talking 2 different things : session as darrel said, web api not design support asp.net session. http , rest services stateless – , result each http request should carry enough information itself recipient process in complete harmony s

jsf - Primefaces DataTable - deleting with dialog deletes wrong entry -

i have table in form. 1 of columns in table displays row of buttons edit , delete table entries. when delete entry callign controller button's action attribute, works expected. but once have added dialog let user confirm deletion, wrong entry deleted. last entry in current table. have no idea reason - using same datatable var button , dialog. i working jsf 2 (mojarra 2.1.6) , primefaces 3.5 deploying on jboss 7.1.1 on suse 12.2 machine. the form: <h:form id="downloads"> <ui:include src="components/table.xhtml"/> </h:form> the table: <ui:composition> <p:datatable value="#{controller.currentlevelresources}" var="download" id="downloadtable" scrollheight="120" rows="10"> <p:column sortby="#{download.name}"> <f:facet name="header">name</f:facet> <h:outputtext id="downloadname" va