Posts

Showing posts from August, 2011

iphone - Dismissing an Alert View in different method than what it is in -

iphone - Dismissing an Alert View in different method than what it is in - i have in app purchase in app , when purchase "purchasing", or in progress, have alert view come says "loading...". when purchase successful, restored, or failed, i'd phone call method releases alert view. problem is, can't seek release alert view in method because have no thought alert view talking , produce error. have no thought if best way of trying accomplish this, ideas appreciated. thanks! case stateispurchasing { //or whatever it's called uialertview *alert = [[uialertview alloc] message , delegate , button stuff here]; [alert show]; [alert release]; } declare uialertview in header retained property, synthesized, , released in dealloc . store alert view create in code snippet using pointer, , utilize declared pointer in other method. don't phone call [alert release]; when create alert view (unless exc_bad_access errors!). oh, if yo...

multithreading - Android FileOutputStream method 'ignored' -

multithreading - Android FileOutputStream method 'ignored' - i utilize 3 files storing of local data, app, 2 of checked on app start-up , updated remotely (if newer version available or files not yet exist). 3rd user info can periodically stored while app running. all 3 utilize same method save file: public boolean setlocalfile(string filename, string filetext, context con) { seek { fileoutputstream fos = con.openfileoutput(filename, context.mode_private); fos.write(filetext.getbytes()); fos.close(); homecoming true; } catch(exception e) { handleerror(e); // local method system.out.println homecoming false; } } now 3rd file writes fine, first 2 (that checked , written on start-up) don't write @ all. in debug, appears if setlocalfile method skipped without throwing exception or crashing app , error logs reported appear be: 07-11 16:14:13.162: error/androidruntime(1882): error: thread att...

jquery - How to add time in datetimepicker -

jquery - How to add time in datetimepicker - i using plugin datetimepicker format yyyy-mm-dd hh:mm:ss , want add together time (ex: 10 second) in 2011-07-12 12:34:45 (45 + 10 sec = 55) => result: 2011-07-12 12:34:55, not ideas, can help me ideas you can utilize timepicker extension jquery datepicker. jquery

java ee - Maven EAR-project with SLF4J, logback and native hibernate on glassfish -

java ee - Maven EAR-project with SLF4J, logback and native hibernate on glassfish - my project pretty simple. want standard ear-project supports slf4j logback implementation. main problem is, config file not used , debug info printed out console xerces. there major classpath problem ear files think, because project war runs fine. have set logback.xml every root dir, not work. had had problem hibernate.cfg.xml file not found. give me tip or provide sample ear? using gf 3.1.1 i believe both war , ejb, config files should in meta-inf of respective jar, if don't need easier access them. if need easier access them, solution app-server-dependent. in case, @ "application" entry in table in glassfish classloader hierarchy doc. i'm not glassfisherman, can point @ docs. java-ee maven glassfish logback java-ee-5

codeigniter - having small problem wth this ci navigation script -

codeigniter - having small problem wth this ci navigation script - my controller [code]$data['navlist'] = $this->mcats->getcategoriesnav();[/code] model is [code] function getcategoriesnav(){ $data = array(); $this->db->group_by('parentid', 'id'); $q = $this->db->get('categories'); if($q->num_rows >0){ foreach($q->result() $row){ if($row->parentid > 0){ $data[0][$row->parentid]['children'][$row->id] = $row->name; }else{ $data[0][$row->id]['name'] = $row->name; } } } $q->free_result(); homecoming $data; } [/code] and views is [code]if(count($navlist)){ echo "<ul>"; foreach($navlist $key => $list){ foreach($list $topkey => $toplist){ echo "<li ...

quit application develop in flash release in Adobe air apk -

quit application develop in flash release in Adobe air apk - i have develop 1 game in flash cs 5.5 , action script 3.0 , problem have set 1 close button in end of game. when press button after create apk , test on mobile, no effect(means not quit application). nik this should work: close.addeventlistener(mouseevent.click, onclickclose); private function onclickclose(evt:mouseevent):void { nativeapplication.nativeapplication.exit(); } flash air flash-cs5

arraylist - Typecasting Elements in java.util.List -

arraylist - Typecasting Elements in java.util.List - i have 2 classes named "basecatalog" , "city". "basecatalog" parent class of "city", in other words, "city" extends "basecatalog" class. i have method called "getbasecatalogobjects" takes 1 parameter catalogtype , returns list of basecatalog objects. according given type, type of list may differ contain objects extends main basecatalog class. because method generic method, produces list containing basecatalog objects. in case, sure each basecatalog instance in list city object: list<basecatalog> basecatalogobjects = getbasecatalogobjects(catalogtype.city); what want convert "basecatalogobjects" list list called "cityobjects" like: list<city> cityobjects = (list<city>) basecatalogobjects; is possible or there efficient way such conversion without creating new java.util.list instance , iterating on list ...

java - How do I create a Play! Framework web project with Maven? -

java - How do I create a Play! Framework web project with Maven? - is there maven archetype out there create play! framework java web application? thanks no, there no maven archetype. play tries distance bit standard java ee practices, , provides total stack including dependency management. java maven playframework

javascript - jQuery "each" -- data... changes... on the other side of the loop -

javascript - jQuery "each" -- data... changes... on the other side of the loop - so grabbing xml data, , parsing within success function of jquery.ajax call. var d1 = []; jquery.ajax( { url: ("/charts/quotes/" + name + ".xml"), success: function( info ) { var dstring; var qstring; var d; var q; jquery(data).find("historicalquote").each( function () { dstring = $(this).children("date").text(); qstring = $(this).children("lastclose").text(); d = date.parse(dstring); q = parsefloat(qstring); d1.push( [ d, q ] ); console.log( d1[d1.length-1][0] + ": " + d1[d1.length-1][1] ); /* ^ first log ^ */ } ); console.log( d1.length ); ( var q in d1 ) { console.log(q[0] + ": " + q[...

Can someone help me with the solution to Project Euler #4 in Java? -

Can someone help me with the solution to Project Euler #4 in Java? - okay guys, know not elegant solution project euler's 4th problem, i'm proud of because did myself... until now. here problem reference: http://projecteuler.net/index.php?section=problems&id=4 public class problem4 { public void projecteuler4() { int reply = 0; (int = 1; < 1000; i++) { (int j = 1; j < 1000; j++) { if (i * j >= answer) { string stringnum = "" + answer; string firsthalf = ""; string secondhalf = ""; if (stringnum.length() % 2 == 0) { (int k = 0; k < stringnum.length() / 2; k++) { firsthalf = firsthalf + ("" + stringnum.charat(k)); } (int k = stringnum.length(); k < stringnum.length() / 2; k--) { ...

More than one for-loop in a python while-loop -

More than one for-loop in a python while-loop - i'm python/coding newbie , i'm trying set 2 loops while loop? can this? how can print out dictionary mydict create sure doing correctly? i'm stuck. 40 minutes later. not stuck anymore. everyone! def runloop(): while uid<uidend: row in soup.findall('h1'): try: name = row.findall(text = true) name = ''.join(name) name = name.encode('ascii','ignore') name = name.strip() mydict['name'] = name except exception: go on row in soup.findall('div', {'class':'profile-row clearfix'}): try: field = row.find('div', {'class':'profile-row-header'}).findall$ field = ''.join(field) field = field.encode('ascii','ignore...

Tiny language to study parser -

Tiny language to study parser - i enthusiast programmer. have dragon book , have been trying understand how recursive parser works it's pretty tough me. have been looking @ language source code bit little languages quite complex. for instance: lua 18k lines of code sed 20k icon 41k ed (the text editor) 2.7k seems pretty different languages know. can recommend tiny little language study? not matter if useful or not. wikipedia refers "tiny programming language there not link it. thanks reading-patrick tiny originaly developed jack crenshaw pascal based tutorial 'lets build compiler' tutorial has moved link had! believe few people have used it, or in number of courses teach ideas behind compilers. there version here http://www.e-booksdirectory.com/details.php?ebook=1137e as stands outputs assembly targeted @ mc680x0 processors used in atari st/comodore amiga type home computers of late 1980's. the code stated intro, of not sophisticated co...

Parse JSON Google Finance in jQuery -

Parse JSON Google Finance in jQuery - i trying parse next json data, seems returns blank, i'm not sure if doing right. could please have look! $.getjson('http://www.google.com/finance/info?infotype=infoquoteall&q=shmn,^dji,^ixic,^bsesn,^spx,^ftse', function(data){ $('#content').html(data); }); jsfiddle: http://jsfiddle.net/a4jkt/ first of won't info because url doesn't conform same origin policy, can fixed adding &callback=? end of url, tells jquery treat request jsonp. also instead of applying info straight div element alerted instead, appears show info that's returned, should hence utilize next jsfiddle new starting point. http://jsfiddle.net/a4jkt/4/ jquery json

Android Kernel Debugging -

Android Kernel Debugging - i have been experimenting getting kgdb work nexus one. i have pulled kernel android.git.kernel.org , enabled kgdb including kgdbts testing using menuconfig . built kernel , flashed device (which unlocked rooted , running cyanogenmod 7) i have followed instructions found on http://bootloader.wikidot.com/android:kgdb enable usb connection deed serial connection required kgdb (and tested communications ttyacm0 ttygs0 successfully). the next folders exist indicating kgdboc , kgdbts have been built kernel: /sys/modules/kgdboc/parameters /sys/modules/kgdbts/parameters the next output dmesg showing kgdbts testing beingness done show (i think) successful completion of tests: # dmesg | grep kgdb <6>[ 12.974060] kgdb: registered i/o driver kgdbts. <6>[ 12.981781] kgdbts:run plant , detach test <6>[ 12.995178] kgdbts:run sw breakpoint test <6>[ 13.002441] kgdbts:run bad memory access test <6>[ 13....

java - Tomcat start datetime info -

java - Tomcat start datetime info - is there simple way how info when tomcat started? know in tomcat log file, other option? thank you not far know. can solve differently (and container independent!) help of servletcontextlistener . @weblistener public class config implements servletcontextlistener { @override public void contextinitialized(servletcontextevent event) { event.getservletcontext().setattribute("startupdate", new date()); } // ... } this way it's available in jsp as class="lang-xml prettyprint-override"> <p>webapp startup date: ${startupdate}</p> (formatting can done jstl <fmt:formatdate> ) or in servlet as date startupdate = (date) getservletcontext().getattribute("startupdate"); // ... java tomcat

algorithm - Counting the ways to build a wall with two tile sizes -

algorithm - Counting the ways to build a wall with two tile sizes - you given set of blocks build panel using 3”×1” , 4.5”×1" blocks. for structural integrity, spaces between blocks must not line in adjacent rows. there 2 ways in build 7.5”×1” panel, 2 ways build 7.5”×2” panel, 4 ways build 12”×3” panel, , 7958 ways build 27”×5” panel. how many different ways there build 48”×10” panel? this understand far: with blocks 3 x 1 , 4.5 x 1 i've used combination formula find possible combinations 2 blocks can arranged in panel of size c = take --> c(n, k) = n!/r!(n-r)! combination of grouping n @ r @ time panel: 7.5 x 1 = 2 ways --> 1 (3 x 1 block) , 1 (4.5 x 1 block) --> 2 blocks used--> 2 c 1 = 2 ways panel: 7.5 x 2 = 2 ways i used combination here well 1(3 x 1 block) , 1 (4.5 x 1 block) --> 2 c 1 = 2 ways panel: 12 x 3 panel = 2 ways --> 2(4.5 x 1 block) , 1(3 x 1 block) --> 3 c 1 = 3 ways 0(4.5 x 1 block) , 4(3 x...

c# - unable to save dynamically created MemoryStream with rebex sftp -

c# - unable to save dynamically created MemoryStream with rebex sftp - i'm using streamwriter generate dynamic file , holding in memorystream . appears alright until go save file using rebex sftp. the example give on site works fine: // upload text using memorystream string message = "hello rebex ftp .net!"; byte[] info = system.text.encoding.default.getbytes(message); system.io.memorystream ms = new system.io.memorystream(data); client.putfile(ms, "message.txt"); however code below not: using (var stream = new memorystream()) { using (var author = new streamwriter(stream)) { writer.autoflush = true; writer.write("test"); } client.putfile(stream, "test.txt"); } the file "test.txt" saved, empty. need more enable autoflush work? after writing memorystream, stream positioned @ end. putfile method reads current position end. that's 0 bytes. you need position stream...

iOS Camera Object? -

iOS Camera Object? - i insert object app's main view uses iphone's photographic camera display photographic camera sees , have button take picture. is possible? take @ camera programming topics ios. ios camera real-time

C++ template comprehension -

C++ template comprehension - i trying understand meaning of next code since valid c++ code: template<class a> class @ { at(); }; template<class b> at<b>::at() {} can help me understand effect of template instantiation in constructor? , if can come useful practical utilize case appreciate. tanks there no template instantiation here. later half of code defines constructor at class. note general practice utilize same names template parameters when doing this: template<class a> class @ { at(); }; template<class a> at<a>::at() {} the utilize syntax break dependency loops: template<class a> class @ { at(); }; class dependent { at<dependant> member; // finish definition of @ needed here }; template<class a> at<a>::at() { dependent object; // finish definition of dependent needed here } c++ templates semantics

jsp - tomcat fail to update newly compiled java files -

jsp - tomcat fail to update newly compiled java files - i using tomcat 6 web server jsp stuff. if made changes associated java file , compile it, tomcat fail reflect such changes.(if changes made jsp file, ok) however, if restart tomcat server, changes reflected , goes expect. i uncertainty server cache thing. how can solve it? for convenience, can utilize tomcat's manager reload existing application. addendum: @paul comments, executing manager commands ant provides improve long-term way deal this. java jsp tomcat

Append css to facebook iframe by jQuery? -

Append css to facebook iframe by jQuery? - is there way, append css fb iframe? i tried way: jquery(window).load(function(){ var html = jquery(".like_single iframe").contents().find("connect_widget_vertical_center").html(); alert(html); }); and got error in firebug: permission denied access property 'ownerdocument' no. since contents of iframe served different domain, don't have permission access or modify contents. security feature enforced browser, called same origin policy. jquery-ui jquery-selectors

iphone - Objective C plist searching and random entry -

iphone - Objective C plist searching and random entry - another couple of questions plists , objective c iphone. both questions relate plist can seen in lastly last question. first thing searching, know possible right way go this? should pull searchable objects array , utilize build table? or possible itereate through plist , show matches? or there other way missing here? quick illustration in next want bring 2 'jones' results: <dict> <key>a</key> <array> <string>a jones</string> <string>a king</string> </array> <key>t</key> <array> <string>t jones</string> <string>t king</string> </array> secondly, possible phone call random result plist, i'm pretty sure is, 1 time again right way go this? i admit finding plist bit of pain seems me bit of rubbish form of xml. , still finding iterating through p...

c# - problem with parameters of the query -

c# - problem with parameters of the query - i'm having troubles passing parameters query throws exception the parameterized query '(@idindicador int)insert [atentomig].[dbo].[indicador]([nom' expects parameter '@idindicador', not supplied. this code _sqlcommand = new sqlcommand ("insert [atentomig].[dbo].[indicator]" + "([name]" + ",[descripction])" + "values" + "('" + data[0] + "'" + ",'" + data[13] + "') set @idindicador = scope_identity()", _sqlconexion); sqlparameter idindicador = new sqlparameter("@idindicador", sqldbtype.int); _sqlcommand.parameters.add(idindicador); _sqlcommand.connection.open(); _sqlcommand.executenonquery(); int id = (int)idindicador.value; _sqlconexion.close(); homecoming true; why doing wrong?...

.net - Books for learning C# with respect to Exam 70-573 on SharePoint 2010 Application Development -

.net - Books for learning C# with respect to Exam 70-573 on SharePoint 2010 Application Development - my company has asked me take exam 70-573 on sharepoint 2010 application development. so first step me larn c#. can guys recommend books help me larn need know can move learning sharepoint development. also, should spend time learning .net framework itself? i have lot of programming experience , @ picking new languages. i've never done .net development before. thanks! jon skeet's book best way larn c# regardless of how you'll utilize c# or exam might want pass. c# .net sharepoint-2010

php - Jquery ajax autocomplete plugin -

php - Jquery ajax autocomplete plugin - hi found plugin best upto now. , want jquery plugin: tokenizing autocomplete text entry but when tried create own php file doesnt works my php file : <?php $arr= array( array("id"=>1,"name"=>"ruby"), array("id"=>1,"name"=>"kritya") ); var_dump($arr); $json_response = json_encode($arr); $json_response = $_get["callback"] . "(" . $json_response . ")"; echo $json_response; ?> they gave me sample.php file had this: <? # # illustration php server-side script generating # responses suitable utilize jquery-tokeninput # # connect database mysql_pconnect("host", "username", "password") or die("could not connect"); mysql_select_db("database") or die("could not select database"); # perform query $query = sprintf("select id, name mytable name '%%%s%%' or...

coldfusion - Why writedump function doesn't require semicolon in cfscript? -

coldfusion - Why writedump function doesn't require semicolon in cfscript? - normally statement written in cfscript tag must end semicolor (;) today working sample code forgot write semicolon (;) after writedump() function still code execute fine. se below sample code , work fine ; @ end of statement. curios know why writedump work without semicolon. i working coldfusion version 9,0,1,274733. <cfscript> = "hello"; b = "world"; concat(a,b); writedump(a & b) writeoutput(a); </cfscript> <cffunction name="concat" access="public" output="false" returntype="string"> <cfargument name="str1" required="true" type="string" /> <cfargument name="str2" required="true" type="string" /> <cfreturn str1 & str2> </cffunction> i guess adobe devs forgot apply pretty useless convention cfscript parser... because...

domain driven design - Help applying DDD to dynamic form application -

domain driven design - Help applying DDD to dynamic form application - i designing application display dynamically-generated forms user come in values form fields , submit values persistence. form represents employee evaluation. one utilize case allows administrator (from hr) define form fields. should able create new form, add/remove fields form , mark form 'deleted'. the sec utilize case when manager views form , enters values form fields specific employee. should able save values @ time , recall saved values when viewing form 1 time again same employee. finally, when manager satisfied values they've entered employee, can 'submit' form info persists flattened info data warehouse reporting purposes. when done, 'working' re-create of info removed form display empty next time view employee. i not concerned front-end @ point , working on back-end service application sits between client , info store. application must provide course...

arrays - what does the following c++ code do -

arrays - what does the following c++ code do - i know naive question, not able understand next code does. #include <malloc.h> #define maxrow 3 #define maxcol 4 int main(){ int (*p)[maxcol]; p = (int (*)[maxcol])malloc(maxrow*sizeof(*p)); } please provide finish explanation including type , size of p. it learning purpose. not using code in real application. as far can tell, it's gibberish. meant (int(*)[maxcol]) . in c means programmer wrote doesn't know how void pointer typecasts work. in c++ means allocating array of arrays. p array pointer, *p array of size maxcol, , allocate maxrow such arrays. result "mangled" 2d array. avantage of using rather obscure syntax 2d array has every cell in adjacent memory, wouldn't accomplish more commonly seen pointer-to-pointer dynamic 2d array. c++ arrays malloc

php - ConvertPrice changing -

php - ConvertPrice changing - i guys seek create link override on prestashop function convertprice (in tools class) : <span>750</span>,00€ with code in override : /** * homecoming cost converted * * @param float $price product cost * @param object $currency current currency object * @param boolean $to_currency convert currency or currency default currency */ public static function convertprice($price, $currency = null, $to_currency = true) { if ($currency === null) $currency = currency::getcurrent(); elseif (is_numeric($currency)) $currency = currency::getcurrencyinstance($currency); $c_id = (is_array($currency) ? $currency['id_currency'] : $currency->id); $c_rate = (is_array($currency) ? $currency['conversion_rate'] : $currency->conversion_rate); if ($c_id != (int)(configuration::get('ps_currency_default'))) { if ($to_currency) $price *= $c_rate; else ...

Java:Evaluation of Mathematical Expression only from left to right -

Java:Evaluation of Mathematical Expression only from left to right - i have written java programme evaluates mathematical look left right (no precedence, left right). however, i'm not getting desired output. import java.util.*; public class evaluation { //private static final char[] validoperators = {'/','*','+','-'}; private evaluation() { /* using private contructor prevent instantiation using class simple static utility class */ } private static int evaluate(string leftside, char oper, string rightside) throws illegalargumentexception { system.out.println("evaluating: " + leftside + " (" + oper + ") " + rightside); int total = 0; int leftresult = 0; int rightresult = 0; string originalstring =leftside; int operatorloc = findoperatorlocation(leftside); leftside...

iphone - Problem with pdf while opening in UIWebView -

iphone - Problem with pdf while opening in UIWebView - i have problem while opening pdf in uiwebview. zoom in , zoom out doesn't work , double tap doesn't enlarge pdf font size. guys there way that.... if not can share code .... #import @interface tiledpdfview : uiview { cgpdfpageref pdfpage; cgfloat myscale; } - (id)initwithframe:(cgrect)frame andscale:(cgfloat)scale; - (void)setpage:(cgpdfpageref)newpage; @end #import "tiledpdfview.h" #import @implementation tiledpdfview // create new tiledpdfview desired frame , scale. - (id)initwithframe:(cgrect)frame andscale:(cgfloat)scale{ if ((self = [super initwithframe:frame])) { catiledlayer *tiledlayer = (catiledlayer *)[self layer]; tiledlayer.levelsofdetail = 4; tiledlayer.levelsofdetailbias = 4; tiledlayer.tilesize = cgsizemake(512.0, 512.0); myscale = scale; ...

.net - Find Pictures in Web? -

.net - Find Pictures in Web? - i want have tool able find pictures in web. that means have pictures watermark me within image , need able scan webpages (and pictures in it) , see if image online on webpage. background is, used image (with watermark me) , win cost it! to pictures specific site easy. question is, how can within image watermark? you want scan entire net looking pictures yours? that's lot of work, why not utilize tinyeye hard work you? think you've underestimated what's involved in doing yourself. .net image watermark

How to implement facebook Credits API using Rails 3 -

How to implement facebook Credits API using Rails 3 - how can implement facebook credits api in rails 3. there gem or helpers this? using koala gem facebook posible implement credits api. thanks in advance sample code included in answer: is there facebook credits ruby on rails gem out there yet? or ruby version of facebook credits sample app? i trying figure out how create first ever gem , gemify - expect pushed in next few weeks. ruby-on-rails-3 facebook facebook-credits koala

hyperlink - Tumblr header link taking over the whole page -

hyperlink - Tumblr header link taking over the whole page - i screwed somehow , have no thought where. i've spent hours trying figure out reason have few 'pages' on tumblr , have been behaving fine. added youtube embed in used carry text , if click anywhere in body of page tries take non-existant homepage. http://blog.pissinggraffiti.com/sights if click of socialize, pg, or go "...com/donations" see have same problem, keeps in header. in safari on 'sights' page see unusual orange underline header there unusual highlight behavior on non-link text, , 'designline' (that yellowish line under header) buffer differences have feeling they're tied together. if can peek on @ page , tell me figure out i'd appreciate it. i'm stumped =/ header hyperlink tumblr underline

algorithm - Help on Elo System specifics for large group competitions -

algorithm - Help on Elo System specifics for large group competitions - i'm trying implement elo-based ranking scheme sport website deals with. there's few one thousand competitors, , each competition sees 50 500 of them go against clock. fastest man wins. my initial thought race 50 people can treated 50*49/2 = 1225 one-on-one matches. i of these comparisons in 1 go, , adjust each competitors rating @ end. i.e. if someone's rating 1600 remains 49 comparisons make, , adjusted sum of changes @ end. doesn't seem right... should doing? the problem have if 1 (normally strong) competitor has terrible day (e.g. injury) can beaten 40+ people beat. have lower ratings him, , such rating gets pummelled. recommended k-factor of 32 see swings of thousands of points in single event... if drastically cut down k factor (say, 1) things better, sense flawed. instead of summing of adjustments, should averaging them in way? or taking extreme value? got head in bi...

math - Project Euler Spoilers, #001 - PHP Sums -

math - Project Euler Spoilers, #001 - PHP Sums - i cannot inquire help on forums, i've been @ 3 hours now. spoilers below don't understand i'm doing wrong. question is: if list natural numbers below 10 multiples of 3 or 5, 3, 5, 6 , 9. sum of these multiples 23. find sum of multiples of 3 or 5 below 1000. here's equation made. for($total = 0, $f = 5, $t = 3; $t < 1000; $t+=3){ if($f < 1000) { $total += $f + $t; echo "five: $f, three: $t = $total"; $f += 5; } else { $total += $t; echo "five: $f, three: $t = $total"; } } the reply is:233168. where's error? you counting numbers divisible both 3 , 5 twice. php math

iPhone photo app communication with Rails server -

iPhone photo app communication with Rails server - i building iphone app uploads/downloads photos rails server. how should transfer photos to/from rails server iphone? should utilize json? rails app supports restful architecture. pointers examples help. i did similar, , suggest using asihttp on iphone side, communicating rails app. here how utilize asihttp: http://allseeing-i.com/asihttprequest/how-to-use pay special attending section "sending form post asiformdatarequest" you can attach photos (or file, really) saying [request setfile:@"photo.jpg" forkey:@"photo"] then can access/manipulate on rails side through params iphone ruby-on-rails json image

sql - Postgresql: Insert the cartesian product of two or more sets -

sql - Postgresql: Insert the cartesian product of two or more sets - as definition: cartesian product of 2 sets set of possible pairs of these sets, {a,b} x {a,b} = {(a,a),(a,b),(b,a),(b,b)}. now want insert such cartesian product database table (each pair row). intended fill table default values each pair, data, i.e. 2 sets, not nowadays in database @ point. any thought how accomplish postgresql? edit : with help of grzegorz szpetkowski's reply able produce query want achieve, isn't prettiest one. suppose want insert cartesian product of sets {1,2,3} , {'a','b','c'}. insert "test" select * (select 1 union select 2 union select 3) p cross bring together (select 'a' union select 'b' union select 'c') q is there improve way this? edit2 : accepted reply fine, found version might appropriate if gets more complex: create temp table "numbers" (id integer) on commit drop; create temp tab...

Foreign keys have random number appended when using Hibernate's TABLE_PER_CLASS inheritance -

Foreign keys have random number appended when using Hibernate's TABLE_PER_CLASS inheritance - i have next in domain model: @inheritance(strategy = inheritancetype.table_per_class) @entity abstract class item { @manytoone @foreignkey(name="fk_item_org") @joincolumn(name="org_id") private organization org } @table(name = "itema") public class itema extends item {} @table(name = "itemb") public class itema extends item {} hibernate's hbm2ddl creates 2 tables mapping: itema , itemb . both have org_id column , foreign key organization table. however, each foreign key has random number appended (ie fk_item_org98343). how can specify foreign key each table uses? example, want have fk_itema_org , fk_itemb_org . update please see follow-on question: is foreignkey annotation used hbm2ddl generate schema? unfortunately, have remove annotation field in main class , move method in each children providing fk...

javascript - copying from "window.prompt" in chrome copies the message, not the text, with ctrl+c -

javascript - copying from "window.prompt" in chrome copies the message, not the text, with ctrl+c - i have setup if nail button, selected text copied clipboard (for ie). selection of text works, since every browser ie doesn't allow copying clipboard, have workaround window.prompt ("copy clipboard: ctrl+c, enter", text); //where text selected text beingness passed this works firefox, in chrome, reason, when re-create text ctrl+c, "copy clipboard: ctrl+c, enter" copied, not in text. any ideas this? javascript google-chrome

c# - Cannot write to file after reading -

c# - Cannot write to file after reading - in next code error "stream not writable": class class1 { private static void main() { filestream fs = new filestream("c:\\ffile.txt", filemode.openorcreate, fileaccess.readwrite, fileshare.readwrite); streamreader r = new streamreader(fs); string t = r.readline(); r.close(); console.writeline(t); streamwriter w = new streamwriter(fs); w.writeline("string"); w.flush(); w.close(); fs.close(); } } the error occurs @ line streamwriter w = new streamwriter(fs); why this? from msdn closes streamreader object , underlying stream, , releases scheme resources associated reader. so stream seek write invalid need reopen stream , reopen file. c# file-io

java - Eclipse plug-in for launching several run configurations -

java - Eclipse plug-in for launching several run configurations - i want create plug-in allow run several chosen(ctrl+click) configuration “run configurations” form 1 click. have made plug-in contextual menu(extension point org.eclipse.ui.popupmenus),but can't find “objectclass” configuration. what name of class object of configuration(conf have different types – junit, eclipse appl , on)? instead of implementing, download , utilize plugin sources attached https://bugs.eclipse.org/bugs/show_bug.cgi?id=39900#c30 ("a plug-in project show basic workflow" zip file) cheers, max java eclipse configuration eclipse-plugin

php - how to count number of rows in related table -

php - how to count number of rows in related table - i have 2 tables in database articles next fields id author post_date modification title section_id views featured content post_status sections next fields sec_id description slug category i have function in model homecoming sections function get_all() { $q = $this->db->select('sec_id,category,slug,description') ->from('sections') ->order_by('category','asc'); $ret['rows'] = $q->get()->result(); homecoming $ret; } am display in table <div id="categories"> <div id="toolbar"> </div> <table> <thead class="table_header"> <tr> <th><input type="checkbox" name="check_all" id="master_box" onclick="toggle(this)" />...

math - fitness function and Selection for a Genetic Algorithm -

math - fitness function and Selection for a Genetic Algorithm - i'm trying design nonlinear fitness function maximize variable , minimize variable b. issue maximizing much more of import @ single digit values, logarithmic. b needs minimized , in contrast a, becomes less of import when little (less one) , more of import when it's larger (>1), exponential decay. the main goal optimize a, guess analog a=profits, b=costs should aim maintain positive can utilize roulette wheel selection, or improve utilize rank/torunament kind of system? purpose of algorithm shape optimization. thanks when considering multi-objective problem goal usually identify solutions lie on pareto curve - pareto optimal set. have look here 2-dimensional visual example. when algorithm completes want set of solutions not dominated other solution. you hence need define pareto ranking mechanism take business relationship both objectives - more in depth explanation, links more reading...

javascript - Is there a way to append code to an asp.mvc section -

javascript - Is there a way to append code to an asp.mvc section - i have partials rendered part of complex page composition. some of these partials need jquery ondocumentready goodness seed list info etc. there can many of these partials chosen during render (it's dynamic) in _layout have section definition looks this <script src="http://my/fav/cdn/jquery-1.5.1.min.js" type="text/javascript"></script> <script type="text/javascript"> jquery(function($) { @rendersection("ondocumentreadysection", false) }); </script> in partials want write this @section ondocumentreadysection{ $('#partial-1').init(); } and have result of page render end this <script src="http://my/fav/cdn/jquery-1.5.1.min.js" type="text/javascript"></script> <script type="text/javascript"> jquery(function($) { $('#partial-1').init(); $('#partial...

ruby on rails - Database Model and associations solution -

ruby on rails - Database Model and associations solution - i have models user, developer, app, permission a user can have default permision a user can have permission different application a user can install multiple applications a user can developer of application a developer still user , can have user's privillage (install applcation, default permission, permissions each application) until have: user.rb class user < activerecord::base has_many :apps end app.rb class app < activerecord::base has_many :permissions, :through => :app_permissions end permission.rb class permission < activerecord::base belongs_to :app end app_permission.rb class apppermission < activerecord::base end questions how distinguish users? (regular, developer) improve utilize cancan or rails sti or simple roles class? please justify why improve utilize of 3 solutions or else. is improve create default_permission model separate application pe...

conditional - java using logical operators instead of if-else if for return -

conditional - java using logical operators instead of if-else if for return - i have next code in equals method. public boolean equals(object o){ if (o == null) homecoming false; if (o == this) homecoming true; if (!(o instanceof vertex)) homecoming false; homecoming ((vertex) o).label().equals(label); } my ide highlights if statement , wants me this public boolean equals(object o){ homecoming (o != null) && ((o==this) || ((o instanceof vertex) && ((vertex) o).label().equals(label); } i've been told compiler smart plenty optimize , in general 1 should code readability. so, sec code sample not easy read first. ide beingness annoying or there actual performance merit doing way? first, optimize if know it's bottleneck, else code readability. you can check byte code see suspect pretty close if not same. if there slight differences in bytecode, i've seen jit compiler optimize stuff downwards there no differe...

sql - Query table records with points (geometry) within area -

sql - Query table records with points (geometry) within area - i have table (locations) has field called point (geometry). wrote query passes top , bottom latitude coordinates , bottom , top longitude coordinates. want retrieve records within area of coordinates pass stored procedure. when run returns 0 records though know there record matches criteria. ideas might doing wrong? declare @categoryid int,@leftlong float,@rightlong float,@toplat float,@bottomlat float declare @searcharea geometry, @polygon varchar(500); set @leftlong = -85.605469 set @toplat = 42.303468 set @rightlong = -85.594912 set @bottomlat = 42.297564 set @polygon = cast(@leftlong varchar(20)) + ' ' + cast(@toplat varchar(20)) + ',' + cast(@leftlong varchar(20)) + ' ' + cast(@bottomlat varchar(20)) + ',' + cast(@rightlong varchar(20)) + ' ' + cast(@bottomlat varchar(20)) + ',' + ...

objective c - Zooming out to see all the pins in MapView -

objective c - Zooming out to see all the pins in MapView - i have 20-30 pins displayed on mapview command , want zoom out pins visible. here code: mkcoordinateregion part = mkcoordinateregionmakewithdistance([mp coordinate],500000, 500000); [mv setregion:region animated:yes]; how can that? /** * center map on area covering annotations on map. */ - (void)recentermap { nsarray *coordinates = [self.mapview valueforkeypath:@"annotations.coordinate"]; // minimum , maximum coordinate cllocationcoordinate2d maxcoord = {-90.0f, -180.0f}; cllocationcoordinate2d mincoord = {90.0f, 180.0f}; for(nsvalue *value in coordinates) { cllocationcoordinate2d coord = {0.0f, 0.0f}; [value getvalue:&coord]; if(coord.longitude > maxcoord.longitude) { maxcoord.longitude = coord.longitude; } if(coord.latitude > maxcoord.latitude) { maxcoord.latitude = coord.latitude; } ...

C# using WMI to query Win32_Fan class and fan speed return null? -

C# using WMI to query Win32_Fan class and fan speed return null? - here code used query fan speed, fan speed homecoming null. know why? public static void win32_fan() { selectquery query = new selectquery("win32_fan"); // initialize object searcher query managementobjectsearcher searcher = new managementobjectsearcher(query); // resulting collection , loop through foreach (managementobject fan in searcher.get()) { console.writeline("{0} = activecooling {1}",fan["name"], fan["activecooling"]); console.writeline("desiredspeed = {0}", fan["desiredspeed"]); } } what hans alluding fact wmi dependent on device driver supplies it. wmi defines big assortment of classes kinds of useful properties, of (related hardware, anyway) need filled in driver. if driver doesn't give wmi information, wmi can...

Call javascript from php in while loop -

Call javascript from php in while loop - i hope can help me, i've been struggling, have , within form table has columns. retrieves info mysql table. in column 2 displays current info , in column 3 displays form options update values, eg: first name: john [form field update] date of birth: 1970-01-01 [form field update] i'm struggling java script functioning popup calendar. if run html works fine when within php can't run because displays form within while loop: <head> <script src="datetimepicker_css.js"></script> </head> <body> <?php ..... $sql2="select * em_detail id = '$data1'"; $result2=mysql_query($sql2); echo "<form action='upd_emp.php' method=post>"; while($row2 = mysql_fetch_assoc($result2)) { $id_2 = $row2['id'] ; ..... echo "<tr>"; echo "<td height=35px><strong>date of birth: </strong></td>"; e...

javascript - Multiple keyword (that has regex) search through JSON -

javascript - Multiple keyword (that has regex) search through JSON - i have json looks like: "groups": [ "group_id": "8", "group_name": "building", "group_color": "00ff00" }, { "group_id": "3", "group_name": "building", "group_color": "8000ff" }, { "group_id": "2", "group_name": "sidewalk", "group_color": "ff0000" }, { "group_id": "6", "group_name": "parking lot", "group_color": "00ffff" }, { "group_id": "3", "group_name": "commons", "group_color": "ff8000" }, { "group_id": "5", "group_name": "other", "group_color": "ff00ff" } ] and when field found flips boolean flag. e.g. ...

django - how to use django_csrf for mobile application -

django - how to use django_csrf for mobile application - i writing mobile application django website. understand every form in django has csrf token key protection. when utilize browser navigate site, server render key user. what confused mobile application, dont need view presetation layer site. wanna http post send data. know can utilize csrf_exempt disable csrf form. or can create view render csrf token me, way need parsing , http request. there nicer way it? thanks time if mobile app rendering template can add together {% csrf_token %} template renders form. if you're not using form , instead posting info can create token above , post it's value data. , if you're not using template create mobile app's markup utilize csrf_exempt (if you're posting info server periodically). obviously there has view process posted data, if you're using generic view still wrap view (in urls.py example) , gain utilize of csrf_exempt django d...

linux - Using -dynamic-linker with a linker script? -

linux - Using -dynamic-linker with a linker script? - i using linux 2.6.31-14 on intel 32-bit processor. c file: #include <stdio.h> main() { printf("hello world!\n"); } linker script: sections{ .text 0x00000100 :{ *(.text) } } output: $ gcc -s test.c $ -o test.o test.s $ ld -t linker.ld -dynamic-linker /lib/ld-linux.so.2 -o test test.o test.o: in function `main': test.c:(.text+0x11): undefined reference `puts' what wrong? how can create linker script utilize dynamic c library? i think should link programme c standard library (libc.so) adding -lc alternative ld arguments. ld -t linker.ld -lc -dynamic-linker /lib/ld-linux.so.2 -o test test.o also may have problems running programme (segmentation faults) because test.o have no programme entry point (_start symbol). need additional object file entry point calling main() function within test.o , termitates code execution calling exit() scheme call. ...

vb.net - Append text to a textbox VB -

vb.net - Append text to a textbox VB - i attempting append info textbox in vb. app allows user take variety of options , displays info in single, read-only text box. i set every time event triggers written in text box, gets appended instead of overwriting text in box. i have seen solutions online lot of them seemed overly complicated task. if has simple solution, much appreciated. the constraint text should appended new line, not straight after lastly sentence. thank private sub addline(byval line string) me.txtthetextbox.text = if(me.txtthetextbox.text = string.empty, line, me.txtthetextbox.text & controlchars.crlf & line) end sub vb.net

multithreading - Thread switching -

multithreading - Thread switching - how execute callback method in same thread calls asynchronous function. caller thread may not ui thread... ui should not hang.. thanks & regards, dinesh there no magic bullet allow 1 thread initiate execution of delegate onto thread. target thread must specially constructed allow this. in case of ui thread there message pump dispatches , processes messages. message pump can used perform marshaling operation via isynchronizeinvoke interface. isynchronizeinvoke target = someform; // someform form or command target.invoke( (action)(() => { messagebox.show("i on target thread"); }), null); in case thread calling asynchronous function must have kind of producer-consumer mechanism built callback execute asynchronously on thread after has been instructed worker thread. unfortunately, not trivial problem solve. here 1 way can create thread can take delegates executed. public class synchronizeinvokethread...

c# - Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'Type[]' to 'Type'? -

c# - Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'Type[]' to 'Type'? - i error after created class xsd file using xsd.exe tool. searched net , found solution. here link: http://satov.blogspot.com/2006/12/xsdexe-generated-classes-causing.html problem makes code run, somehow deserialized info seems corrupt. did site suggests , in end 2nd array dimension empty (see comments of site, had problem). question is, how solve issue now? there tool create xsd file? tried xsd2code, without success. thanks :-) you need alter type of fellow member variable in serialized class. illustration if raising error like: unable generate temporary class (result=1). error cs0030: cannot convert type 'data[]' 'data'. i ran search on info type name in generated file, , found this: [system.xml.serialization.xmlarrayitemattribute("data", typeof(data), isnullable=false)] public data[][] row replac...

Jquery property disable -

Jquery property disable - is there property in jquery help me check if txtbox disabled? , lets me compare through if statement? for example: if ($('#ctl00_contentplaceholder1_textbox3'). == "false") { } you can utilize :disabled selector. try: if ($('#ctl00_contentplaceholder1_textbox3').is(":disabled")) { } or if ($('#ctl00_contentplaceholder1_textbox3:disabled').length) { } jquery

java - how to disable lwuit vkb? -

java - how to disable lwuit vkb? - the ability disabling vkb included in new svn source code... default vkb comes in midlet... how disable in midlet... in old documentation given to utilize lwuit virtual keyboard application must call: vkbimplementationfactory.init(); before calling to: display.init(this); but in latest version vkbimplementationfactory deprecated . , old documentation given enable only...there no details disabling. use display.setdefaultvirtualkeyboard(null); java java-me lwuit midlet virtual-keyboard

oauth - How do you renew an expired Facebook access token? -

oauth - How do you renew an expired Facebook access token? - i working this reference, , trying implement oauth protocol allow users log site via facebook. however, facebook's documentation pretty terrible , unclear in few key parts. it says authorization takes 3 steps: user authentication (redirect user https://facebook.com/dialog/oauth?client_id=...&redirect_uri=... , , expect redirect_uri page called code ). works great! app authorization (handled facebook, etc). works great! app authentication (on callback page, grab code , phone call https://graph.facebook.com/oauth/access_token?client_id=...&redirect_uri=...&client_secret=...&code=... . body of response include access_token need stuff) i understand access_token , can phone call apis , such. but, happens when expires? new one, point many http requests later, , no longer have code used in first place. have store code along side access_token ? or, have tell user log in 1 time again new cod...

javascript - Select all checkboxes issue(jQuery) -

javascript - Select all checkboxes issue(jQuery) - i have little issue, if select single checkbox , press f5 state of checbox remain(so checked) if utilize jquery select checkboxes on page , press f5 of checkboxes blank(so uncheck, one's handpicked remain in there state). how can solve this, when nail refresh remain same? the code jquery('.sellectall').click(function(){ $('input:checkbox').attr('checked',true); }); i assume you're using jquery 1.6 or later. if so, utilize prop() [docs] method instead of attr() [docs] method. then should same behavior if user clicked box. jquery('.sellectall').click(function(){ $('input:checkbox').prop('checked',true); }); ...or set checked property manually: jquery('.sellectall').click(function(){ $('input:checkbox').each(function() { this.checked = true; }); }); javascript jquery forms checkbox