Posts

Showing posts from July, 2013

ruby binary string compare -

i want clarify understanding of string comparison in ruby. how ruby compare binary strings? does (a) split strings on utf-8 characters, compare strings based on length of binary string in utf-8 characters , values of utf-8 characters, or (b) compare strings on byte level? it depends on version of ruby you're using in ruby 1.8, strings collection of bytes . in ruby 1.9, strings collection of encoded data . string comparisons in ruby 1.9 done on byte level, other operations regex matches not. best normalize string objects same encoding before comparing them.

How do I search and remove/append a row in Jquery or Javascript? -

if have table <table id="mytable"><tr><td>first thing</td><td>first value</td></tr> <tr><td>second thing</td><td>second value</td></tr> <tr><td>third thing</td><td>third value</td></tr> </table> how can use jquery or javascript search index of row text "second value" , remove it? possible create new row <tr><td>fourth thing</td><td>fourth value</td></tr> with click of button? have iterate through existing rows last index of row insert in? you can achieve using :contains() selector, remove() function, , append() function. don't need iterate through rows find you're looking for. to index: $("#mytable").find("td:contains('second value')").parent().index(); to remove it: $("#mytable").find("td:contains('second value')")....

objective c - Excel file into NSArray -

i have excel file data need use source table view. how can convert .xls plist file can parse nsarray? numbers app in iwork suite have option? thanks. the solution i’ve used in past export .xls tab-delimited file , use e.g. python script convert plist. it’s pretty easy, though providing sample code difficult because it’s pretty problem-specific.

deployment - ASP.Net MVC 3.0 "Error Executing Child Request" on Development Server but works fine on local machine -

here stack trace [nullreferenceexception: object reference not set instance of object.] hrorx.controllers.leftnavlinkscontroller.leftnavservices() in c:\common\pro\hrorx\controllers\leftnavlinkscontroller.cs:30 lambda_method(closure , controllerbase , object[] ) +78 system.web.mvc.reflectedactiondescriptor.execute(controllercontext controllercontext, idictionary`2 parameters) +263 system.web.mvc.controlleractioninvoker.invokeactionmethod(controllercontext controllercontext, actiondescriptor actiondescriptor, idictionary`2 parameters) +38 system.web.mvc.c__displayclass15.b__12() +128 system.web.mvc.controlleractioninvoker.invokeactionmethodfilter(iactionfilter filter, actionexecutingcontext precontext, func`1 continuation) +826410 system.web.mvc.controlleractioninvoker.invokeactionmethodwithfilters(controllercontext controllercontext, ilist`1 filters, actiondescriptor actiondescriptor, idictionary`2 parameters) +314 sys...

How to upload a file with Django -

i'm trying write form upload file django. admin form works fine, problem after click submit on form, form loses file selected (filename disappears , 'no file chosen' appears next 'choose file' button), , view won't validate form because file missing. form/view/file handler django example . forms.py class attachform(forms.modelform): class meta: model = attachment exclude = ('insp', 'contributor', 'date') views.py def handle_uploaded_file(f): destination = open('some/file/name.txt', 'wb+') chunk in f.chunks(): destination.write(chunk) destination.close() def attach(request, insp_id): if request.method == 'post': form = attachform(request.post, request.files) if form.is_valid(): handle_uploaded_file(request.files['file']) f = form.save(commit=false) f.contribut...

oracle - How to delete rows with bi-directional dependencies? -

i'm using oracle 10g express , trying delete records tables bi-directional constraints. i'm trying un-thread hundreds of tables , dependencies generated via hibernate (which can't changed @ point), here extremely simplified example: create table tablea (id number(19,0) not null, ..., rtablea_id number(19,0), primary key (id)); create table tableb (id number(19,0) not null, ..., rtableb_id number(19,0), primary key (id)); alter table tablea add constraint fka1 foreign key (rtablea_id) references tableb; alter table tableb add constraint fkb1 foreign key (rtableb_id) references tablea; trying delete entries either table returns following: edit: happens in case foreign keys prefixed sys_ ora-02292: integrity constraint (xxx.fka1) violated - child record found i've tried disable constraints attempts futile: ora-02297: cannot disable constraint (xxx.fka1) - dependencies exist i have wonder how data got in state in first place, since foreign keys not...

How to add a chart in iReport Designer 4.1.2 to my designer view? -

problem i have created blank report (mychart.jrxml).i cannot figure out how add chart blank report in designer view. what have tried i went samples folder under ireport folder of installation , opened 1 of samples has chart. in example (charts.jrxml) chart definition expanded in summary section on left tree navigation bar. so go blank (mychart.jrxml) file , try right click "summary" see if can add type of component cannot. update i have noticed in main navigation bar the palette menu item under tools empty. does know how? have pay edition accomplish this? thanks, official answer: click on window->palette open palette widnow on right

oop - Unexpected identifier in Javascript Object -

i creating following object: var iobreadcrumb = { breadcrumbs: [] add: function(title, url){ var crumb = {title, url}; this.breadcrumbs.push(crumb); } }; i getting unexpected identifier error. not sure coming from, in block of code. you need comma between members of object, cause of error cite. need put colon, rather comma, between key-value pair in crumb object. var iobreadcrumb = { breadcrumbs: [], // <-- comma here add: function(title, url){ var crumb = {title: url}; // <-- colon here this.breadcrumbs.push(crumb); } }; if want object there 2 members, 1 title , 1 url, may want this: var crumb = { title: title, url: url }; i don't know whether work breadcrumbs setup...

c++ - Can two classes access each other? -

if have 2 classes called , b, note: following doesn't compile. class { public: static void funca() {} void call_funcb() { b::funcb(); } // call class b's function }; class b { public: static void funcb() {} void call_funca() { a::funca(); } // call class a's function }; errors: error c2653: 'b' : not class or namespace name error c3861: 'funcb': identifier not found can call static functions of each class? you have this: class { public: static void funca() {} void call_funcb() ; }; class b { public: static void funcb() {} void call_funca() { a::funca(); } // call class a's function }; void a::call_funcb() { b::funcb(); } // call class b's function this allows a::call_funcb() see b declaration.

android - Single mobile app subscription model for multiple platforms -

if have iphone app, android app, , blackberry app, there way implement monthly or yearly subscription-based billing scheme such user need pay 1 subscription in order use app on device? problem each app store seems have stipulation fees required use app must paid through them can take cut. dropbox this, think can away because apps work free, , subcription offers more storage space. way type of billing app requires subscription in order used @ all? if not, adding sort of free functionality me around this? thanks. [edit] let me clear, question how can done legally . i'm running same issue caused financial times stop offering paper through native iphone app. difference between them , me, though, don't mind paying app markets cut. want know if possible; user can either order subscription through android market or app store, , if user isn't paying through both stores think i'm violating terms of 1 of stores. you try bango .but need implement possibility t...

javamail - Failing to parse this multi-part mime message body in Java -

i'm not writing mail application, don't have access headers , such. have block @ end of question. i've tried using javamail api parse this, using like session s = session.getdefaultinstance(new properties()); inputstream = new bytearrayinputstream(<< string parse >>); mimemessage message = new mimemessage(s, is); multipart multipart = (multipart) message.getcontent(); but, tells me message.getcontent string, not multipart or mimemultipart. plus, don't need overhead of whole javamail api, need parse text it's parts. here's example: multi-part message in mime format.\n\n------=_nextpart_000_005d_01cc73d5.3ba43fb0\ncontent-type: text/plain;\n\tcharset="iso-8859-1"\ncontent-transfer-encoding: quoted-printable\n\nstuff:\n\n please read stuff @ beginning of each week. =\nfeel free discuss throughout week.\n\n\n--=20\n\nmrs. suzy m. smith\n555-555-5555\nsuzy@suzy.com\n------=_nextpart_000_005d_01cc73d5.3ba43fb0\ncontent-...

c# - Change a font style in a TextBox -

i have several text box's input added. these input displayed in text box @ bottom of program after button clicked. i want make 1 of strings display italics in text box @ bottom of program. here have. private void button1_click(object sender, eventargs e) { string author; string name; string year; string title; string place; string publisher; name = textbox2.text + ", "; author = textbox1.text + ". "; year = "(" + textbox3.text + ") "; title = textbox4.text + ", "; place = textbox5.text + ", "; publisher = textbox6.text + "."; // output reference field richtextbox1.text = name + author + year + title + place + publisher; } what want display title string in italics. any great. thanks richtextbox1.find(title, richtextboxfinds.matchcase); r...

"Ruby-ish" way of creating a new instance of a class with parameters from multiple arrays? -

what "ruby-ish" way of creating new instance of class parameters multiple arrays, @ same index location in arrays? for example, i'm doing: array1.each_with_index { |element, i| myclass(element, array2[i], array3[i], array4[i]) } this works fine, don't feel ruby-ish. there way in ruby? -- derek [array1, array2, array3, array4].transpose.map{|args| myclass(*args)}

oop - Private classes in Objective C -

i pattern nested private class in objective c. requirements are: class not visible/accessible other classes. class can execute methods (i.e., not c struct) containing class members visible/accessible nested class considering comments, simplifying requirements: inner class may accessible other classes, not visible (similar using category hide private methods). inner class not have nested is still not possible? objective-c has no notion of private classes or private instance variables in formal declarative fashion. instead, visibility in objective-c entirely controlled declare something. if in header file, can imported else. if declared in implementation file, cannot (reasonably) imported and, therefore, private compilation unit. and "it", mean pretty can declared; class, global, etc... i.e. if stick @interface/@implementation pair class in .m file, class private compilation unit. of course, without namespaces, make sure class uniquely ...

javascript - ExtJS4: How to define DnD object method in DnD plugin -

i working on page drag grid tree , using gridviewdragdrop , treeviewdragdrop plugin. everything works fine, don't need drag node, need dragdata , dropdata, want stop drop action . i found notifydrop method in ext.dd.droptarget don't know how define in plugin config. help? lot! you can use beforedrop event, thing , @ end of event return false; in there, way not complete drop, that's special case have.

prototype - Delayed start of Ajax.PeriodicalUpdater -

in web-app have statusbar users number of new messages etc shown. use ajax.periodicalupdater refreshing every 60 sec. periodicalupdater doing first fetch on initialization when there no need data fresh on page load. so best practice start updater 60 seconds after page load? i using window.settimeout call function starts updater, there better? function statusbarupdate(){ new ajax.periodicalupdater({ success: 'statusbar' }, '/status', { method: 'get', frequency: 60, decay: 1 }); } window.settimeout("statusbarupdate()", 1000 * 60) there nothing in ajax.periodicalupdater 's source allows delayed start. however bit of syntactic sugar last line can neatened: statusbarupdate.delay(1000 * 60);

Custom validations in ExtJS -

iam using ext3.3 in application iam design email field in composite field,so when set vtype:email,its not shows error icon ,its shows redline in txtfield , how write custom validations in extjs phone numbers , numaric values please me when iam using ext.apply(ext.form.vtypes, { phone: function (value, field) { debugger; return value.replace(/[ \-\(\)]/g, '').length == 10; }, phonetext: 'wrong phone number, please make sure contains 10 digits', phonemask: /[ \d\-\(\)]/ }); its shows error object not support property thanks in advance use msgtarget : 'side' field see error icon. see here list of vtypes : http://www.sencha.com/forum/showthread.php?4271-more-vtypes !

hibernate - Shared sequence generator for IDs and DB scheme creation using hbm2ddl -

all. have issue db scheme generation via hbm2ddl. want use shared sequence generator private keys. defined once in entity. @entity @sequencegenerator(name = "my_sequence_generator", sequencename = "my_seq") public class myentity implements serializable { .... } then want use sequence generator ids. public class someentity1 implements serializable { @id @generatedvalue(strategy = generationtype.sequence, generator = "my_sequence_generator") long id; .... } public class someentity2 implements serializable { @id @generatedvalue(strategy = generationtype.sequence, generator = "my_sequence_generator") long id; .... } when run hbm2ddl ant task exception: [hibernatetool] javax.persistence.persistenceexception: org.hibernate.annotationexception: unknown id.generator: my_sequence_generator [hibernatetool] org.hibernate.annotationexception: unknown id.generator: my_sequence_generator is issue or i'm doing w...

asp.net - Handling application-wide events without Global.asax -

my project has no "global.asax" various reasons , can't change (it's component). also, have no access web.config, httpmodule not option. is there way handle application-wide events , "beginrequest" in case? i tried , didn't work, can explain why? seems bug: httpcontext.current.applicationinstance.beginrequest += mystaticmethod; no, not bug. event handlers can bound httpapplication events during ihttpmodule initialization , you're trying add somewhere in page_init (my assumption). so need register http module desired event handlers dynamically. if you're under .net 4 there news - there preapplicationstartmethodattribute attribute (a reference: three hidden extensibility gems in asp.net 4 ): this new attribute allows have code run way in asp.net pipeline application starts up. mean way early, before application_start . so things left pretty simple: need create own http module event handlers want, module initi...

Syncing existing git with existing SVN repository -

okay, made mess. have svn repository code , have local git repository in work, branch, etc.. used commit things time time git svn using git-svn. got new computer , cloned git repository 1 other. tried use git-svn afterwards, due new version , me being not careful enough configuration somehow lost. used git svn init , clone history in svn, situation looks this: o--z--o--....--x--o--o....--o (master) | o--o--o--....--x (remotes/git-svn) x marking state in both repositories in same state (as master , git-svn in sync on old machine). now, i'd commit x head master svn repository, when use git svn dcommit -n shows diffs way z. how can sync git-svn , git , svn again (so can use dcommit commit stuff again)? is possible go x , use git svn set-tree x (because current svn holds version) , go head git svn dcommit ? don't want (blindly) try stuff on svn, there lot of more stuff in (by many other people) don't want screw up. git svn dcommit looks in his...

sql - Dynamically inserting multiple rows to a table -

i need insert multiple records table. number of records depend on result of query. example: insert table1(colm1, colm2, colm3) values(select clom1 table2, constant, constant) in query colm2 , colm3 have constsnt values, value of colm1 differs based on ouput of table2 , , number of records inserted depend upon number of values table2 . can give me solution? insert table1(colm1,colm2,colm3) select clom1,constant,constant table2 this should work

php - Flex + Air App to Database? -

i'm trying create air app using flex 4.5. app interacts livecyle collaboration service support screen-sharing , webcam chatting in desktop. i'm looking database (not local sqlite) store , load facebook wall-sized data. is, many users can store , load database in short amount of time (synchronization issue). also, i'll set database in mac mini snow leopard server. i came these 3 solutions: 1) mysql using amfphp - access mysql via server-side language. 2) mysql via assql library - direct access mysql, bad security. 3) blazeds/livecyclees , coldfusion - java ee backend, coldfusion commercial, , suited large project? which 1 best solution small , mid-sized project? or recommend other solution? thanks. coldfusion suited large projects. shouldn't matter it's commercial unless have budget doesn't fit into. but, if livecyclees more expensive if cost issue you'll have use blazeds. as "wall-like" feature facebook has several thin...

lua - Corona/Box2D detect collision with non-moving static objects -

for posting reasons here's simple version of i'm trying do. on screen have simple circle object static , doesn't move. user can drag , drop straight line. if line passes through circle i'm hoping collision event triggered. it appears unless 1 of objects moving collision never detected. can detect collision when line drawn? collision event function onhit(e) print("hit"); end runtime:addeventlistener("collision", onhit) touch event local startx = 0; local starty = 0; local endx = 0; local endy = 0; function ontouch(e) if(e.phase == "began") startx = e.x starty = e.y elseif(e.phase == "moved") endx = e.x endy = e.y elseif(e.phase == "ended") local line = display.newline(startx, starty, endx, endy) line:setcolor(100, 100, 100) line.width = 2 physics.addbody(line, "static", { }) end end runtime:addeventlistener(...

javascript - jQuery video onpause play animation -

i building site has thumbnail based navigation , large image or video background. see here http://www.sarahnwatson.com . right have if click on video navigation menu animates out of way can see video better. want make on pause menu animates in. here code //clicking on thumb, replaces large image or video $list.find('.st_thumbs img').bind('click',function(){ var $this = $(this); $loader.show(); var src = $this.attr('alt'); if (/\.(mp4|ogv)$/i.test(src)) { var $currimage = $('#st_main').children('img,video').first(); $("<video class='st_preview' controls='controls' id='video' preload='auto'>").attr({ src: src }).insertbefore($currimage); $('.st_overlay').hide(); settimeout('playvid()', 5000); $sociallinks.animate({ ...

javascript - Youtube API automatically starts playing songs -

i using below code play youtube shared videos want user start videos page loaded starts playing video. want user click on link should start playing <script type="text/javascript"> function updatehtml(elmid, value) { document.getelementbyid(elmid).innerhtml = value; } function setytplayerstate(newstate) { if(newstate==3 || newstate==-1) { $('ld').show(); } else { $('ld').hide(); } } function onyoutubeplayerready(playerid) { ytplayer = document.getelementbyid("myytplayer"); setinterval(updateytplayerinfo, 250); updateytplayerinfo(); loadnewvideo('<?=$w ?>'); ytplayer.addeventlistener("onstatechange", "onytplayerstatechange"); } function onytplayerstatechange(newstate) { setytplayerstate(newstate); } function minute(secvar0) { // initial data, in s...

php - How to solve this without multiple inheritance? -

i have class named controller_home . should inherit controller_permissions , controller_template . class prefixed controller_ must inherit controller class. if multiple inheritance supported in php (my case), this: class controller_home extends controller_permissions, controller_template { and controller_permissions , controller_template : controller_permissions extends controller { controller_template extends controller { now need this: class controller_home extends controller_template { class controller_permissions extends controller_template { controller_template extends controller { okay, works! now need use controller_template without permissions (in controller_permissions ). how without duplicating code? don't want class controller_templatewithoutpermissions . controllers, templates , permissions example. the common alternative multiple inheritance use composition. makes relationship "has a" opposed "is a" relationsh...

c# - Ignoring incoming data in TcpClient / NetworkStream -

for communication third-party software, need establish unidirectional connection on tcp. software needs send data other side , never read data. i'm using tcpclient. happen if there incoming packets nonetheless , never read them? pile somewhere , lead errors or like? how configure tcpclient ignore or discard incoming data? the whole design not do, can't change other software , need bear this. some nice hints on bits inside tcpclient helpful! i think of data buffered, waiting read it. not sure how large buffer size is, however. don't think lead errors immediately, if sender expecting able write, @ point write may time out , other party may choose close connection.

javascript - Double Key Totals PHP Resultset into HTML Table -

i've resultset wich sums totals n situations , n different codes period. data comes sql select *, count(flda) ca table ('... month/year ...') group sit, cod order count(flda) desc; ok here's table want: +--------------------------------+ | d/l | sit. | sit. b | sit. n | +-----+--------+--------+--------+ | c91 | 10 | 05 | 10 | +-----+--------+--------+--------+ | c93 | 15 | | | +-----+--------+--------+--------+ | cn. | 07 | 01 | | +-----+--------+--------+--------+ | tot | 22 | 06 | 10 | +--------------------------------+ so corresponding array (resultset) table above should like: sita, c93, 15; sitn, c91, 10; sita, c91, 10; sita, cn., 07; sitb, c91, 05; sitb, cn., 01; note number of situations (collumns) , codes (rows) will vary . , there cases in resultset array there should no value col x row combination. obviously, totals should calculated afterwards. the question is... wich best a...

c - set_thread_area in strace -

using strace on program: strace outputs same extract output in debian , centos except set_thread_area. (the program's version same on both linuxes.) why different ? there way output same on both linuxes ? can difference programmed in c ? package missing in debian/centos ? set_thread_area({entry_number:-1 -> 6, base_addr:0xb7fb16c0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 open("/dev/urandom", o_rdonly) = 3 read(3, "\242\177)", 3) = 3 set_thread_area(0xff9db33c) = 0 edit first: centos i686 second: debian x64 compiled -m32 are asking reason addresses different, or why strace formats output differently? if it's latter, suspect you're dealing 2 different versions of strace , 1 possibly outdated. however, looks odd this: set_thread_area(0xff9db33c) = 0 the address 0xff9db33c not valid userspace address on i38...

How to save the contents of MATLAB's Command Window to a file? -

i want save in "command window" file automatically. there way it? you have few options available saving content command window: you can using diary command. automate records modifying startup.m file turn on text logging: diary('mytextlog.txt'); %# text appended if file exists and modify finish.m file turn logging off: diary('off'); this automatically store entire text content of command window every matlab session, grow rather large text file. another option besides using diary command , modifying startup.m , finish.m files start matlab using -logfile option : matlab -logfile "mytextlog.txt" although i'm not sure if overwrite text file or append each time start matlab. if you're wanting save output evaluating 1 or more expressions, can use evalc function evaluate string containing expression , capture output go command window in character array. can print character array file using fprintf . finally, if ...

How should I remove the first occurrence of an object from a list in Scala? -

what best way remove first occurrence of object list in scala? coming java, i'm accustomed having list.remove(object o) method removes first occurrence of element list. i'm working in scala, expect method return new immutable list instead of mutating given list. might expect remove() method take predicate instead of object. taken together, expect find method this: /** * removes first element of given list matches given * predicate, if any. remove specific object <code>x</code> * list, use <code>(_ == x)</code> predicate. * * @param toremove * predicate indicating element remove * @return new list selected object removed, or same * list if no objects satisfy given predicate */ def removefirst(toremove: e => boolean): list[e] of course, can implement method myself several different ways, none of them jump out @ me being best. rather not convert list java list (or scala mutable list) , again, although work. us...

xml - xsl to remove all 'string' type quotes before converting to json output for any boolean values -

i using xsl convert xml json. the josn boolean values showing myboolean:"true" . should showing myboolean:true (without quotes around true). how can make xsl remove 'string' type quotes before converting json output boolean values? you can use translate() function strip out double-quote " , single quote/apostrophe ' characters our string value, translating them nothing: translate(.,'&quot;&apos;','')

c# - httpwebrequest gives timeout until restarted -

i working on desktop application developed in c# (.net environment). this application connects remote server using httpwebrequest . if due reason pc disconnected internet , re-connect application gives request timeout httpwebrequest until restart whole application , if again add new thread application after network d/c works fine. is there way reset network or can tell me how work? //my code is.. public string request(string add, string post, int time, string reff, int id, int rwtime) { try { if (rwtime == 0) { rwtime = 100000; } string result = ""; string location = ""; // create web request httpwebrequest req = webrequest.create(add) httpwebrequest; req.readwritetimeout = rwtime; req.keepalive = true; req.headers.add(httprequestheader.acceptencoding, "gzip,deflate"); req.accep...

django - A good static file server as a service -

i'm looking easy use static file service can use application server. i'm using django , need simple service let's me host static files can call templates. it best if service had easy way secure files , had way integrate secure file sending. i use webserver have, i'm testing heroku , doesn't host static files. i'd use other webservers, i'm looking can handle secure files better ngix server. i'm not great admin hoping easy-to-use api based or static server host. essentially want described in here: http://forum.slicehost.com/comments.php?discussionid=1929 but server not "local" application server, http://wiki.nginx.org/nginxxsendfile requires. well depends on need. looking cdn, go google , search cdn , spend few hours picking 1 out. if you're looking store user uploaded files perhaps try s3. if looking how deal in django. that's static_url (or media_url) setting handles (as {{ media_url }} idiom in templates (repl...

android - AlarmManager doesn't start the alarm on time -

i try use alarmmanager setup alarm happens after seconds now. here code: alarmmanager = (alarmmanager)context.getsystemservice(context.alarm_service); intent intent = new intent(alarm_action); pendingintent alarmintent = pendingintent.getbroadcast(getbasecontext(), 0, intent, pendingintent.flag_update_current); calendar rightnow = calendar.getinstance(); rightnow.add(calendar.second, numofsecond); am.set(alarmmanager.rtc, rightnow.gettimeinmillis(), alarmintent); for example, if rightnow 8:00am , hope alarm happens after 14400 seconds, 12:00pm, numofsecond set 14400. when code runs happens alarm not happens @ 12:00pm, delayed 1 or 2 minutes, or 5 minutes! 1 know heck happened here? try alarmmanager.rtc_wakeup instead.

node.js - Redis Sub/Pub - Get latest published content? -

using nodejs , redis sub/pub system. when log web app want latest published content once subscribe via nodejs. possible? when login want user see content channel subscribed to. right when login there no data, when publish content channel shows up, refresh page , content not show again. edit when person logs system instead load results db via php there subscribe channel via nodejs , update rows via redis sub/pub? how work? i think best answer anytime data published channel @ same time store data in redis using channel name key. when user logs in grabs data in redis, displays subscribe channel waiting updated information. agree or there better way?

Get Android source code -

i want know if can or when can open website : http://android.git.kernel.org/ read this . kernel.org hacked while ago. can download android source mirror https://github.com/android .

networking - how to save request and resend in android app -

in app trying send data network. app getting slow or gets crashed when network not available. how save request later , resend once phone has network coverage again? how this......... @aleadam right, should post data later once internet connected, can check intent connection method. public boolean isnetworkavailable() { connectivitymanager connectivitymanager = (connectivitymanager) getsystemservice(context.connectivity_service); networkinfo activenetworkinfo = connectivitymanager.getactivenetworkinfo(); return activenetworkinfo != null; } but method require import android libraries here these import android.content.context; import android.net.connectivitymanager; import android.net.networkinfo; i hope help.

java - Whats going on behind the scenes with method - public static long parseLong(String s,int radix) -

i need generate consistent unique long based on name of package. instead of using "convert string long" in eclipse think can achieve same task @ run time using method public static long parselong(string s,int radix) ? i think need use - long.parselong("hazelnut", 36) returns 1356099454469l which got question - how convert string long in java? why need set radix 36 when converting string contains characters ? well, you're treat number in base 36. example, string "012" mean 2 + 1 * 36 + 0 * 36 2 . when run out of digits, go letters - "abc" mean 12 from 'c' + 11 from 'b' * 36 + 10 from 'a' * 36 2 . if understand how hex works, it's same except using characters in latin alphabet. it'll fail not in 0-9, a-z, a-z though - , it'll fail reasonably long strings; long works 2 63 you'll past reasonably in base 36. "hazelnut12345" fails, example. oh, , case-insensitive, value ...

iphone - UIBarButtonItem Taking Entire Width of UIToolbar -

Image
i have uitoolbar uibarbuttonitem created in interface builder. uibarbuttonitem bordered button contains custom image. the button takes entire length of toolbar. have tried using different images, changing width of button... don't know else do. stretches across entire toolbar. if use 1 provided "identifiers" (camera, trash, compose...) button appears normal size. how looks in interface builder how looks when run on iphone solution after more tinkering, here found: if create new uitoolbar , add custom image uibarbuttonitem, works fine - connect uibarbuttonitem iboutlet, goes large. had specify uibarbuttonitem's width in code, via iboutlet. i'm not expert, think might have how frame defined in "sizing inspector", maybe show screenshot of settings?

ios - how to determine in applicationDidBecomeActive whether it is the initial iPhone app launch? -

how determine in how determine in uiapplicationdidbecomeactivenotification whether initial app launch?whether initial app launch? that initial start of application, opposed subsequent didbecomeactive's due application being put in background , foreground (e.g. user goes calendar app) in applicationdidfinishlaunching:withoptions: put this: [[nsuserdefaults standarduserdefaults] setbool:yes forkey:@"alreadylaunched"]; [[nsuserdefaults standarduserdefaults] synchronize]; then, in didbecomeactive : if ([[nsuserdefaults standarduserdefaults] boolforkey:@"alreadylaunched"]) { // not initial launch... } else { // initial launch... }

Suppress Error Messages in Access -

i have access form runs query. runs query using vba code , searches table text fields , number fields depending on field choose on combo box in form. i have left note if wish search text field must enter double quotes or code not work. however, if user not follow these directions popup exlains coding issue options debug , end. not want them see message. is there way suppress error message , write own? edit: dim dbscurrent database dim qrytest querydef varwhere = "where inclusiveparent." & combo0.value & "=" & text2 varwhere = "select location, icmservice, icmscript, thresholdvariable, pbxvdn, domestic, firstsecondlook, dnis, tollfree, outdial, description, carrier, defaulttollfree, blockedroute, variable3, variable4, variable5, variable9, valuescrvdn, cvp inclusiveparent " & varwhere 'filter frmcustomers based on search criteria 'dim dbscurrent database 'dim qrytest querydef ...

c++ - function has effects on the other functions that run before it did -

{ int x = hfilter * threebythree(i,j,getdata(),getnumrows(),getnumcols()); int y = vfilter * threebythree(i,j,getdata(),getnumrows(),getnumcols()); int value = floor(sqrt(x*x+y*y)); //evil setvalue function setvalue(i,j,value); } image image::threebythree(int globali,int globalj, int** matrix,int row,int col) { image neighbor; neighbor.setnumrows(3); neighbor.setnumcols(3); neighbor.allocatemem(); for(int i=0; i<3; ++i) { for(int j=0; j<3; ++j) { if((i+globali-1 >=0) && (j+globalj-1 >=0) && (i+globali-1 < row) && (j+globalj-1 < col)) { //cout<< matrix[i+globali-1][j+globalj-1] << " , "; neighbor.setvalue(i,j,matrix[i+globali-1][j+globalj-1]); } else { neighbor.setvalue(i,j,0); } } } for(int i=0; i<3; ++i) { ...

Why Visual Studio in C++ is not as intelligent as it's in C#? -

i'm wokring on homework in c++ in visual studio 2010, i've found visual studio not wonderful in c#. no intellisense , no code formating , stupid load of error messages might gone togother if 1 error has been fixed. why that? microsoft has not been putting effort c++ tools since .net appeared. in lot of ways, current ide worse visual c++ 6. here visual c++ team's blog entry recent c++-related work , why there no intellisense c++/cli: http://blogs.msdn.com/b/vcblog/archive/2011/03/03/10136696.aspx

How to load thrift client in Erlang -

i wish use scribe export data erlang application, have problem running thrift client. install thrift, in erlang lib directory. i'm using: thrift-0.6.1 i found example code connect erlang via thrift scribe: {ok, c} = thrift_client:start_link("localhost", 1463, scribe_thrift, [{strict_read, false}, {strict_write, false}, {framed, true}]), but erlang returning error: ** exception error: undefined function thrift_client:start_link/4 when try run application:start(thrift) , moment see code completion thrift* 7> thrift_client: call/3 close/1 module_info/0 module_info/1 new/2 send_call/3 and there no method start_link . i think these days want thrift_client_util:new(host, port, protomodule, options) which in case be: thrift_client_util:new("localhost", 1463, scribe_thrift, ...

php - PHP5 performance comparison, Windows and Linux -

Image
i have question symfony2 performance. i have been developing symfony2 under ubuntu 11.04 few weeks now, apache 2.2.17, php 5.3.5, apc 3.1.9, no xdebug on dev environment, time given on symfony2 toolbar never above 70 ms. today, i've tried install app on windows 7 environment : wampserver 2.2, php 5.3.8, apache 2.2.21, apc 3.1.7, no xdebug the computer on windows environment better 1 on ubuntu (ssd, quad core, etc). and when run application on dev environment, toolbar indicates minimum of 300 ms. so, know how possible ? thanks ! edit : found link subject : http://fossplanet.com/f6/%5bsymfony-users%5d-symfony2-slow-windows-xp-116465/ i noticed problem file_exists function (using webgrind). so, ideas ? maybe subject has been discussed, surprised not find related. tl;dr; set realpath_cache_size value > 1000 edit 2: problem solved in pr: try set php.ini's realpath_cache_size value > 1000 symfony requirement added fixing issue: https://gith...

Particular camera setup and calibration process with opencv -

this first post , delighted part of community. i've 2 webcams , want use detect 2d coordinates of center of white tennis balls. , find 3d coordinate of centers. cameras setup this. there's circular region of radius 7 feet , cameras placed on opposite end of each other means if camera1 placed @ 0 degree of circular region camera2 placed @ 180 degree of same region on straight line opposite of each other on circumference of circular region. i need calibrate cameras , need find intrinsic , extrinsic parameters.i'm using opencv this. can use cvstereocalibrate() camera setup? i'm asking because if @ camera setup see there's point on camera1 , camera2's captured image collinear epipoles of both cameras. epipolar line point. issue calibration procedure? if yes possible tell me how solve problem? this camera setup stereo cameras toed-in (really cross-eyed :). calibrate need correspondence points each image. can find these around edges ... way aro...

converting format (from date to numeric) using SAS -

i working dataset in sas, containing many variables. one of these variables date variable , has date/time format. looks this: 12feb97:00:00:00 27mar97:00:00:00 14apr97:00:00:00 now thing convert variable numeric format. , following result (based on shown 3 examples): 199702 199703 199704 do have ideas how it? read through many docs, pdfs etc. still not find proper solution yet. thank much! first, need extract date datetime variable. can use datepart function: date = datepart(var); then, want put variable (which still coded date number) number can read year , month. putn : date_as_num = putn(date,'yymmn6.');

drupal - Random uneditable node -

i have come across problem in past never solved it. i on verge of finishing drupal site client. created 2 content types , gave him permissions necessary edit occurrence of these node types. the strange problem client can edit node of type product_type except 1 particular node of same type . in other words, nodes of type product_type editable except node/3. can please me. do have node access module installed, content access or taxonomy access control? if do, there per-node permissions set , client's role doesn't have permission edit node, or tagged particular taxonomy term prevents him editing it. if don't have node access modules installed, link "edit" missing in tabs section of page? can client type in "http://example.com/node/3/edit" , reach edit screen way? if supply answer these questions in comments, i'll edit answer best can.

iphone - Testing an Application on device in xcode 4 -

i trying test iphone app in xcode 4 , telling me don't have valid provisioning profile though do. wrong? there lot of factors cause this. more information needed. primary things suggest are: is device authorized in provisioning profile (using developer portal or team provisioning profile) have downloaded latest profile developer portal? , made sure not expired? have specified correct provisioning profile in build settings project? if have had make changes profile or renew have re-download , install in xcode , change build settings point new 1 though has same name.

python - How to remove trailing whitespace in PyDev plugin for Eclipse -

ideally, eclipse should remove trailing whitespace when save file. know there option in c++/java plugins eclipse, couldnt find 1 pydev. there one? if not, whats easiest way achieve this? check in: preferences > pydev > editor > code style > code formatter and check "right trim lines?" check box.

cmd - How to run Windows remove command from NAnt? -

i want execute remove command inside nant script. how can that? i'm not aware of command called 'remove' in msdos. did mean 'rm'? assuming meant 'rm' here example of how work ... <tasks> <exec> <executable>$(windir)\system32\cmd</executable> <buildargs>/c "rm somefile.txt"</buildargs> </exec> </tasks>

Batch traverse subolders and rename files -

i traverse folder , it's subfolders, keep counter variable of current file , rename $counter$existingfilename. e.g. $count = 1; foreach $file in $folder { $file.name = $count + $file.name; $count++; } the person can answer hero! :) btw using windows 7. all right, while pondering on questions in comment post (or maybe still making way site read them), here's trial shot: @echo off set "rootdir=%~1" if "%rootdir%"=="" set rootdir=. set cnt=0 /r "%rootdir%" %%f in (*) ( set /a cnt+=1 setlocal enabledelayedexpansion rename "%%f" "!cnt!%%~nxf" endlocal ) this rename files prepending names numbers, this: 1file.txt 2program.exe ... if like, can have way: 00001file.txt 00002program.exe for you'll need make 2 changes above script (highlighted in bold): @echo off set "rootdir=%~1" if "%rootdir%"=="" set rootdir=. set cnt=10000 /r "%ro...

c - for-loop left after one iteration -

i'm encountering problem , don't why. used exact same loop before test (without inside code) , worked. i'm not programming newbie (though c newbie), feel one. replaced length hard coded number, doesn't change anything. jobstatus() uses for-loop works fine. appreciated! ps: don't mind if / else-if part. desperation move because cant find problem, know don't need last else if etc. thanks in advance #include <stdio.h> #include <stdlib.h> short jobs[] = {6,13,7,3,4,9,10,11}; short table[13][10]; short q,i,j,k,diff; short sum; void jobstatus(short a){ printf("jobstatus:"); for(i=0;i<a;i++){ printf(" %i",jobs[i]); } printf("\n"); } int main(){ // berechne anzahl der jobs short length = sizeof(jobs)/2; printf("jobs: %i\n", length); /* für alle quanten q for(q=0;q<13;q++){ // schreibe das jeweilige quantum in die erste spalte jeder zeile table[q][0]=(q+1); gehe jeden job durch*/ ...

asp.net mvc - Difference between anchor link & window.location? -

i have link below: <a href='@url.action("myaction","mycontroller", new searchcriteriaaffaire { page=3, pagesize=5 }, null)'>test1</a> this links works. received search criteria in action page. now, have button javascript below: <button id="buttontest2">test2</button> <script language="javascript"> $("#buttontest2").click(function () { document.location = '@url.action("myaction","mycontroller", new searchcriteriaaffaire { page=3, pagesize=5 }, null)'; }); </script> this button doest' work. mean, didn't receive search criteria in action page , don't know why?? it drives me crazy! test1 , test2 produces same url (i check in 'view source code' right clicking on html page): /?sortby=none&amp;page=3&amp;pagesize=5' any appreciated. try : <button id="buttontest2">test2</b...

How to set key binding for 'Team|Show history' in Eclipse with MercurialEclipse in PyDev perspective? -

i'm trying set key binding showing mercurial history of active file ( team|show history in context menu) in pydev perspective. see in mercurial category in window|preferences|general|keys pertaining history show root history command. after setting key binding command , pressing appropriate keys nothing happens. don't see command of interest pertaining history in team category in same window. problem seems similar 1 svn key bindings described in svn key bindings not working in eclipse question. however, in customize perspective dialog pydev perspective, on command groups availability tab there's no mercurial entry analogues svn entry mentioned in above question. i'm using eclipse indigo, version: 3.7.0, build id: i20110310-1119, pydev 2.0.1 , mercurialeclipse 1.8.1 this might have been solved in meantime, in current indigo version (eclipse php developers 3.0.2 mercurialeclipse 1.9.1) show history command available in mercurial category of key s...

asp.net - HTML editor and image upload to server -

in asp.net, when work html editor, include images , text. how images upload specific folder in server , saved relative path in db. need concept cms. why need store image's relative path in db ? there no need, because content html saved in db , when retrieve content particular image shown in content. as far have used ck editor , there setting required in config file set path images stored when user adds images in content.

objective c - Pausing iteration of a for loop to wait for user input -

i wrote for loop iterating through array of objects. asking myself if it's possible break iteration of loop until user clicks on button calls ibaction ? for (int = 0; < [array count]; i++) { // object // wait action method called // user clicked action go on } you can adapt code fit case. "unrolls" loop multiple messages. start sequence [self doitforindex:[nsnumber numberwithint:0]]; - (bool)candoitforindex:(nsnumber *)i { // return yes if want go ahead // (e.g. test bool set in response user tapping button } - (void)waitforindex:(nsnumber *)i { if ([self candoitforindex:i]) { // clean // repeat i+1: [self doitforindex:[nsnumber numberwithint:[i intvalue]+1]]; } else { [self performselector:_cmd withobject:i afterdelay:0.01f; } } - (void)doitforindex:(nsnumber *)i { if ([i intvalue] < lastindex) { // have [self waitforindex:i]; } // else you're done } ...

windows - Escape double quotes in parameter -

in unix run myscript '"test"' , "test" in windows cmd 'test' how can pass double-quotes parameter? know how manually cmd window don't have write program test program. i cannot reproduce symptoms: if try myscript '"test"' batch file myscript.bat containing @echo.%1 or @echo.%~1 , quotes: '"test"' perhaps can try escape character ^ this: myscript '^"test^"' ?

Retrieving and displaying the Disk Volume Serial number in NSIS -

i using nsis(hm nisedit 2.0.3 editor) building setup(s) of application. having requirement 1 of setups use disk volume serial number(in hexadecimal format).i need display same in message box. can please post me complete piece of script getting disk volume serial number displaying in message box? this page describes how retrieve serial number in hex format: http://nsis.sourceforge.net/get_disk_volume_serial_number so need include function in script: function showdiskvolumeserialnumber !define getvolumeinformation "kernel32::getvolumeinformation(t,t,i,*i,*i,*i,t,i) i" system::call '${getvolumeinformation ("$0",,${nsis_max_strlen},.r0,,,,${nsis_max_strlen})' intfmt $0 "%08x" $0 messagebox mb_ok $0 functionend and call this: strcpy $0 "c:\\" call showdiskvolumeserialnumber obviously can replace drive letter whatever ensure has double trailing backslash .