Posts

Showing posts from August, 2014

linux - How to grep for presence of specific hex bytes in files? -

my web app displaying bizarro output (unicode characters shouldn't there, etc.). best can reckon somehow introduced bad char somewhere in source, can't figure out where. i found this answer states can like: grep -obuap "<\x-hex pattern>" . when copy unicode char out of browser , bless hex editor, tells me exact bytes of char are: 15 03 01 ef bf bd 02 02 how can format <\xhex pattern> match exact bytes need. tried: grep -obuap "<\x-15 03 01 ef bf bd 02 02>" . but doesn't work. thoughts? check post again. frost not including '<' , '>' in actual grep command. used carats enclose example statement. actual statement looks this: "\x01\x02" not: "<\x01\x02>" i have c source file on computer begins line: #include <stdio.h> when run grep -obuap '\x69\x6e\x63\x6c\x75\x64\x65' io.c i get 1:include that is, line number followed only ...

javascript - Hide textbox based on its value -

i've got canvas on can add text , image layers, below canvas have couple of textboxes in display information selected layer. things display are: x coördinate y coördinate width height font font size font color titel angle now since image layer not have font, font size , font color display 'undefined' now. i using javascript code display info in textboxes: document.getelementbyid('width').value = math.round(layer.width*100)/100; document.getelementbyid('height').value = math.round(layer.height*100)/100; document.getelementbyid('x').value = layer.offsetx; document.getelementbyid('y').value = layer.offsety; document.getelementbyid('color').value = layer.fontcolor; document.getelementbyid('color').style.color=layer.fontcolor; document.getelementbyid('font').value = layer.fontfamily; document.getelementbyid('size').value = layer.fontsize; document.getelementbyid('title').value = layer.t...

String Variable in Visual Studio 2008 Expression Expected -

dim html string html = '<head> ' $_ '<title>send sms</title>' $_ '</head>' i having error @ line 2 expression needed. use double quotes enclose strings. use ampersands concatenation. so: dim html string html = "<head> " & _ "<title>send sms</title>" & _ "</head>"

sockets - RMI Client- Server: java.rmi.ConnectIOException: error during JRMP connection establishment -

i'm trying establish rmi client server connectivity client , server behind different nat/firewall using tcp hole punching mechanism. currently, connectivity between client , server using public ip , port "80". after tcp connection established retrieve stub info of rmiserver. also, netstat , see connection established. but when trying read remote object i'm getting following exception java.rmi.connectioexception: error during jrmp connection establishment; nested exception is: java.net.sockettimeoutexception: read timed out @ sun.rmi.transport.tcp.tcpchannel.createconnection(tcpchannel.java:293) @ sun.rmi.transport.tcp.tcpchannel.newconnection(tcpchannel.java:190) on monitoring connectivity netstat, see tcp connection gets terminated , not stable. helpful if hints on how maintain or stable tcp connection. thanks. the timeout error indicates able open socket between client , server, socket not serviced in timely manner, closed , gave excepti...

c# - Range validator not working -

i trying put asp.net required field validator , range validator required field validator works not range. why ? <asp:textbox id="txtcnic" runat="server" cssclass="textfield_width"></asp:textbox> <asp:requiredfieldvalidator id="requiredfieldvalidator2" runat="server" controltovalidate="txtcnic" errormessage="requiredfieldvalidator" forecolor="#ff3300" setfocusonerror="true" validationgroup="complaints">cnic required</asp:requiredfieldvalidator> <asp:rangevalidator controltovalidate="txtcnic" minimumvalue="14" maximumvalue="16" type="string" validationgroup="complaints" ...

jquery - Issue Adding Mouse Hover Animation to HTML5 Canvas Drawings -

could please take @ this demo , let me know how add css animation drawing via css3 or jquery? want make circle bigger or change background color on mouseover . <canvas id="mycanvas" width="200" height="100" style="border:1px solid #d3d3d3;">your browser not support html5 canvas tag.</canvas> var c = document.getelementbyid("mycanvas"); var ctx = c.getcontext("2d"); ctx.beginpath(); ctx.arc(95, 50, 20, 0, 2 * math.pi); ctx.fillstyle = "#ff8c00"; ctx.fill(); ctx.linewidth = 4; ctx.strokestyle = '#2d2d2d'; ctx.stroke(); this tried: ctx.hover( function() { ctx.animate({ fillstyle: 'yellow' }, 300); }, function() { ctx.animate({ fillstyle: 'red' }, 300); } ); but didn't work! thanks. you can't control html canvas drawings either css or jquery. dom elements can trigger events on hove...

html - Image rest of height inside a div-Container -

i have got following code: html: <div id="mapwrapper" style="height: 624px;"> <div class="box" id="map"> <h1>campus</h1> <p>description campus map.</p> <img src="abc.png"> </div> </div> css: .box { background-color: #fff; border: 1px solid #ccc; border-radius: 5px; padding: 3px; overflow:hidden; height:100%; } #mapwrapper { position: absolute; top: 0px; left: 0px; width: 100%; overflow: hidden; padding: 10px; } #map { display: inline-block; position: relative; } #map img { height: 100%; } i want image take rest of height, free in map-div. currenty image set 100% , why runs out of box @ bottom. can help? thanks! why not use display:table setup, advantage of can add content want first 'row' , image take remaining space (whatever left table height minus first...

ruby on rails - Multiple model.save's in 1 if condition with an unless -

i'm trying save response , save issue if it's not nil in 1 condition don't have multiple if/else conditions complicating logic. for use case @response exists , issue nil, not if block. is there obvious i'm not seeing or can not write logic in 1 line this? note: know transaction should used, i'm trying working prototype right now. if @response.save && (issue.save unless issue.nil?) # not if block when @response exists , issue nil p 'in save' format.html { redirect_to issue_path(params[:issue_id]), notice: success_message } else p 'not in save' format.html { render action: 'new' } end this have working , hoping there easier 1 liner rather this. success = false if issue.nil? if @response.save success = true end else if @response.save && issue.save success = true end end if success p 'in save' format.html { redirect_to issue_path(params[:issue_id]), notice: ...

jQuery Ajax DOM Exception 12 -

i'm trying send request using $.get('/').done(function() { alert('assdsdasasd'); }).fail(function(jqxhr, textstatus, errorthrown) { alert(errorthrown); }); but fail handler invoked , alerts me "error: syntaxerror: dom exception 12" where error come , how can fix this?

r - ggplot2 syntax for geom_smooth -

i have following function using fit non linear curve set of data. keep receiving following error: error in do.call("layer", list(mapping = mapping, data = data, stat = stat, : object 'y' not found the error coming geom_smooth fit. can offer suggestions? below test data , function: library("ggplot2") df <- data.frame(rfp_fold=1:20, e=rnorm(20)) flimplot <- function(data) { ggplot(data, aes(x=rfp_fold, y=e)) + geom_point(shape=1) + geom_smooth(method=nls, # add non linear regression fit formula='y ~ * (x / (x + k))', # forumla fit start=list(a=max(y), k = 0.1), # set parameters se = false, # no shaded ci fullrange=true) # extend regression line } flimplot(df) # error in do.call("layer", list(mapping = mapping, data = data, stat = stat, : object 'y' not found i don't know why variables not bein...

matlab - Why is a sum statement so bizarrely synthesized? -

i have 4 buttons on fpga dev board wrote function [hex0] = bar(key) n = uint8(sum(key, 'native')); ... unfortunately, hdl coder turned following chunk of vhdl: y := '0'; k in 0 3 loop y := y or key(k); end loop; y_0 := '0' & '0' & '0' & '0' & '0' & '0' & '0' & y; which don't get. can me figure out what's going on here? to understand this, have understand matlab sum logical inputs , native option. sum of logicals logical. sum replaced or sum([true,true],'native') and coder puts out. for-loop implements sum ( sum(key, 'native') ), coder recognizes implemented using or. finally, conversion logical uint8 done padding 7 0 bits.

php - Set index of dropdown list to value -

i have dropdown list <label for="stafftype">staff type<br /></label> <select id="mylist" name="stafftype" onchange="show()"> <option>care staff</option> <option>nursing staff</option> <option>administrator</option> </select> i want set index $user['stafftype']. what best way? php code create user object <?php while ($cursor->hasnext()): $user = $cursor->getnext(); ?> depdending on how set dropdown values, need give condition set if corresponding value matches, if yes, set selected. consider example: // db values $values_from_db = array( array('id' => 1, 'stafftype' => 'care staff'), array('id' => 2, 'stafftype' => 'nursing staff'), array('id' => 3, 'stafftype' => 'administrator'), ); // current value...

C Hash Table - Advantages/Disadvantages of Binary files? -

i've been learning hash tables , binary files , wondering how viable method of data storage be. efficient read/write disk due added efficiency of binary files, or considered inefficient? i've heard term "hash disk" mentioned more once, not sure if active data management opposed reading dat file upon opening. what advantages/disadvantages storing data in dat file rather in memory? for example i'm working on program right using hash table store data. can store hash data array of struct, linked list, or binary file(the 3 methods have learned far). if not efficient read/write file, there still situation said method accepted?

Jquery and ajax for submitting form doesnt work -

this code for submitting form: aj.js $(document).ready(function(){ $("#reqform").submit(function(e){ e.preventdefault(); var f = e.target, formdata = new formdata(f), xhr = new xmlhttprequest(); xhr.open("post", f.action,true); xhr.send(formdata); xhr.onreadystatechange=function() { if (xhr.readystate==4 && xhr.status==200) { $("#alert").html(xhr.responsetext); $('#alert').css('visibility','visible').fadeout(5000); } } }); }); at first time when submit form, things , mycode run well. when want submit second, third ,.. time ajax code done , form data save in database, part of code doesnt work xhr.onreadystatechange=function() { if (xhr.readystate==4 && xhr.status==200) { $("#alert").html(xhr.responsetext); $('#alert').css('visibility','visible').fadeout(5000); ...

c - Resolving host name -

i can resolve hostname getaddrinfo () and validate address. can use connect(socket, sockaddr, len) i'm not sure connect does. because if try modify hosts file e.g. modify ip-address host name. connect() still works fine. e.g. foo.bar 1.1.1.1 ---> foo.bar 2.2.2.2 is there anyway know oh, no more 1.1.1.1 valid, 2.2.2.2 getaddrinfo() translates addrinfo structs containing sockaddr structs can in turn used connect() socket, cares raw ipv4/ipv6/unix domain addresses. connect() needs raw addresses, not know or care @ came (translated, hardcoded 32 bit integers, etc.), , connecting address not verification translated address "right" one, server on requested raw address open on requested port. it sounds want cache translated addresses, can beneficial, seem expect changed name mappings "pushed" you. linux systems not cache address translations @ os level unless running nscd (name service cache daemon), , there no form of ...

c# - Floyd-Warshall Algorithm - Also get the name of each point other than shortest distance -

i have created algorithm shortest point between 2 selected points on map. first filled matrix entirely distance, weight. named example: dist[0,1] refers road between point 0 , point 1. every point has number assigned it. the matrix filled accordingly , fjord warshall algorithm runs: for (int k = 0; k < count; ++k) { (int = 0; < count; ++i) { (int j = 0; j < count; ++j) { if (dist[i,j] > (dist[i,k]+dist[k,j])) { dist[i, j] = dist[i, k] + dist[k, j]; } } } } this derives shortest point between every single path. check path have it's shortest point: shortest = dist[x, y]; which return correct value , works well. here issue. need set see through points passes. mean if want go point 1 point 5 , shortest route throug...

sql server - Finding difference of two columns from two different rows in an SQL table -

i trying figure out query returns difference of 2 columns belongs 2 different rows of single table for example have following data in table id market grade term bid offer 1 heavy abc jun14 -19.5 -17 2 heavy abc jul14 -20 -17.5 3 sour xyz jun14 -30 -17 4 sour xyz jul14 -32 -27 now, want following results (as market , grade same id=1,2 ) bid of id=1 - offer of id=2 offer of id=1- bid of id=2 (as market , grade same id=3,4 ) bid of id=3 - offer of id=4 offer of id=3- bid of id=4 something following market term bid offer heavy/abc jun14/jul14 (-19.5-(-17.5))=-2 (-17-(-20))=3 sour/xyz jun14/jul14 (-30-(-27))=-3 (-17-(-32))=15 what vest way ms sql. using row_number function create table things (id int, market varchar(30), grade varchar(30), term varchar(30), bid decimal, offer decimal) insert...

r - Solving a system of unknowns in terms of unknowns -

i trying solve 5x5 cholesky decomposition (for variance-covariance matrix) in terms of unknowns (no constants). a simplified version, sake of giving example, 2x2 decomposition: [[a,0],[b,c]]*[[a,b],[0,c]]=[[u1,u2],[u2,u3]] is there software (i'm proficient in r, if r can great) solve above yield answer of left-hand variables in terms of right-hand variables? i.e. final answer: a = sqrt(u1) b = u2/sqrt(u1) c = sqrt(u3+u2/u1) take @ this wikipedia section . the symbolic definition of (i,j)th entry of decomposition defined recursively in terms of entries above , left. implement these recursions using matlab's symbolic math toolbox , apply them (symbolically) obtain formulas 5x5 case. warned you'll end extremely complicated formulas of unknowns, , - excepting unusual circumstances - fine implement decomposition iteratively fixed size 5x5 matrix.

Python: how to add spaces between strings -

to more specific, i'm trying print several results of function in form of sentence print str(function(first)) + str(function(second)) + str(function(third)) , on, i've come across problem there no spaces between individual strings. so, want know how add spaces between each of strings. use join() print " ".join([str(function(first)), str(function(second)), str(function(third))])

java - Creating String representation of lambda expression -

this question has answer here: is possible retrieve lambda expression @ runtime 2 answers for debugging purposes trying create string representations of lambda expressions (specifically of predicate s, though interesting other lambda expressions too) in java 8. idea this: public class whatever { private static <t> string predicatetostring(predicate<t> predicate) { string representation = ... // magic return representation; } public static void main(string[] args) { system.out.println(whatever.<integer>predicatetostring(i -> % 2 == 0)); } } and output i -> % 2 == 0 (or logically equivalent). tostring() method seems of no help, output com.something.whatever$$lambda$1/1919892312@5e91993f (which guess expected tostring() not overridden). i'm not sure whether possible, e.g. reflection, haven...

php - Two arrays into one table. First array vertical, second horizontal -

name bob jim moe rob id 555 666 777 888 lvl 1 2 3 4 this (part of) array: array ( [heroes] => array ( [0] => array ( [paragonlevel] => 384 [name] => barbecue [id] => 35335691 [level] => 70 [hardcore] => [gender] => 0 [dead] => [class] => barbarian [last-updated] => 1400233350 ) [1] => array ( [paragonlevel] => 384 [name] => ethereal [id] => 43477852 [level] => 70 [hardcore] => [gender] => 1 [dead] => [class] => crusader [last-updated] => 1400283921 ...

Get query result (ActiveRecord Ruby on Rails) -

model: def self.auth(username, password) user = users.where(:username => username).where(:password => password).first user end controller: def auth user = users.auth("username", "password") render :text => user end result nil. how fix it? thanks. try using model method(auth) in controller this def auth1 user = auth(username,password) render :text => user end note: model should singular(user) .currently have users ,which against rails convention , might cause problems in future.

How to setup cron job in magento? -

i working on magento 1.7.0.2 version. i want send csv in mails customers. should done every month using cron job in magento. for cron job config.xml <crontab> <jobs> <module_store> <schedule><cron_expr>0,15,30,45 * * * *</cron_expr></schedule> <run><model>clinic/observer::sendmailtoclinic</model></run> </module_store> </jobs> </crontab> observer.php class module_store_model_observer { public function sendmailtoclinic(varien_event_observer $observer, $content){ $mail = new zend_mail(); $mail->settype(zend_mime::multipart_related); $mail->setbodyhtml($html_body); $mail->setfrom($from_email, $from_email_name); $mail->addto($to_email, $toemailname); $mail->setsubject($subject); $file = $mail->createattachment(file_get_contents($file_path)); $file->type = 'text...

java - Does Thread.sleep throw if the thread was already interrupted? -

given thread interrupted while not blocked (i.e. no interruptedexception thrown), thread throw interruptedexception when later attempts sleep? the documentation not state clearly: interruptedexception - if thread has interrupted current thread. interrupted status of current thread cleared when exception thrown. yes, does. the documentation perhaps isn't crystal clear on point, easy both test (see own answer below, example), , see canonical (hotspot) implementation. thread.sleep shells out os:sleep checks interruption before staring sleep process can see here (look os:sleep ). if wasn't case, interrupts more or less impossible use. if happened arrive outside of sleep() call lost subsequent sleep() calls ignore them. couldn't re-interrupt thread because interrupted.

graph - MATLAB Surface Plotting -

Image
i want plot region (of integration) in 3d-space given conditions -1<=x<=1, 0<=y<=1, 0<=z<=1-x^2 translucent single-coloured faces in 'wireframe'. my solution draws 4 bounding surfaces of region separately. used surf() bottom face lies on x-y plane , top face; surf() doesn't seem work 2 vertical faces. hence guess there has easier way draw this... cludgiest code ever: figure hold on x = linspace(-1,1,30); y = linspace(0,1,30); [x,y] = meshgrid(x,y); z = 1-x.^2; h = surf(x,y,z); set(h,'edgecolor','none','facecolor','r','facealpha',0.5); z = zeros(30); h = surf(x,y,z); set(h,'edgecolor','none','facecolor','r','facealpha',0.5); y = ones(30); z = 1-x.^2; y = x.*0; h = fill3(x,y,z,'r'); alpha(h,0.5); y = y+1; h = fill3(x,y,z,'r'); alpha(h,0.5); y = linspace(0,1,30); x = y.*0+1; z = y.*0 plot3(x,y,z,'k')

Login to Facebook from Android app without inserting manually credentials -

i'm wiriting android app used bar's clients take selfie of , automatically post on bar's facebook page. need way automatic login bar's facebook account without entering username , password inside login dialog, providing them source code (it hardcoded, app installed in tablet of bar). thank you marco you should use facebook sdk in app. https://developers.facebook.com/docs/android/ for facebook login: https://developers.facebook.com/docs/android/login-with-facebook/v2.0

android - Cannot find if a view is not visible on screen in a ScrollView. Always returns true -

i have been trying determine if textview can seen on screen, if not want display small text saying "scroll read". have tried various methods questions this , many others too. in detail fragment of master-detail layout, have fragment, contains framelayout. framelayout has scrollview in , textview in front saying "scroll read" (which keep invisible until textview news article in scrollview not visible). eg, wont display "scroll read" textview here or here , display here . right now, visible testing purposes. the layout here . scrollview scroller . when image available viewstub article_header_stub_import used given in bottom of file. want check if textview body visible or not. added wastedtext below body checking shown visible in cases. i have tried different things solutions, getting gethitrect scrollinglinearlayout or scroller or detailframelayout , detail fragment. code similar question linked , using log.d(...) see check if-else case. i...

java - JComboBox error when items are added -

i try add items jcombobox , receive nullpointerexception error. sample of code : public adminpanel() { fillcomboteacher(); initcomponents(); } public void fillcomboteacher(){ hashset<person> set = cont1.returnteachers(); iterator = set.iterator(); try { while (it.hasnext()) { person p = (person) it.next(); string name = p.getname(); comboteacher.additem(name); } } catch (exception e) { system.out.println(e); } } person class - name, state (with getters , setters) returnteachers() - returns hashset containing persons state = "teacher" i don't understand why i'm receiving error , why can't fill combobox , followed tutorial step-by-step , still not well. thanks! you calling fillcomboteacher before calling initcomponents . looking @ method's name, assumed initialized comboteacher ...

sql - MySQL. Average price, connecting two databases -

i learning mysql , not understand how something. have 2 tables , want display stuff out of it, it's pretty hard explain i'd rather show you. tables: create table if not exists `proprietate` ( `id` int(11) not null auto_increment, `serie_buletin` varchar(8) not null, `cnp` bigint(20) not null, `nr_vehicul` int(11) not null, `data_cumpararii` date not null, `pret` int(11) not null, `id_persoana` int(11) not null, primary key (id), ) engine=innodb default charset=latin1 auto_increment=16 ; create table if not exists `vehicul` ( `id` int(11) not null auto_increment, `nr_vehicul` int(11) not null, `marca` varchar(30) not null, `id_marca` int(11) not null, `tip` varchar(15) not null, `culoare` varchar(15) not null, `capacitate_cilindrica` int(11) not null, `id_proprietate` int(11) not null, primary key (id), foreign key (id_proprietate) references proprietate(id) ) engine=innodb default charset=latin1 auto_increment=16 ; and these value...

java - How to draw lines in an existing activity? -

in fact, want code bridge constructor game , user must able draw these lines make bridge.. already answered : i've been trying create class allow me draw lines on existing layout, app crashed when try launch activity "game" (by pressing button in main menu). logcat told : "fatal exception : main" , have nullpointerexception. [edit] : search how lines we've created individual objects (we suppose there bitmaps canvas created), don't know how these bitmaps... here code of activity "customview" (use draw lines) : package com.g70.buildmybridge; import java.util.linkedlist; import android.content.context; import android.graphics.bitmap; import android.graphics.canvas; import android.graphics.color; import android.graphics.paint; import android.graphics.path; import android.view.motionevent; import android.view.view; public class customview extends view { private paint mpaint; private bitmap mbitmap; private canvas...

uitableview - How to manually trigger "Scroll to top" for active scrollview component on iOS? -

i know how manually scroll uitableview or uiscrollview top. i trying replicate behaviour of tapping uistatusbar automatically finds active view can scrolled top , scrolls top. so, want same, without knowing uiscrollview subclass active , can scrolled top. is there public nsnotification this, or other public method? [self.scrollview setcontentoffset:cgpointzero animated:yes]; update should traverse view hierarchy or responder chain , first item of class uiscrollview responds yes scrollstotop (or if delegate implements scrollviewshouldscrolltotop: , returns yes ) candidate automatic scrolling

nested conditions in forloop in matlab like c++ -

i new in matlab, coming c++ , not sure whether valid question ask. trying write c++ loop in matlab, did study matlab loops not able found such example illustrating: for example in c++ write code like: // simple example int a=1 , b=1; for(x=0, z=a; x<length; x++, z++){ for(y=0, w=b; w<length; y++,w++) a[x][y]= z*w; } } now in matlab : z=a; x=0:length y=0:length a(x,y)=z*w w++; // trying end z++; end this trying wanna increment both 'w' , 'z' there no w++ in matlab, need use w = w+1

How to validate complete html using java -

i want validate html tags , contents using java. validation should make sure html tags closed properly. there no mistake in tag creation area. eg <div id="dividvalue'></div> or <span id\="spanidval" ,></span> i need validate such kind of things. while googling got regular expression this <(\"[^\"]*\"|'[^']*'|[^'\">])*> but wont validate htmls closed or not? how can add this. my sample code attached below. please me. package com.test; import java.util.regex.matcher; import java.util.regex.pattern; public class htmlvalidator { private static pattern pattern; private static matcher matcher; private static final string html_tag_pattern = "<(\"[^\"]*\"|'[^']*'|[^'\">])*>"; public void htmltagvalidator(){ pattern = pattern.compile(html_tag_pattern); } public static boolean validate(final string...

user interface - Java - How to correctly display ANSI art in a JTextPane -

Image
i having trouble displaying ansi art in jtextpane . i thought chosing fixed-width or monospace font , removing line-spacing of jtextpane 's styleddocument via simpleattributeset enough correctly display some different pieces of ansi art , after trying different fonts , settings realized has more that. i've been using damn nfo viewer compare jtextpane in order see if code displaying the piece of digital art correctly. i set jtextpane font same font damn nfo viewer using (according settings courier new, 8 , default) via arttextpane.setfont(new java.awt.font("courier new", 0, 8)) . however, if apply line-spacing settings via styleddocument.setparagraphattributes(int, int, attributeset, boolean) jtextpane not display art correctly. here 2 screenshots show differences: damn nfo viewer (courier new, 8): my jtextpane (courier new 8) : what strange when setting jtextpane 's font-size 9 alignment seems correct bit unsharp. zooming onto charact...

Why basic math functions aren't overloaded for different types in Java, Math? -

i have interesting question. figured out, math.pow() takes (double, double) args , wonder why there no overloaded functions other types combinations such (int, int) or (int, double) atc ... i think big hole , paintfull weakness belive there reason. can explain me, please? consider these 2 methods: private int simplepow(int x) { return x * x; } private int harderpow(int x) { return (int) math.pow(x, 2); } first 1 faster second... problem is, if know, use power (int, int), calculation effective , don't need take care of problems double variables. well 1 should concerned (int, int) overload; others take double parameter should result in double s anyway (double, double) method do. why there no (int, int) overload? because exponentiation grows fast, , since int s 32 bits long, there limited number of parameters such 1 raised other in range. double s have much larger range don't have similar problem (to clear, doubles can overflow too, can hold maxim...

java - Have a greater number than 256 android file output stream -

i using fos.write(some_number) when trying display number won't greater 255. this second activity's code: fileoutputstream fos; try { fos = openfileoutput("income", context.mode_private); //"income" number written on textfield fos.write(income); fos.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } first activity's code: try { fileinputstream fis; fis = openfileinput("income"); total_income = fis.read(); fis.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } //... //.... textview textview = (textview) findviewbyid(r.id.incomevalue); textview.settext(""+ total_income); the write() method writes byte has range 0-255, won't more that. better use dataoutputstream , d...

Running command with python subprocess.call fails but works correctly when typed into cmd.exe -

so background on i'm trying setup cocos-2dx v3.0 project. i've gotten python script creates project run , i'm trying build , run project can start development on game. issue i'm running into, per question, 1 of commands issued subprocess.call fails every time build , run python script run. when run exact command being passed in shell myself however, runs perfectly. the method in python calling subprocess.call: @staticmethod def run_cmd(command, verbose): if verbose: logging.debug("running: '%s'\n" % ''.join(command)) else: log_path = ccplugin._log_path() command += ' >"%s" 2>&1' % log_path print "calling run_cmd" ret = subprocess.call(command, shell=true) if ret != 0: message = "error running command, return code: %s" % str(ret) if not verbose: message += ". check log file @ %s" % log_path raise c...

actionscript 3 - SharedObject, clicking every users button -

i have imageslider.swf , has 2 buttons. nextbtn pass next image , prevbtn go previous image. swf slide share app. want when presenter press of button, every slide show change( on every clients). happen on internet.not on localnetwork. import flash.display.loader; import flash.net.urlrequest; import flash.events.event; import flash.events.mouseevent; import fl.transitions.tween; import fl.transitions.easing.*; import flash.filters.glowfilter; import flash.filters.dropshadowfilter; import flash.utils.timer; import flash.events.timerevent; //*****************declaring variables*****************************// //the array has picture labels var myarray:array = ["barbecued chicken", "bread & rolls", "burger", "chicken chilly" , "awesome fish"]; var myglow:glowfilter = new glowfilter(0xffffff,1,10,10,255);// saving glow var myshadow:dropshadowfilter = new dropshadowfilter(6);// saving shadow applied later var totalimages=11; var...

coffeescript - Why Does Meteor Spacebars #each Tag Not Render Content? -

the {{name}} in below html not inject page when should "hello world". have tried remove {{name}} , put in simple "blah blah blah". page not show text. one error getting is: :1039:17: #each requires argument (compiling raffler.html) raffler.html <head> <title>raffler</title> </head> <body> <div id="container">{{> raffle}}</div> </body> <template name="raffle"> <h1>raffler</h1> <ul id="entries"> {{#each entries}} <li> {{name}} </li> {{/each}} </ul> </template> raffler.coffee if meteor.is_client template.raffle.entries = [{name: "hello world"}] also working off of tutorial: http://railscasts.com/episodes/351-a-look-at-meteor your code looks fine, maybe missed </template> , try this: if meteor.is_client template.raffle.entries = -> [name: "hello world...

html - Radio Buttons to PHP-MySQL -

how can value of radio button "gender selector" (male/female) php? need register.php form. tried googling didnt provide how value of how generate it. code <form action = "register.php" method = "post"> <input type="radio" name="sex" value="male">male<br> <input type="radio" name="sex" value="female">female </form> php: $sex = $_post['radiobutton=sex']; on page form: <form action='register.php' method='post'> <input type='radio' name='sex' value='male'/>male <input type='radio' name='sex' value='female'/>female <input type='submit' name='submit_sex' /> </form> on register.php: <?php if (isset($_post['submit_sex'])) echo 'gender ' . $_post['sex']; ?>

ruby on rails - Get user_data of a aws instance using AWS::EC2::Instance class -

i want user_data of ec2 instance instance. looked @ documentation of class aws::ec2::instance @ link http://docs.aws.amazon.com/awsrubysdk/latest/aws/ec2/instance.html and tried getting user_data this require 'aws-sdk' puts aws::ec2::instance.instance.user_data but think not right way works . can 1 let me know how user_data of instance. try this:- require 'aws-sdk' ec2 = aws::ec2.new( :access_key_id => 'access_key_id', :secret_access_key => 'secret_access_key') instance = ec2.instances['i-9e516a95'] puts instance.user_data note :- 'i-9e516a95' particular instance_id , make sure instance running.

ios - phonegap/cordova run issue -

i have installed newest version of cordova (phonegap) 3.4.1 on imac. downloaded helloworld app. built according documentation in platform guides @ command line. opened xcode (5.1.1) , opened helloword.xcodeproj file. see files expect under www directory. selected simulator , clicked build button. message build succeeded. and that's it. can't seem run it. command-r grayed out. can't find configuration allows build , run. when did native ios app development couple of years ago using xcode 4.x had option of build or build/run. don't see similar information now. basically want see freaking program run in simulator , friend google letting me down.

c - Ascii character encoding issue -

#include <stdio.h> int main() { char line[80]; int count; // read line of charecter printf("enter line of text below: \n"); scanf("%[ˆ\n]",line); // encode each individual charecter , display them for(count = 0; line[count]!= '\0'; ++ count){ if(((line[count]>='0')&& (line [count]<= '9')) || ((line[count]>= 'a')&& (line[count]<='z')) || ((line[count]>= 'a')&& (line[count]<='z'))) putchar(line[count]+1); else if (line[count]=='9')putchar('0'); else if (line [count]== 'a')putchar('z'); else if (line [count]== 'a') putchar('z'); else putchar('.'); } } in above code problem converting encoding. whenever compile code, compiler automatically converts encoding , unable required output. target output should li...

javascript - What version of SimpleDeclare do I need to run Booking Dojo? -

i'm trying run booking dojo project available @ https://github.com/mercmobily/bookingdojo . after running git clone, ran: $ npm install npm install not install correctly simpleschema-tingo , simpledblayer-tingo, had install them manually: $ npm install simpledblayer-tingo $ npm install simpleschema-tingo after installing modules, tried run again following commands: $ node server $ node_env='production' mongo_url="mongodb://$mongo_user:$mongo_pass@oceanic.mongohq.com:10082/$dbname" node server these first lines trace dump (same error appears both mongodb , tingodb): /home/bogdanbiv/webstormprojects/bookingdojo/node_modules/mongodb/lib/mongodb/mongo_client.js:424 throw err ^ typeerror: cannot read property 'prototype' of undefined @ /home/bogdanbiv/webstormprojects/bookingdojo/node_modules/simpledeclare/declare.js:137:57 @ array.foreach (native) @ declare (/home/bogdanbiv/webstormprojects/bookingdoj...

linux - Bash grabbing directory name to use in loop -

i want grab names of directorys create tar.gz file each for example, directorys beginning a: count = 10 ((k = 1 ; k < $count ; k++)); tar -cf adirname.tar.gz adirname sleep 1 done how can this? this create tarball each a* directory. for dir in a*/; tar -cf "${dir%/}".tar.gz "$dir" done the wildcard expands list of directory names loop over. trailing slash sets matches off directories included in expansion; trim tarball's filename simple variable substitution ( ${variable%suffix} expands variable's value suffix trimmed end if present; there corresponding ${variable#prefix} , number of other substitutions; see shell's man page.) the double quotes mandatory, although script work without them long there no file names whitespace in them. common oversight in many shell scripting tutorials.

php - CakePHP does not use my models -

Image
i have got these 2 cakephp v 2.4.5 models: class owner extends appmodel { public $name = 'owner'; public $hasmany = array('car'); } and class car extends appmodel { public $name = 'car'; public $belongsto = array('owner'); } in controller wrote: var $uses = array('owner', 'car'); public function test(){ $data = array( 'owner' => array( 'name' => 'me' ), 'car' => array( array('color' => 'red'), array('color' => 'blue') ) ); $this->owner->saveassociated($data, array('deep' => true)); } but cakephp created owner , forgets create cars: 1 begin 2 insert `test`.`owners` (`name`) values ('me') 3 commit this erm looks like: why cakephp not save cars? it's not possible give directly-working answer because: t...