Posts

Showing posts from March, 2011

Ruby: Ways to prevent cucumber reduncancies? -

does have idea how make shorter , less redundant: feature: nosql scenario: flatfile user wants have flatfile storage classic jekyll cms. when case should make sure adhere classic folder , file structure, , store generated content in _site unless user decides want generation stored inside of memcached, should go ahead , use that. given have chosen flatfile storage site when request page, "the_page" , have chosen flatfile generation should pull page "_site" given have chosen flatfile storage site when request page, "the_page" , have chosen memcached generation should pull page memcached i see repeated text , though cucumber meant people communicate seems it's made things perhaps "too dumb" because of repetition in types of scenarios? unless missing something. there other small problem, how make 1 feature have dependency of feature? example memcached feature how require feat...

android - How to play, pause and stop a song with only one button? -

i have tried make application in android play, pause , stop song 1 button only. can show me how can make application? final button bplay = (button)findviewbyid(r.id.bplay); mediaplayer song1 = mediaplayer.create(tutorialfour.this, r.raw.fluet); button bstop = (button)findviewbyid(r.id.bstop); bplay.setwidth(10); song1.setoncompletionlistener(new oncompletionlistener() { public void oncompletion(mediaplayer mp) { bplay.settext("play"); } }); bplay.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { // todo auto-generated method stub b=true; if(bplay.gettext().equals("play") && b==true) { song1.start(); bplay.settext("pause"); b=false; } else if(...

php - Any better way to save dates in db than time()? -

i used save dates in db int(11) time() . considering limitation of time() there better way save that? i not use database own date type (and db own date functions). thanks ok, comments, understand problem using time() we're looking represent dates outside 01/01/1970 whenever/2038 range. in case, think it's best format dates db ymdhis , stored in bigint (or ymd in int if time isn't needed). can use date_create("now")->format($fmt) instead of time() , , $fmt either 'ymd' date-only or 'ymdhis' date+time this gives latest date somewhere in 922,337,203ad , earliest in -922,337,203bc time, or 214,748ad -214,748bc in int no time.

php - CodeIgniter authentication concept issue -

i've made ci authentication controller allowing user log site, , after login i'm redirecting him visited url keep using: $this->session->set_flashdata( 'return_url', current_url() ); unfortunately causes problem. every time when user opens more 1 tab in browser variable being overwritten , after successful login user redirected same url in tabs. so question is: is possible load custom controller inside my_controller? ( my_controller class extends ci_controller ) i tried using (inside constructor of my_controller ) didn't worked out: $ci =& get_instance(); $ci->router->set_class('authentication'); $ci->router->set_method('login'); edit: appreciate other ideas of solving problem. a solution not save return url in session var, pass around in get/post parameter (in case of get, encoded, base64 ie.). addition have standard return url if no (valid) return url set --- edit why talking base64 when php has fu...

tsql - How do I insert a row in T-SQL where there are only auto-generated columns? -

i have table this: create table [dbo].[traceable]( [traceable_id] [uniqueidentifier] not null constraint [df_traceable_traceable_id] default (newsequentialid()), constraint [pk_traceable] primary key clustered ( [traceable_id] asc )with (ignore_dup_key = off) on [primary] ) on [primary] how insert row table? doesn't work: insert traceable() values() it errors on values() clause (incorrect syntax near ')'). taking out brackets doesn't work either. insert traceable default values; or insert traceable values (default);

Calling ASMX Service from jQuery Client Side Code -

i have vs 2010 project locally have asmx service running locally. created vs 2010 project has consume local asmx service. reason whenever trigger service gives me 500 internal service error. both applications running on separate ports. $.ajax( { type: "post", url: "http://localhost:22059/mobile/hocwebservice.asmx/getcategories", data: "{}", datatype: "json", contenttype:"application/json", success: function (response) { alert(response); } } ); both applications running on separate ports. that's problem. violating same origin policy restriction . cannot send ajax requests services not hosted on same origin page containing script (different ports => different domains).

iphone - UI ScrollView Hiding in iPad Landscape mode -

i have added 1 uiscrollview , 2 uiimageview it. shows fine in potrait mode. hides in landscape mode. running xcode n simulator , implemented method - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation. i new ipad programming , lil stuck. appreciate help. - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { if(uiinterfaceorientationislandscape(interfaceorientation)) { [self.view insertsubview:scrollview abovesubview:imageview]; } else { [self.view insertsubview:imageview abovesubview:scrollview]; } return yes; }

extjs - Data within Ext.Panel without XTemplate? -

is there way apply data "regular" fields , subitems without using xtemplate? my code looks like: var panel = new ext.panel({ data: mydatablock defaults: { data: mydatablock } title: 'name: {name}' items: [{ xtype: 'panel', title: 'more: {moredata}' }] }); what required have proper substitudes data form "mydatablock" ? cheers what mean "regular" fields? the data property of panel initial data want rendered, , gets rendered using template. can specify custom template rendering if wish, either way has use template extjs knows how render content. look @ source code component : if (this.data) { this.tpl[this.tplwritemode](contenttarget, this.data); delete this.data; } data : initial set of data apply tpl update content area of component.

python - Achieve AVRCP using Pybluez in Linux -

i want make pc avrcp bluetooth controller (ct) , handle device supports avrcp bluetooth profile has done using python scripting. can achieve pybluez. if yes can 1 give me pointer of how achieve this. thanks in advance there new linux bluetooth stack supporting avrcp. see here . there seems implementation of avrcp in python here . have @ , try it.

objective c - dots, commas etc get converted into a special symbol "?" in iphone -

Image
i'm using database fetch datas. there 750 questions in database.some questions contain special character's ",....,' etc. while fetch data , print in textview converted "?". there way remove these kind of symbols , print in original format. i used below code fetching , displaying in textview. qsql=[nsstring stringwithformat:@"select * mydata col_1 = '365'"]; if(sqlite3_prepare_v2(database, [qsql utf8string], -1, &statement, null) == sqlite_ok) { while (sqlite3_step(statement) == (sqlite_row)) { char *field0 = (char *)sqlite3_column_text(statement, 1); char *field1 = (char *)sqlite3_column_text(statement, 2); nsstring *t1 = nil; if(field0!=null){ t1 = [[nsstring alloc] initwithutf8string:field0]; //nsstring *t1 = [[nsstring alloc] initwithcstring:field0 encoding:nsutf8stringencoding]; nslog(@"%@jujuj" ,t1); } nsstrin...

scala - How to override apply in a case class companion -

so here's situation. want define case class so: case class a(val s: string) and want define object ensure when create instances of class, value 's' uppercase, so: object { def apply(s: string) = new a(s.touppercase) } however, doesn't work since scala complaining apply(s: string) method defined twice. understand case class syntax automatically define me, isn't there way can achieve this? i'd stick case class since want use pattern matching. the reason conflict case class provides exact same apply() method (same signature). first of suggest use require: case class a(s: string) { require(! s.tochararray.exists( _.islower ), "bad string: "+ s) } this throw exception if user tries create instance s includes lower case chars. use of case classes, since put constructor out when use pattern matching ( match ). if not want, make constructor private , force users only use apply method: class private (val s: string) { } o...

parsing arguments from python to c++ -

i wanted know how change values of arguments in c++/c program python. in program below use newton-raphson method compute roots of function. want change value of variable xn (for initial guess) value given in python interface. code simple trying bigger code need change values of variables , dont want compile code each time change values of these variables. i can write input file in order avoid compiling code again want is controlling code more, instance, stop program @ time step , change values of variables , continue execution. tell me if there straightforward way that? regards. #include <iostream> using namespace std; double first_derivative(double x) { double dummy; // parabolic function dummy = 2.0 * x + 7.0; return (dummy); } doubl...

Silverlight and memory usage -

my silverlight application taking 75 megs of memory. seems high. how can troubleshoot application see memory being used. there trick running low memory mode reduce footprint s light! @matt bridges suggestion profiler correct. have used ants. other alternatives include yourkit , using windbg sos. there isn't 1 answer question might closed, however, there memory leaks inline data templates in controls. here example, there lots of pages when google it: http://www.devtoolshed.com/silverlight-memory-leak-datagrid-dataform-datatemplate-etc

python - Transfer layout from networkx to cytoscape -

Image
i want use networkx generate layout graph. possible transfer layout cytoscape , draw there? tried write graph as import networkx nx g = nx.graph() g.add_edge(0,1,weight=.1) g.add_edge(2,1,weight=.2) nx.write_gml(g,'g.gml') nx.write_graphml(g,'g.xml') but neither of these read in cytoscape. not sure how transfer graph in format can include positions. your g.xml graphml file looks good, , loads cytoscape me (i'm on mac). have installed graphmlreader plugin? if not, download , drop plugins folder, restart cytoscape , try loading g.xml network again. update here code add graphics look-and-feel , positioning networkx graph. bit verbose, , may able omit of attributes depending on needs: import networkx nx g = nx.graph() g.add_edge(0, 1, weight=0.1, label='edge', graphics={ 'width': 1.0, 'fill': '"#0000ff"', 'type': '"line"', 'line': [], 'source_arrow': ...

problem in date column with hibernate hql query -

i hav hql query..it gets data used between 2 dates..i wriiten query this com.cod.model.billing datecolumn between '2011-4-4' , '2011-4-20' but didn't results query ..i checked out query in mysql sql query.there it's workng fine..but if write same query in hql returns null results can 1 what's problem in query.thanx in advance the dates mentioned have of type java.util.date , not string

Accessing MySQL through Javascript via PHP -

when user logs in, want send 2 parameters php , want update related db table. possible in javascript? if possible sample code or links appreciated. you can use javascript request php script using xmlhttprequest , , include database interaction mysql in php script.

actionscript 3 - How to trigger garbage collection? -

does know if it's possible apply garbage collection new stagevideo component in as3? have tried no success! code below: if ( this._stagevideo == null ) { this._stagevideo = stage.stagevideos[0]; this._stagevideo.addeventlistener(stagevideoevent.render_state, stagevideostatechange); } attempt @ gc: this._stagevideo = null; this._stagevideo.removeeventlistener(stagevideoevent.render_state, stagevideostatechange); this._stagevideo = null; this._stagevideo.removeeventlistener(stagevideoevent.render_state, stagevideostatechange) i'm surprised worked, should throw exception, should first remove event listeners , nullify it's reference. garbage collector not start every time nullify something, if can use flash builder profiler can attempt force gc, if want test out, can package project air, , call gc manually. there bug/feature invoke gc if fail start localconnection twice (http://www.nbilyk.com/flash-garbage-collection): try { new localcon...

c# - Invoke object method regardless of parameter type -

i using dynamicobject wrap internal object , mask generics, when try invoke methods on internal object require typed paramaters, treating paramaters type object invoke fails. code: public override bool tryinvokemember(invokememberbinder binder, object[] args, out object result) { try { result = minternalobject.gettype().invokemember(binder.name, (bindingflags.invokemethod | bindingflags.instance | bindingflags.public), null, minternalobject, args); return true; } catch (exception) { return base.tryinvokemember(binder, args, out result); } } so basically, wondering how make ignore paramater types , invoke method object anyway, sugestions? i suspect want along lines of (psuedo code, simplified): var mem = internalobject.gettype().getmember(binder.name); if (mem.isgenericdefinition) mem = mem.makegeneric(array.convert(args, x => ...

system-wide setting for php exec() search path -

i run php websites on freebsd server updated php 5.2.17, after exec("something") stopped working, , required write exec("/full/path/something") . since scripts run on different machines executables in different places writing full paths not acceptable. running passthru("set") php reveals path variable (for user "www") be: path=/sbin:/bin:/usr/sbin:/usr/bin i need path point php safe_mode_exec_dir directory: path=/usr/phpsafe_bin running putenv("path=/usr/phpsafe_bin") in php resolves problem, need solution fixes problem on global level php scripts running on machine, in other words changing php.ini, apache settings, or other system settings. hope can provide solution this, maybe explanation why changed in php update. there seems no php documentation on how search path exec() , friends determined. it's not pleasant solution, it's think of. create script file change you've suggested , use "a...

jquery - How to add a callback to a function in javascript -

i have 2 javascript functions function 1 () { long... writing jpgfile on disk } function 2 () { fast... show file } i call (in jquery) this 1 (); 2 (); because function 2 needs link file function one, need sure execution completed... getting function 2 in callback of function 1 should trick.. how ? note : did put alert ('aaa') between 2 functions let function 1 complete, , worked fine... when alert commented (removed) nothing works anymore ! you need use callback if doing asynchronous, otherwise doesn't matter how long takes, next function won't run until first has finished. a callback passing function argument, , calling when done. function 1 (callback) { long... writing jpgfile on disk callback(); } function 2 () { fast... show file } one(two); obviously, if are doing asynchronous, need tell when finished (such event firing).

java - Can this code be done shortened and/or be more efficient? -

my current code: textview question; private int qtype = -1; private int asked = 0; private void qbegin() { // todo auto-generated method stub question = (textview) findviewbyid(r.id.question); random random = new random(); int qtype = random.nextint(5); switch(qtype){ case 0: question.settext("question 1"); break; case 1: question.settext("q2"); break; case 2: question.settext("q3"); break; case 3: question.settext("q4"); break; case 4: question.settext("q5"); break; } asked++; //intlist.add(qtype); getanswers(qtype); /*if(intlist.contains(qtype) && asked <= 5){ qbegin(); } else { answercounter.settext("congratulations!!! score : "+correct); }*/ } private int answer; private void getanswers(int type) { random random = new random(); //...

regex - Java literate text word parsing regexp -

firstly happy [a-za-z]+ need parse words end letter "s", should skip words have 2 or more first letters in upper-case. try [\n\\ ][a-za-z]{0,1}[a-z]*s[ \\.\\,\\?\\!\\:]+ first part of [\n\\ ] reason doesn't see beginning of line. here example text denis goes school every day! parsed word goes any ideas? what about \b[a-z]?[a-z]*x\b the \b word boundary, assume wanted. ? shorter form of {0,1}

c# - How is unmanaged memory allocated in system when instances are created? -

how unmanaged memory allocated in system when com objects or other unmanaged instances created c#? the clr creates runtime callable wrapper (rcw) com objects want instantiate. kind of interop proxy .net com system. com object create therefore allocated , reference created in clr, puts on heap. you must implement idisposable in class holds references rcws, because not automatically cleaned (the wrappers on .net heap, com objects not). calling dispose() on wrapper releases com objects. not implementing idisposable therefore causes memory leaks.

how could i persist the page state after page redirect in asp.net MVC? -

i have search filed , gridview, if jump page , when redirect back, of states not persist, create search model save data , keep in session, search in page , fields not fixed. there way solve this? the general options store in tempdata available upon next request or store in cache or reload or store in session longer persistence. how web works far being stateless need figure 1 of these general methods. cookies quite limited exclude them in case. ideally - if use repository pattern loading data, in repository method can add data cache current user's login id - if data makes sense cache. if want available next request, add tempdata["yourdata"] = yourobject after read on next request automatically flagged deletion @ end of request processing.

html - jQuery modal window scroll bar -

sorry if think didn't show code because haven't implement yet. i trying built jquery photo view plugin, when find examples on line, height of modal window either window height height of computer screen of document height height of html body. when saw facebook photo view plugin, height of modal window can extended according content height, tell me how that, if show me bit of coding related or examples great, thank great help. facebook interesting modals. have page wrapped in container, , modal added dom sibling, rather child of container. so, set container position:fixed instead of modal. allows user scroll if modal grows past constraints of window size. if intend follow same strategy, modal naturally grow content does, since modal doesn't have postion:absolute. otherwise, can of course done traditional approach of making modal position:absolute or position:fixed, little trickier. if have control on code changing content in modal, evaluate size of cont...

How to replace some text with something in extJS? -

have question: have in database filed text (i submitted through form). then have extjs panel data. made, when click on soem field, appears message box plain text (but in database text beautiful ul's, /br/'s , son) :( ok, eyes can't read normally! how avoid this? maybe in extjs exists replace params? replace('/n/', '//br/').. or? my grid var grid = new ext.grid.gridpanel({ id : 'grid', store : store, frame : true, autoscroll :true, columns : my_columns, striperows : true, title :'answers', iconcls : 'arrow', listeners: { celldblclick: function(grid, rowindex, cellindex, e){ var rec = grid.getstore().getat(rowindex); var columnname = grid.getcolumnmodel().getdataindex(cellindex); ext.msg.show({ title : 'message...

java - How to test an interpreter using JUnit? -

i writing tests interpreter programming language in java using junit framework. end i've created large number of test cases of them containing code snippets in language under testing. since these snippets small convenient embed them in java code. however, java doesn't support multiline string literals makes code snippets bit obscure due escape sequences , necessity split longer string literals, example: string output = run("let := 21;\n" + "let b := 21;\n" + "print + b;"); assertequals(output, "42"); ideally like: string output = run(""" let := 21; let b := 21; print + b; """); assertequals(output, "42"); one possible solution move code snippets external files , refer each file corresponding test case. adds significant maintenance burden. another solution use different jvm language, such scala or jython support multiline string litera...

multithreading - How to access remote connection requests from safari, facebook and other applications on iPhone -

i noticed 1 application on app store named onavo access internet connection usage other applications on iphone safari, facebook, youtube, etc. there api available this. how have implemented it. curious know it. i've found answer on quora. follow: http://www.quora.com/how-is-onavo-able-to-direct-all-the-data-traffic-to-their-proxy-without-using-ios-private-apis roi tiger, cto of onavo hi, i'm cto of onavo, thank checking out our service. after installing onavo prompted install configuration profile allows data redirected through onavo's servers using proxy server settings. configuration profile installation not require private api access in ios platform. another answer: http://www.quora.com/how-does-onavo-manage-to-compress-data-traffic

php - The right way of generating pdf, xls, png files in webapp -

i have generate reports of various file type(excel, pdf, png), based on inputs of web application. application written in php on apache webserver. atm, when users visit reports section, trigger event checks if there submitted new data in database , based on info, new report files generated. makes user wait until files generated (3-10seconds), not approach @ need advice can give me. of course depends on application , system, typically have cron job executes php script generate reports periodically. output saved filesystem or in database. way reports generated once (rather each time user tries download them) , generated when needed (your script check if needs generate report based on whatever change criteria have, or set generate whole new reports periodically). keep simple call current web page wget or curl, , create new page on webserver downloading saved reports. the problem approach users might download "stale" reports (data has changed reports haven...

ios - How to debug whole iPad freezing? -

i have ipad drawing app uses core data , quartz 2d. users , have been experiencing freeze problems happen 1 or 2 times every hour if unlucky. have tried can debug problem, making sure there no dead locks, no ui code being called background threads , no core data methods called in different threads. (i used method swizzling check them.) but problem still here, , there no crash log because whole ipad freeze , user has hard restart. happens when drawing have no clue why happens. seems related fact updates cashapelayers every time uitouch moved. (it not feasible use bitmaps instead because of memory usage) used instruments manually check every function called when drawing. what else can try fix problem? has been bothering me few months now... , begin wonder if bug ios.

Java: length of string when using unicode overline to display square roots? -

in java create string uses unicode , overline because trying display square roots of numbers. need know length of string formatting issues. when using combining characters in unicode usual methods finding string length seem fail seen following example. can me find length of second string when random numbers in square root, or tips on how square root display better? string s = "\u221a"+"12"; string t = "\u221a"+"1"+"\u0305"+"2"+"\u0305"; system.out.println(s); system.out.println(t); system.out.println(s.length()); system.out.println(t.length()); thanks help, couldn't find on using google. the usual methods finding string length seem fail they don't fail, report string lenght number of unicode characters [*]. if need behaviour, need define mean "string length". when interested in string lengths displaying purposes, interested in counting pixels (or othe...

nsmanagedobject - Objective C - Core Data record update -

i have update records in core data. right way? nsmanagedobjectcontext *context = [self managedobjectcontext]; nsmutablearray *poifromcd=(nsmutablearray *)[self takepoifromcoredata]; (int i=0; i<[array count]; i++) { (int j=0; j<[poifromcd count]; j++) { poi *poi=(poi *)[poifromcd objectatindex:j]; if ([[[array objectatindex:j]objectforkey:@"poiid"]isequaltostring:poi.poiid]) { poi *p=[poifromcd objectatindex:j]; p.poiid=[[array objectatindex:i]objectforkey:@"poiid"]; p.lastmod=[[array objectatindex:i]objectforkey:@"lastmod"]; } else { poi *p; p=[nsentitydescription insertnewobjectforentityforname:@"poi" inmanagedobjectcontext:context]; p.poiid=[[array objectatindex:i]objectforkey:@"poiid"]; p.lastmod=[[array objectatindex:i]objectforkey:@"lastmod"]; } } } nserror *error; if (![context save:&error]) { nslog(@"errore durante il salvataggio: %@...

c# - Do you need to call Flush() on a Stream if you are using the “using” statement? -

i not sure whether need call stream.flush() if write this: using (file stream...) using (cryptostream...) using (binarywriter...) { // } is automatically flushed? when using statement flush stream , when doesn’t (if can happen)? as leave using block’s scope, stream closed , disposed. close() calls flush(), should not need call manually.

jsf 2 - How to display a confirmation dialog(Primefaces) from backing bean -

i have import function parse xml file contains version information of document , save in database. if user try upload existing version, need show confirmation dialog " version exists wants overwrite..?" ok, cancel. i using mozarra 2.0.3, prime faces 2.2 rc2, glass fish 3 , trying way. <h:form id="condialog"> <p:commandbutton value="getconfirmmsg" update="condialog" action="#{buttonbean.getconfirmmsg()}" oncomplete="confirmation.show()"/> <p:growl id="messages1" globalonly="true"/> <p:confirmdialog message="version exists. want override it?" rendered="#{buttonbean.showconfirm}" header="version exist" severity="alert" widgetvar="confirmation"> <p:commandbutton value="ok" update="messages1" oncomplete="confirmation.hide()" action="#{bu...

video - h264 or mp4 with mediaelement.js -

i've been using mediaelement.js(http://mediaelementjs.com/) our site. i've noticed have convert mp4 videos codec h264 . if use code mpeg-4 mp4 video audio ok video black. any idea why ? thanks. mejs requires h264 .mp4 formatted files.

exif - Find where a picture is taken on Facebook? -

is still possible find location information of pictures on facebook since fb doesn't keep exif? thanks unfortunately, not possible. facebook strips exif data upon upload. the way determine photo taken if user associated place when uploading facebook.

Inno Setup: Exiting when clicking on Cancel without confirmation -

if user clicks on "cancel", want installer stop , exit, without asking want exit or not. can done somehow? appreciated. this easy. add [code] procedure cancelbuttonclick(curpageid: integer; var cancel, confirm: boolean); begin cancel := true; confirm := false; end; to iss script.

regex - Automatic Linkification for network files in PHP -

i'm trying automatically detect links in user-submitted text , dynamically generate links. i've found works "normal" urls. $pattern = "/(http|https|ftp|ftps)\:\/\/[a-za-z0-9\-\.]+\.[a-za-z]{2,3}(\/\s*)?/"; return preg_replace($pattern, "<a href=\"\\0\" rel=\"nofollow\" target=\"_blank\">\\0</a>", $str); is there way expanded cover unc or mapped network drives such \\computername\sharedfolder\file.txt or z:\dir\file.txt ? i'm not looking perfect solution. the obvious non perfect solution have 3 patterns , check each 1 in turn. (so, \\ , [a-z]:\ , grab first whitespace.)

javascript - Are Variable Operators Possible? -

is there way similar either of following: var1 = 10; var2 = 20; var operator = "<"; console.log(var1 operator var2); // returns true -- or -- var1 = 10; var2 = 20; var operator = "+"; total = var1 operator var2; // total === 30 not out of box. however, it's easy build hand in many languages including js. var operators = { '+': function(a, b) { return + b }, '<': function(a, b) { return < b }, // ... }; var op = '+'; alert(operators[op](10, 20)); you can use ascii-based names plus , avoid going through strings if don't need to. however, half of questions similar 1 asked because had strings representing operators , wanted functions them.

c# - WCF passing a custom object to client and running it's methods -

this design technical question. i'm not sure doing right... i have wcf api communicates db , passes person object (which defined in separate .dll) has both methods , attributes. object being sent wcf calling client. i want call person's methods on client. understand these can not sent downstream api however, if reference same .dll wcf uses should able cast api person .dll person run methods? i hope clear trying achieve. thanks, sam wcf supports ability re-use references included in project. in sense, can create contracts assembly (an assembly contains thin domain models (e.g. person etc) can add own logic to. you can add assembly both wcf service, , calling client projects, , instruct wcf re-use existing references. way, pulled service deserialised local copy of person , not person generated proxy, full instance, on can perform method calls. don't forget through, marshalling value in case. changes make person instance local client only, need pass...

Need a video player for integration with PHp -

i using jwplayer video project. retrieving url database after selection of particular video. jwplayer time load url of youtube.com , plays sometime not playing videos. sample code: <h2>mp4 video playing youtube api </h2> <div id="container1">loading player ...</div> <script type="text/javascript"> jwplayer("container1").setup({ flashplayer: "player.swf", file: "youtube.com/watch?v=cbd9h0juq3w";, height: 270, width: 480 }); </script> if can suggest me better video player... in advance. marco jwplayer video player. if it's randomly loading youtube videos or not playing videos @ all, you've goofed in your code (in case switching players isn't fix anything). show code and/or example page happening.

how to gate array of timer in c# -

i want timer "foreach datavalue in _datavalues" storeed in array exp, timer[0]=timer0, timer[1]=timer1, timer[2]=timer2 etc.here code, timer[] timer=new timer[50]; int = 0; foreach (int datavalue in _datavalues) { string a="timer" + i; timer[i] =a; i++; timer1[i].tick += new eventhandler(timer_tick); timer1[i].interval = (1000) * (2); } but provide error "cannot implicitly convert type 'string' 'system.windows.forms.timer' how value in timer[i]?any 1 can me? " it not clear after. here wild guess: timer[] timers = new timer[50]; string timernames = new string[50]; int = 0; foreach (int datavalue in _datavalues) { timenames[i] = string.format("{0}",i); timer[i] = new timer(); timer[i].interval = datavalue; i++; } it bad idea create 50 timers. if want have different intervals can done single timer too. create 1 timer shortest ...

perl - How do you get MotherDogRobot to birth an array of puppy objects using map and a hash of hashes? -

puppy meta data gets read in config file using (general::config) , creates hash of hashes $puppy_hashes = { puppy_blue => { name => 'charlie', age => 4 }, puppy_red => { name => 'sam', age => 9 }, puppy_yellow => { name => 'jerry', age => 2 }, puppy_green => { name => 'phil', age => 5 }, } the motherdogrobot package consumes puppies hash birth array of puppy objects (lol) package motherdogrobot; use moose; use puppy; use data::dumper; #moose includes warn , strict sub init_puppy{ my($self,%options) = @_; $puppy = puppy->new( %options ); return ($puppy); } sub birth_puppies{ my($self,$puppy_hashes) = @_; @keys = keys %{$puppy_hashes}; @puppies = map { $self->init_puppy( $puppy_hashes->{$_} ) } @keys; return(@puppies); } sub show_me_new_puppies{ my($self,$puppy_hashes) @_; print dumper($self->birth_puppies($puppy_hashes)); } error odd number of arguments passing %op...

javascript - AJAX SEO - back & forward buttons -

i'm using ben almans plugin hash change tracking: http://benalman.com/projects/jquery-hashchange-plugin/ also i've modified web configuration when enter www.mysite.com/test1 , php grabs string test1 value , forwards javascript. javascript sends through ajax sever side script , brings test1 page . and after user writing www.mysite.com/test1 in address bar gets test1 page . ok. now. if enter www.mysite.com , see index page, , there link test1 page . if press it, makes address www.mysite.com/#test1 , because of # hash change plug-in can bring using ajax when press button. what want have such hash change plug-in or method or system not need # signs. cause want user see same clean address www.mysite.com/test1 . is possible? that's not possible. # prefix hash part of location. hashes not sent server, , thus, changing hash won't cause page request. when omit sharp (that's name of # character), page request initiate. if want seo url's,...

How to display a phone number in an iphone webapp? -

i have webapplication runs on iphone , display phone number on it. how can make when phone number clicked phone number dialled? use tel: url scheme. mobile safari automatically set link.

Python matrix, any solution? -

my input(just example): from numpy import * x=[['1' '7'] ['1.5' '8'] ['2' '5.5'] ['2' '9']] i want make next thing on random matrix : 1. each row calculate: > example first row: [1;7]*[1,7] = [[1, 7]; #value * value.transpose [7, 49]] > example second row: [1.5;8]*[1.5,8]= [[2.25, 12]; [12, 64]] >....... this simple numpy , because transpose x.t , if x=[1,7] must calculated every row on matrix! 2. want sum in way... [1+2.25+... 7+12+...... ] [ ] [7+12+.... 49+64+.... ] so result matrix. any ideas? edit2: x=[['1','7'] ['1.5', '8'] ['2', '5.5'] ['2','9']] y = x[:, :, none] * x[:, none] print y.sum(axis=0) i received error: "list indic...

NHibernate on-delete="cascade" with relationship on many side -

i have object model that: folder - simple structure name etc. file - complex object containing reference folder in contained. folder doesn't know files , don't want know. relation many-to-one , should known on file's side only. anyway, rely on database's on delete cascade feature, when remove folder, want files within folder deleted automatically. can't use nhibernate's cascading there no relation folder file. i know there on-delete="cascade" option <key> element in case of one-to-many relationship, can't find equivalent model - when relation defined on many side . am doing wrong or need go through , delete files within deleted folder manually? you try map one-to-many side access="noop" . way don't need property in classes still have mapping. in fluent nhibernate someting this: hasmany(reveal.member<folder, ienumerable<file>>("_files")) .keycolumn("column_na...

php - SQL query to select only the maximum items? -

i have table: want search uid id | vid | uid 1 | 1 | 5 1 | 1 | 6 1 | 2 | 6 2 | 3 | 5 2 | 3 | 6 2 | 4 | 6 i want end result: id | vid | uid 1 | 2 | 6 2 | 4 | 6 in other words, select entries vid max of uid keeping in min nid differ. suppose: select * table uid = 6 , max(vid) ??? but doesn't work? one way order value in descending order (so max @ top), select first result. select t.id, t.vid, t.uid table t t.id = 1 order t.vid desc limit 1 or mean want all rows t.vid highest value? in case this, select t.id, t.vid, t.uid table t t.id = 1 , t.vid = (select max(vid) table); edit : based on edit question, looks want max vid value each id? if i'm understanding correctly, should give need. select t.id, max(t.vid) vid, t.uid table t t.uid = 6 group t.id

javascript - Using multiple instances of setInterval -

i have jsfiddle here: http://jsfiddle.net/dztga/22/ the goal: essentially, i'm trying have 2 discrete timers on same page can destroyed , re-created on mouseover/mouseout (pause), or on manual progression (restart). the problem: jsfiddle's single timer illustrate when click "stop timer", setinterval (stored in variable t) seems have multiple instances albeit being destroyed clearinterval(t). becomes apparent when click "restart timer" , seems have 2+ independent timers illustrated quick increment. a caveat: have done research on can, because i'll having 2 different sliders on page, can't use "clear timers" methods, tried storing each in variable. i hope that's clear. view. to fix current issue: add clearinterval(window.t) @ onclick function of reset button. a method able have multiple timers. requires structure, though. fiddle (6 timers!): http://jsfiddle.net/dztga/27/ (function(){ //anonymous function, ...

Actionscript 3 Flash Keyboard Event -

i wonder 1 enlighten me on easier way of solving code.i new flash , actionscript. i want have text box, user enters name. each time charachter pressed, , image of letter displayed below text box. example. user rights john. john displayed in nice images below. i have got working, have create input box each character, left eg. 6 boxes each letter of name, accept character each. reason is, cannot place images after each other, keep overwriting position of 1st character typed, if 1 single textbox used. i know going long way around this, there must alot easier. here code, tedious if have go route. someon give me quick hinter on correct way go this. thanks fintan ////////////////111111//////////////////// firstname.addeventlistener(keyboardevent.key_down, key_pressed); function key_pressed(event:keyboardevent):void { if (event.charcode == 65) { var fl_myinstance_2:librarysymbol = new librarysymbol(); fl_myinstance_2.x = 50 fl_myinstance_2.y = 200 ...

sql - DESC in SQLite conditional ORDER BY -

i need select records ordered following logic, sqlite raises error when desc in conditional. order case when parentguid null dateposted desc else dateposted end this achieve facebook ordering =- original posts (which have null parentguids) in order descending date , replies original posts ordered date ascending. if understand right, you'll need join table has date of parent post. if that's available, should do: declare @x table ( id int not null identity primary key, parentid int, dateposted date not null ) insert @x (parentid, dateposted) values (null, '2010-01-01'), (null, '2010-01-02'), (1, '2010-01-03'), (1, '2010-01-04'), (1, '2010-01-05'), (2, '2010-01-06') select post.parentid, post.dateposted @x post left join @x parent on post.parentid = parent.id order -- order post date, or rather parent's post date if 1 exists coalesce(parent.dateposted,...

android - Record accelerometer sensor readings to SQLite or flat file? -

i'm writing android app record , save high-rate accelerometer data (and later gyroscope data). schema of data like: timestamp, x_accel, y_accel, z_accel should save data sqlite or flat file (using filewriter , bufferedwriter, explained here )? 1 has lowest latency or more appropriate? eventually need import data csv file excel create graphs. if write sqlite, need later write out csv. either work obviously, personal (non-advocating or backed anything) rule of thumb if can accomplish task file, go it. it's way easier write , manage database code, , you'll able format csv on-the-fly no conversion needed later. don't over-think it. bufferedwriter take care of writing out in large chunks you, keep output stream open until you're done recording data , shouldn't have latency problems. (don't forget flush() , close() when you're done, rule appropriate in java in life).

ios - Counting the number of lines in a UITextView, lines wrapped by frame size -

i wanted know when text wrapped frame of text view there delimiter can identify whether text wrapped or not. for instance if text view has width of 50 px , text exceeding that, wraps text next line. i wanted count number of lines in text view. "\n" , "\r" not helping me. my code is: nscharacterset *acharacterset = [nscharacterset charactersetwithcharactersinstring:@"\n\r"]; nsarray *myarray = [textviewtext componentsseparatedbycharactersinset:acharacterset]; nslog(@"%d",[myarray count]); this variation takes account how wrap lines , max size of uitextview , , may output more precise height. example, if text doesn't fit truncate visible size, , if wrap whole words (which default) may result in more lines if otherwise. uifont *font = [uifont boldsystemfontofsize:11.0]; cgsize size = [string sizewithfont:font constrainedtosize:myuitextview.frame.size linebreakmode:uilin...

php - array switch case statement -

i have array coming in sub arrays this array ( [0] => array ( [customers] => array ( [id] => ) [products] => array ( [id] => ) [models] => array ( [id] => 151 [submodels] => array ( [ol] => ) [noice] => ) ) i want make switch statement on array so this switch($array){ case products: case customers: case models: } how that. thanks since $array holds array within it, looks you'll want @ keys of array indexed @ $array[0] foreach ($array[0] $key => $value) { switch ($key) { case 'products' : // break ; case 'customers' : ...

perl - Archive::Zip, EBook::Epub, and IIS6 - "desiredCompressionLevel" error -

i'm trying convert html files epub ebook::epub. script i've written simple, so: my $epub = ebook::epub->new; $epub->add_title('title'); $epub->add_author('author'); $epub->add_language('en'); $epub->copy_xhtml("d:/path/to/file.html" , "file.html"); $epub->pack_zip("d:/path/to/file.epub"); when run command line, works great. however, i'm trying deploy cgi script on iis6 server--which runs off same computer--it fails message: can't call method "desiredcompressionlevel" on undefined value @ c:/strawberry/perl/vendor/lib/archive/zip/archive.pm line 252. i checked out archive.pm, , line 252 in sub addfile. it's using 3 variables--$filename, $newname, $compressionlevel--and used print statements reveal values right before line 252. ($compressionlevel blank) this command line, works: filename: c:\docume~1\admini~1\locals~1\temp\7qiqzznin5/ops/file.html newname: ops/advanced8...

android - Free Barcode Image Decoding Libraries -

i'm looking free open source library decoding bar code images. requirement of application decode bar codes of code 39 type (if library having capability decode other bar code types no issues well). application supposed run on android based mobile phones , iphone/ipad also. therefore java based libraries not work (since iphone/ipad doesn't support java). 'c' based library ideal. any recommended libraries..? additionally, helpful if can provide me information on how can compile library different platforms (like android, ios etc). thanks. have check library developped google : zxing ? have used android project , it's work well. know it's work on iphone/ipad.

c# - ASP.NET MVC Custom Membership Provider - How to overload CreateUser? -

i'm trying build custom membership provider. capture additional information (first name , last name) during registration , i'm not using usernames (email login). in custom membership provider i'm trying overload createuser method this: public override mymembershipuser createuser(string firstname, string lastname, string email, string password) { ... } but when want call account controller: [httppost] public actionresult register(registermodel model) { if (modelstate.isvalid) { // attempt register user membershipcreatestatus createstatus; membership.createuser(model.firstname, model.lastname, model.email, model.password); if (createstatus == membershipcreatestatus.success) { return redirecttoaction("index", "home"); } else ...

java - What is the proper way to set a JLabel to show an image? -

below snippet create imageicon , jlabel: imageicon armorshopicon = new imageicon("/images/armorshop.png", "armor shop"); jlabel armorshoplabel = new jlabel("armor shop", armorshopicon, jlabel.center); object.setarmorimage(armorshoplabel); then in object class have setter: public void setarmorimage(jlabel label) { this.jlabel1 = label; } this doesn't show image when test application , wondering if point out mistake edit most of source code: main: public class main extends javax.swing.jframe { public main() { initcomponents(); imageicon armoricon = new imageicon("/images/armorshop.png", "armor shop"); jlabel armorshoplabel = new jlabel("armor shop", armorshopicon, jlabel.center); shopdisplay armorshop = new shopdisplay(); armorshop.setarmorimage(armorshoplabel); public initcomponents() { /*more generated code here*/ } } } display: public class shopdispla...

ios - how do you make an app ONLY support landscape? -

how make app support landscape? no portrait mode landscape throughout whole thing in xcode 3? my naive answer add method in of root view controllers: - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { if (interfaceorientation==uiinterfaceorientationlandscapeleft || interfaceorientation==uiinterfaceorientationlandscaperight) return yes; return no; } this in game. of course, game has 1 view controller. also, found helpful set "initial interface orientation" in app's info.plist landscape.

javascript - Replace Picture Source (Adding) -

what wish have div containing image, when button/mini picture pressed image's source change 1-2 2-3, etc adding 1 each time. needs go both ways: i.e right arrow: 1.jpg 2.jpg left arrow 3.jpg 2.jpg script needs include if statement if picture doesn't exist button visibility: hidden; in css. if picture source 5.jpg + 1 doesn't exist #mini img visibility: hidden; had idea use not same similar (jquery). used script change image on hover, figure change onclick , use similar. $(function() { $('#buttons #right img').each(function() { var originalsrc = this.src, hoversrc = originalsrc.replace(/\.(gif|png|jpe?g)$/, '_over.$1'); image = new image(); image.src = hoversrc; $(this).hover(function() { image.onload = function() { } this.src = hoversrc; }, function() { this.src = originalsrc; }); }); }) it not hard the image supports onerror load image onclick , onload replace source var currentimage; function loadimage(img,dir) { cu...

.net - Parallel threads calling in ASP.net 4.0 -

one customer arriving @ landing page consume 5 threads. 1 main thread request getting serviced , 4 separate threads asp thread pool serve 4 parallel calls. in such case, if 20 people arrive @ landing page available threads finished , 21st person wait 3 seconds until thread starts working on person's request. i facing issue achieve task. confuse start can done multi threading , parallel calling of threads in asp.net 4. anyone have resource article or sample this? you take @ asynchronous asp.net pages .

android - Highligth selected item on list , when the customadapter also has focusable items? -

i'm using custom adapert has buttons perform functions. other thing need onitemclickedlistener , selected should highlighted . listview onitemselected listner not working , how can it. here's getview of custom adapter. public view getview(final int position,view convertview, final viewgroup parent) { final viewholder holder; if(convertview == null) { convertview = mlayoutinflator.inflate(r.layout.businessbrieflist,null); holder = new viewholder(); holder.callbutton = (imagebutton) convertview.findviewbyid(r.id.call); holder.favbutton = (imagebutton) convertview.findviewbyid(r.id.fav); convertview.settag(holder); }else holder = (viewholder) convertview.gettag(); holder.toprofile.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { log.e("profile","clicked"); intent t = new...

vcproj - XSLT: keeping whitespaces when copying attributes -

i'm trying sort microsoft visual studio's vcproj diff show meaningful after e.g. deleting file project. besides sorting, want keep intact, including whitespaces. input looks like space <file spacespace relativepath="filename" spacespace > ... the xslt fragment below can add spaces around elements, can't find out how deal around attributes, output looks like space <file relativepath="filename"> xslt use msxsl 4.0 processor: <xsl:for-each select="file"> <xsl:sort select="@relativepath"/> <xsl:value-of select="preceding-sibling::text()[1]"/> <xsl:copy> <xsl:for-each select="text()|@*"> <xsl:copy/> </xsl:for-each> those spaces always insignificant in xml, , believe there no option control behavior in general way xml/xslt library.

jquery - Link to a page and trigger toggle event on div -

i using jquery toggle hidden (by default) div on page 1. $(document).ready(function(){ $(".trigger").click(function(){ $(".panel").toggle("fast"); $(this).toggleclass("active"); return false; }); }); what need able link page 1 page 2 open hidden div in same event. i'm hoping can shed light on simple execution of this? cheers! on page 2: <a href="page1.html?panel_open=1"> click me </a> on page 1: $(document).ready(function() { // parse query params var url_params = (window.location.search.substr(1) .split('&') .reduce(function(prev, curr) { curr = curr.split('='); if( curr.length > 1 ) { prev[curr.shift()]=curr.join('='); } return prev; }, {})); if( url_params.panel_open ) { // if "panel_open" passed in url, open panel $(".panel").toggle...