Posts

Showing posts from February, 2011

ios - SELECT from VIEW with FMDB -

i have sqlite database following tables: player card team playercard carddatacomposed view created following select: select player.playerid, player.playerfirstname, player.playerlastname, card.cardid, team.teamid, team.teamname player, card, playercard, team player.playerid=playercard.playerid , card.cardid=playercard.cardid , team.teamid=playercard.teamid; using sqlite3 command line tool, select * carddatacomposed returns of records. using same query fmdb: nsstring *dbquery = @"select * carddatacomposed"; [self.database executequery:dbquery]; does not return records. imagine has how i'm (incorrectly) putting query fmdb can retrieve records properly. how fix query select records view? able query views fmdb? in advance! i had delete contents of documents directory in simulator see changes made database. above query works expected.

Search data from array in php -

i want data php array , show on same page. how import data php array using search box. code not working properly. th error of code? foodstore.js var xmlhttp = createxmlhttprequestobject(); function createxmlhttprequestobject(){ var xmlhttp; if(window.activexobject){ try{ xmlhttp = new activexobject("microsoft.xmlhttp"); }catch(e){ xmlhttp = false; } } else{ try{ xmlhttp = new xmlhttprequest(); }catch(e){ xmlhttp = false; } } if(!xmlhttp) alert("cant create object hoss!"); else return xmlhttp; } function process(){ if(xmlhttp.readystate==0|| xmlhttp.readystate==4){ food = encodeuricomponent(document.getelementbyid("userinput").value); xmlhttp.open("get","foodstore.php?food="+food,true); xmlhttp.onreadystatechange = handleserverresponse;

ember.js - Ember removes element from DOM after creating it, and jQuery can not find it -

i have wrapper around ember.select , activate select2 features: app.select2selectview = ember.select.extend({ prompt: 'please select...', classnames: ['input-xlarge'], didinsertelement: function() { ember.run.scheduleonce('afterrender', this, 'processchildelements'); }, processchildelements: function() { this.$().select2({ // here configuration of // select2 component escapemarkup: function (m) { return m; } // not want escape markup since displaying html in results }); }, willdestroyelement: function () { this.$().select2('destroy'); } }); sometimes need make drop-down invisible, , this: {{#if cityvisible}} <div class="control-group"> <label class="control-label">city</label> <div class="controls"> {{view settingsapp.select2selectview

c# - Pervasive SQL System Stored Procedure from ADO.NET error -

i'm trying return list of columns , attributes through system stored procedure. documentation have seems below code should work, "pervasive.data.sqlclient.lna.k: [lna][pervasive][odbc engine interface]invalid or missing argument." on execute. psql v11, .net 4.5. using (psqlconnection conn = new psqlconnection(cs)) { psqlcommand locationcmd = new psqlcommand(); psqlparameter tableparam = new psqlparameter(); psqlparameter returnparam = new psqlparameter(); returnparam.direction = parameterdirection.returnvalue; locationcmd.commandtext = "psp_columns"; locationcmd.connection = conn; locationcmd.commandtype = commandtype.storedprocedure; locationcmd.parameters.add(tableparam).value = table; locationcmd.parameters.add(returnparam); conn.open(); locationcmd.executenonquery(); } i think problem line: locationcmd.parameters.add(tableparam).value = table

spring - Is it possible to drive the @Size "max" value from a properties file? -

i'm using spring 3.1.1.release. have model following attribute import javax.validation.constraints.size; @size(max=15) private string name; i validate model in controller running @requestmapping(value = "/save", method = requestmethod.post) public modelandview save(final model model, @valid final myform myform, i have "15" value come properties file instead of hard-coded, unclear if that's possible or how done. ideas? this not possible. constant expression provide value max attribute added @ compile time. there no way change value of annotation @ runtime. setting properties file read therefore not possible what can instead create , register own validator class has field. example, public class myvalidator implements validator { public void validate(object target, errors errors) { myobject obj = (myobject) target; int length = getproperties().get("max.size"); if (obj.na

tags - How to add some text after the text in the span using jquery? -

i want insert text after text in span follows. want add &times after tag1 "tag 1 &times". &times after </span> , means outside span. thanks. bty, there suggestion delete button tags? html: <li><span>tag 1</span></li> jquery: $('li span').append('<p>&times</p>'); var span = $('li span'); span.html(span.html() + '&times'); is you're looking for? if want in 1 line: $(that).find('span')[0].innerhtml += '&times';

How to control a conflicting click event with jQuery -

i have following html... <div id="panel"> <a class="ext" href="http://google.com">google</a> </div> if have $(#panel).on({ click: function(e) {...} event expand div height or collapse it, how tell click event "not fire" if click on .ext class item, can go google.com. thanks advice an alternative approach test target of click event: $('#panel').on({ click: function(e) { var target = e.target, $target = $(target); if ($target.hasclass('ext')) { window.location = target.href; } else if { // whatever you'd click on #panel } }); references: hasclass() .

javascript - Execute function only by correct series of keys -

i'm not professionally, out of curiosity since recently. have basic of basic knowledge. my current experiment this; can program series of keys, execute specific function, , in correct order? i'm saying game combo (ie: famous konami code easter egg, consisting of '↑', '↑', '↓', '↓', '←', '→', '←', '→', 'b', 'a', , 'start') if, say, use 'onkeydown' this, registers 1 key, not taking regard keys pressed earlier or after (or believe). if not, have somehow record came before and... waaaay out of little fishies league. is there way such thing, simpler , easier? please don't expect me know much, , please no jquery or such js library :d usage. could script in konami code example? js char codes pattern 38 38 40 40 37 39 37 39 66 65 13, replacing nintendo 'start' 'enter' key. here's working example, if mess up, can restart sequence , forgive you. al

xml - issue assigning ajax response length to a var by jquery -

this question has answer here: how return response asynchronous call? 21 answers i have ajax request send vars on url , gets xml nodes back. ajax works good, in fact can see response when debug firebug... problem when try assign number of nodes var jquery. this function: function cargartvalores(){ try{ $.ajax({ url: 'f_func.php?f=g_tv&adm=1', data: {}, success:function(result){ alert("entro"); var algo = 0; algo = $(result).find('error').length; if(algo>=1){ alert(tostring($(result).find('error').first().text())); } }, error:function(){ alert("error inesperado."); } }); }catch(e){ alert("algo paso"); } } i know response of ajax this: <?xml versi

java - Efficiency of Random Method -

i read not want make new instances when unnecessary. not sure if understand saying. problem repeat of in logcat: 08-09 17:12:11.300: d/dalvikvm(19620): gc_for_alloc freed 2281k, 23% free 9365k/12048k, paused 12ms, total 12ms so better have method: public int rand(int i) { int rand = new random().nextint(i); return rand; } than have method: public int rand(int i) { return new random().nextint(i); } if calling rand() lot? why or why not? helping newb! do this: class ... { private final random dice = new random(); public int rand(int i) { return dice.nextint(i); } } that way, calling new random() once, instead of every time generate number.

php form change sha1 password with sed and exec -

i'm working on simple password reset form, great deal of here have working. add twist , save reset password in sha1. here code: #password file $password='something'; <?php // change password $rawpassword = (isset($_request["change_pwd"])); $salt = "lgv932q2e9dshufkdjgf927gf8hlo082"; $newpass = sha1($salt . $rawpassword); $change_pass = exec('sed -i " . escapeshellarg("s/\$password=.*/\$password=\'$newpass\'/g")." include/conf.php'); echo "$change_pass"; ?> <form method="get" action="<?php echo $_server['php_self']; ?>"> <input type="text" name="change_pwd" maxlength="41"> <input type="submit" name="submit" value="submit" /> </form> when submit new password, doesn't change sha1 password correctly in file. instead every time password value gets changed to:

Completely disable Forms authentication in ASP.NET -

how disable forms authentication in asp.net application , replace custom authentication module? i set authentication mode none in web.config <authentication mode="none" /> and attached own authentication module <add name="customauthenticationmodule" type="customauthenticationmodule, auth"/> my custom authentication module has application.authenticaterequest += new eventhandler(this.application_authenticaterequest); application.postauthenticaterequest += new eventhandler(this.application_postauthenticaterequest); application.authorizerequest += new eventhandler(this.application_authorizerequest); everything looks working except 1 thing... when try access secured page required admin roles <location path="somepage.aspx"> <system.web> <authorization> <allow roles="admin"/> <deny users="*"/> </authorization> </

javascript - Grouping values in grid panel after double clicking -

i want group values in grid panel below code: var store = ext.create('ext.data.treestore', { root: { expanded: true, children: [ { text: "school friends", expanded: true, children: [ { text: "mike", leaf: true, name: "mike", email: "mike@stackoverflow.com", phone: "345-2222"}, { text: "laura", leaf: true, name: "laura", email: "laura@stackoverflow.com", phone: "345-3333"} ] }, { text: "facebook friend", expanded: true, children: [ { text: "steve", leaf: true, name: "steve", email: "steve@stackoverflow.com", phone: "345-2222"}, { text: "lisa", leaf: true, name: "lisa", email: "lisa@stackoverflow.com", phone: "345-3333"} ] }, ] }}); ext.create('ext.tree.panel', { title: 'all friends', wid

webpage - Colors to use with black background? -

Image
is using yellow text on black bg bad mike pointed out here ? if yes colors should use (rgb or hex values)? yellow bad choice, using grey intensity values varying from; rgb: 65 65 65 rgb: 180 180 180 can solve problem. gives decent, elegant site well. something try. hope helps.

c# - Increase or update amount on Entity Framework -

how can translate this: insert test (id, amount) values(1, 5) on duplicate key update amount=amount + values(amount) into entity framework mysql query? extract logic. explained in manual : if specify on duplicate key update, , row inserted cause duplicate value in unique index or primary key, update of old row performed. example, if column declared unique , contains value 1, following 2 statements have identical effect: insert table (a,b,c) values (1,2,3) on duplicate key update c=c+1; // , update table set c=c+1 a=1; your query says: insert row id 1 , amount 5, if exists, increase amount of row id 1 5. ms-sql does, far know not support such statement, you'll have work yourself: public void insertorupdatetest(test input) { var entity = _dbcontext.test.firstordefault(t => t.id == input.id); // if record doesn't exist, create , add dbset<test> tests if (entity== null) { entity= new test(id = input.id);

angularjs variables in the view not changing when scope change -

i'm new angularjs. have serious problem. , have been stuck @ point last 48 hours. problem: my view not updating when update variable in controller. here's code. var stdata; function mainctrl($scope,$http){ retrievedataset($scope,$http, 'http://localhost:8080/ramap-service/dataprovider?title='+$scope.title+'&year='+$scope.year); $scope.$apply($scope.changemap = function(){ var curl = 'http://localhost:8080/ramap-service/dataprovider?title='+$scope.title+'&year='+$scope.year; console.log(curl); showdialog(); retrievedataset($scope,$http,curl); }); function retrievedataset($scope,$http, curl){ $http.get(curl).success(function (data,status){ console.log(data.description); $scope.desc = data.description; loadcolors(data.results); stdata=data.results; handlekeys($scope,data.results); }).error(function(data,status){ conso

d2 - Thread-local storage variables in D, confusion about interaction with module initializers -

let's have globals , thread-local variables getting initialized (say, tls a , global b , tls c , , global d initialized in order) in module's static this() , deinitialized in static ~this(). could please walk me through steps taken program initialize variables in both single , multi-threaded applications? or correct me if i'm making really horrible assumption? edit: make little clearer: module mymodule; int a; __gshared int b; int c; __gshared d; static this() { = 2; b = 3; c = 4; d = 1337; } static ~this() { if(a == 2) dosomefunc(b); // , other nonsensical things involve branching on tls , using globals. } what happens when change value of in thread spawned, never touch in main thread? dosomefunc() ever called? actual behavior supposed here, , behavior dependent on? how module initializers called regards tls? called once , tls vars shaft beyond value initialization? in world 2 (de)initializers mean ? there 2 types of static constructors:

c# - Upload XML file by Web Service -

i trying upload xml file local drive through soap web service, , saved sql 2008 r2 database. data type of column xml. below xml in file. <?xml version="1.0" encoding="utf-8"?> -<dataresult> -<unit> <serialno>359815604755374</serialno> <savedtime>20130723113546</savedtime> <result>pass</result> <message/> </unit> </dataresult> i need save xml file sql database. because have submit xml file our customer reference. what method should use in order achieve goal? can use xml serialization , deserialization? i design web method accept string of xml text. can use string directly in sql insert command. public string uploadxml(string xmlstring) { using (var connection = new sqlconnection(myconnectionstring)) { using (var command = connection.createcommand()) { command.commandtext = "insert mytable (xmlcolumn) values (@xmltext)";

javascript - iOS css -webkit-transform: scale doesn't offset touch events -

i have iframe need pull in display on ios devices. contents of iframe not under control , not responsive in way (fixed 800x600). i'd scale iframe down display in ios viewport. using -webkit-transform: scale(0.4) able scale down touch events wrong (e.g. touch form element doesn't pop open keyboard). if touch element before scaling works. is there way correct offset touch events? opt scale3d instead of scale . in experience, transforming elements need responsive better achieved when element pushed accelerated stack. markup <iframe src="http://wikipedia.org" width="200" height="200"/> css iframe { -webkit-transform-style: preserve-3d; -webkit-transform: scale3d(0.4,0.4,0.4); } fiddle: http://jsfiddle.net/gyhr6/ more -webkit-transform-style here: https://www.webkit.org/blog-files/3d-transforms/transform-style.html

ios - Take square image with Cordova (Phonegap) Camera API? -

i have coded camera api take , save photos (on ios). however, want photos square (like instagram). i have set targetwidth , targetheight same pixels images still comes out portrait or landscape, depending on how phone held. my complete api code is: navigator.camera.getpicture(onphotodatasuccess, onfail, { quality: 50, targetwidth: 600, targetheight: 600, correctorientation: 1, savetophotoalbum: 1 }); does know how save square photo api on ios devices? during tests realized same thing, intention opposite. wanted preserve picture's full dimensions, while camera on, "square overlay" shown, implying content inside square saved. then, changed "allowedit" parameter "false" instead of "true". can save full picture. in case, can see not using parameter, maybe should add in code. example: navigator.camera.getpicture(onphotosuccess, onphotofail, { quality : 40, allowedit : false, dest

jquery - How find one msg to multi request response Ajax Data done -

hell send 3 request in ajax, webservice return me 3 success message show one. exemple: .done(function(shipdata) { var ship = $(shipdata); var msgerror = ship.filter('#alert'); if (msgerror == "invalid_shipto_town") { $("#ship-modal-data p").append("code postal, ville destinataire est erronée."); }; rum 3, show 1 code postal, ville destinataire est erronée. code postal, ville destinataire est erronée. code postal, ville destinataire est erronée. thank u helpe me append add message p tag each response, added 3 times if 3 errors. use text function overwrite p content instead , you'll have single message @ end: $("#ship-modal-data p").text("code postal, ville destinataire est erronée.");

ios - Getting tableView to scroll as one with parent scrollView after being added with addChildViewController -

i'm working through tutorial on child view controllers in rubymotion . (what i'm trying create tabbed interface in likes of instagram's profile pages.) have things working, problem container has scrollview , child i'm adding tableview, scrollview. 2 scroll independent of each other, i'd them scroll one. there way can given code below? my container: class profilecontroller < sharedcontroller def viewdidload super scroll_frame = self.view.bounds @scroll = uiscrollview.alloc.initwithframe(scroll_frame) @scroll.bounces = true @scroll.delegate = self @scroll.alwaysbouncevertical = true @scroll.contentsize = cgsizemake(uiscreen.mainscreen.bounds.size.width, scroll_frame.size.height) main_container = uiviewcontroller.alloc.init self.push(main_container) end def tap_child(sender) set_active_tab(sender) controller = childpartialcontroller.alloc.initwithnibname(nil, bundle:nil) controller.data

javasound - Need a little with an audio player in java -

i'm making audio player in java,a small code snippet runs .wav files is: audioinputstream ais = audiosystem.getaudioinputstream(new file("c:\\path\\c4.wav").getabsolutefile()); clip clip = audiosystem.getclip(); clip.open(ais); clip.start(); i want know things java sounds first,what use of mixers,lines,ports in java sounds. second,how include other formats such mp2,mp3...or there general method include format. third,how add volume control. fourth,i making player in net beans how use slider volume control , seek bar. ...and want make audio player using basic java sound api,i'm reading tutorial http://docs.oracle.com/javase/tutorial/sound/toc.html please don't give solutions having javafx or other media files included... first of all, if want play sounds aren't looped , longer few seconds, shouldn't using clips. you're going need use sourcedatalines, can read audio data in several different formats (consult audio

How can I resolve Google reporting "This site may harm your computer" for my website? -

google reporting 'this site may harm computer' website. how can resolve issue? of 17 pages tested on site on past 90 days, 2 page(s) resulted in malicious software being downloaded , installed without user consent. last time google visited site on 2013-07-26, , last time suspicious content found on site on 2013-07-26. malicious software hosted on 3 domain(s), including qygjutwojtgdntqidubw.dnsalias.com/, wink.ie/, 3xindiansex.com/. 2 domain(s) appear functioning intermediaries distributing malware visitors of site, including wink.ie/, 3xindiansex.com/. this site hosted on 1 network(s) including as21844 (theplanet-as). it means of 17 pages on site, 2 pages had links 1 or several of 3 domains qygjutwojtgdntqidubw.dnsalias.com, wink.ie , 3xindiansex.com, domains host malicious software. this happens either because link them, or, or link iframe or javascript links them, or because on shared domain other sites link them.

java - How to read a file in order to check if username has already been created -

so creating program called registerandlogin, have enter username, password , re-enter-password in order create new account. validation of users , passwords can done using: 1.a user name typed in during registration can not same of 5 names in username.txt. 2.also user name has between 5 , 8 characters without numbers (i.e., user name can [a-z] or [a-z] not digits [0-9]). 3.a password between 5 , 8 characters, numbers allowed (so 12345 , abcde both valid passwords). 4.the retyped password must same password, otherwise, error message output after hitting register button. when user name passes 5 8 characters validity check, user name not exist in username.txt, , password passes validity check, new user name added username.txt. so created username.txt 5 names. however, problem have not sure how read username.txt file can check whether username has been used or not. code here, little long , appreciate. import javax.swing.*; import java.io.*; import java.awt.even

graph - How to draw single axis plot in R -

Image
i wish draw very simple line 3 numbers. below |------|--------------| 0.5 1.5 3.4 is simple ask? first, plot nothing, remove axes, , add x-axis in @ specified points: x <- c(.5, 1.5, 3.4) plot(0, xlim = c(0, 3.5), axes=false, type = "n", xlab = "", ylab = "") axis(1, @ = x, labels = x)

c++ - Program address range -

when write simple program using c / c++ , what's address range get? mean, can point wherever want.. : void* ptr = (int*)0xffffffff; where pointer point to? guess not real address in main memory "cover" address of program. can explain me? what's address range (in windows example) when running own c program? can access other program's address range if want to? thanks! your program runs in virtual address space, , pointers point locations within virtual memory. no, cannot expect conjure pointer same numeric value 1 in program , have them both point same actual memory. on contrary, if program crash or otherwise misbehave (but beware: it's undefined behavior, happen , it's platform-dependent).

redis - Fastest serialization/deserialization of Scala case classes -

if i've got nested object graph of case classes, similar example below, , want store collections of them in redis list, libraries or tools should @ that give fastest overall round trip redis? this include: time serialize item network cost of transferring serialized data network cost of retrieving stored serialized data time deserialize case classes case class person(name: string, age: int, children: list[person]) {} your use case targeted use case scala/pickling ( https://github.com/scala/pickling ). disclaimer: i'm author . scala/pickling designed faster, more typesafe, , more open alternative automatic frameworks java or kryo. built in particular distributed applications, serialization/deserialization time , serialized data size take front seat. takes different approach serialization together- generates pickling (serialization) code inline @ use-site @ compile-time, it's fast. the latest benchmarks in our oopsla paper - binary pickle format (

c# - Change the function of a button if Logged in -

i new c#/asp.net-scene , can't seem syntax right myself. want button's text , function change when user logged in. code have far is: if (session["patient"] == "logged in") { button3.visible = false; button4.visible = false; } else { button3.text = "create account"; button4.text = "log in"; } as far understand code above changes button's text,but how change button's function? thanks in advance:-) you can implement same switch in buttons event handler , call different methods. if (session["patient"] == "logged in") { loggedinmethod(); } else { anonymousmethod(); }

php - Textarea content to database -

i have textarea called personalinfos fill infos in following format : <p><span class="white">1966 - '69</span><br/> text .... </p> when submit database, gets saved ok, same format. when retrieve code database admin textarea gets filled ok. my problem on front end displayed code text not rendered html code. basiclly see on page : <p><span class="white">1966 - '69</span><br/> you should have @ htmlspecialchars_decode() example $str = '<p><span class="white">1966 - \'69</span><br/> text .... </p>'; echo htmlspecialchars_decode($str); also make sure escape single quotes well.

Java calling overloaded methods -

this question has answer here: how jvm finds method (parameter closest matching) call in case of function overloading 6 answers consider code segment class stockserver { stockserver(string company, int shares,double currentprice, double cashonhand) {} double buy(int numberofshares, double pricepershare) { system.out.println("buy(int,double)"); return 3.0; } float buy(long numberofshares, double pricepershare) { system.out.println("buy(long,double)"); return 3.0f; } } if execute lines of code, stockserver = new stockserver("",2,2.0,2); byte b=5; a.buy(b,2); the results : buy(int,double) i want know how compiler decide method execute? if have overloaded methods, compiler figures out specific candidate using method signature. in case 2 signatures are buy(int,

ubuntu - MySQL import txt data -

i having problems mysql importing text database. .txt file looks this: a.txt pattern: 1 address: 18phqkzkzp6qumwuiddhj2yrgkzkrmv3j privkey: 5jrpliecq57ijgfvgmme19v1f29zpkwwjtqinjjjpfytqa3zcby pattern: 1 address: 18zvgu7k8wxanwgghdudhdzyrco7aevpbuu privkey: 5jmap8qgujxdhwjhwgkw9fkiuweksdwzl73xu8ihay2fy3kjmn3 etc.... i want import txt. file database called bitcoin table a.txt. lines "pattern: 1" should disappear , table "a" should have 2 columns:" address , privkey" address prim. key. mysql> load data local infile "/home/weber/desktop/a.txt" table -> fields terminated ':' -> lines starting 'address' -> ignore 1 lines; seems not working well, mysql knowledge give me hint, thanks. you seem think file can use more 1 line in text file row. need use 1 line per row. try: pattern:address:privkey 1:18phqkzkzp6qumwuiddhj2yrgkzkrmv3j:5jrpliecq57ijgfvgmme19v1f29zpkwwjtqinjjjpfytqa3zcby 1:18zv

performance - How to retrieve MySQL EAV results like a relational table -

i need extract results 1 table organized eav-feed repository. what need return results relational table. i'm using schema that: table schema meta table ----------------------- idmeta | entity_identity(fk) | products_idproduct(fk) | products_feeds_idfeed(fk) | value | 1 | 1 | 1 | 1 | first product first val | 2 | 2 | 1 | 1 | first product second val| 3 | 1 | 2 | 1 | 2nd product first val | 4 | 2 | 2 | 1 | 2nd product second val | 5 | 1 | 3 | 1 | 3rd product first val | 6 | 2 | 3 | 1 | 3rd prod

view - Pass Data Through Navigation Controller With Back Button -

example: master detail application text view in detail controller. best way pass text view data master view when user presses button? you can create @property in masterview , pass data when leaving detailview . basically, can have @property in masterview : @property (strong, nonatomic) uitextview *textview; and, instance, if using storyboard go back. [self performseguewithidentifier:@"masterview"...] create instance of masterview masterview *master = [[masterview alloc] init]; and pass textview from detailview to @property created in masterview . master.textview = detailtextview;

Android monkey runner: Touch with MOVE -

i trying use monkeyrunner simulate complex touch events. swipe b with... device.drag((300,500),(300,650),0.5,50) works great complex movement b c doesn't work trying that device.touch(100,500, 'down') device.touch(300,500, 'move') device.touch(300,400, 'move') device.touch(300,400, 'up') was seaching solution , found this.. https://android-review.googlesource.com/#/c/50991/ is implemenet in offical android sdk? or did have compile or else , how works? i dont know think side official monkeyrunner source.. monkeydevice.java , 1 have "move" type on line 70. touchaction.java on same side @ line 28 have no "move" implemented. maybe that's reason why it's not working. can tell me how complex touch movement on android phone? yes, merged official sdk tools now. can use it. care delay between move , move. here link sample code you. have tested code on galaxy nexus.

image output in php with header('Content-Type: image/png'); -

i'm using code uotput image not getting error not display image too... // test image. $fn = '/itunes.png'; // getting headers sent client. $headers = apache_request_headers(); // checking if client validating cache , if current. if (isset($headers['if-modified-since']) && (strtotime($headers['if-modified-since']) == filemtime($fn))) { // client's cache current, respond '304 not modified'. header('last-modified: '.gmdate('d, d m y h:i:s', filemtime($fn)).' gmt', true, 304); } else { // image not cached or cache outdated, respond '200 ok' , output image. header('last-modified: '.gmdate('d, d m y h:i:s', filemtime($fn)).' gmt', true, 200); header('content-length: '.filesize($fn)); header('content-type: image/png'); echo file_get_contents($fn); } can help?

ember.js - How to update/edit record in emberjs? -

i have collected data fixture , displayed in form of table. also,i have added 2 column 1 edit delete want edit specific row. on click of edit have populated data on modal window 1 update button , want update changes on click of update. here code : store : grid.store = ds.store.extend({adapter: 'ds.fixtureadapter'}); router: grid.router.map(function () { this.resource('mainview', { path: '/' }); }); grid.mainviewroute = ember.route.extend({ model: function () { return grid.modalmodel.find(); } }); model : grid.modalmodel = ds.model.extend({ fname: ds.attr('string'), lname: ds.attr('string'), email: ds.attr('string'), contactno: ds.attr('string'), gendertype: ds.attr('boolean'), contactype: ds.attr('number') }); grid.modalmodel.fixtures = [ {

cordova - Is it possible to customize the "Done" Button and bar position of the InAppBrowser? -

i have application open external url inappbrowser plugin, want change position of bar done button appear… is possible customize "done" button of inappbrowser? yes can customize ... ios only. closebuttoncaption - set string caption "done" button. note have localize value yourself. toolbar - set 'yes' or 'no' turn toolbar on or off inappbrowser (defaults 'yes') but here can not change position of status bar , done button.

java - HIbernate update with null on onetomany relation -

i have following tables : product (id_product, name) property (id_property, name) product_properties (id_product, id_property) (all fields not nullable) and following hibernate mapping : class product { @id private integer id; @onetomany(mappedby="product") @cascade({cascadetype.all}) private set<productproperties> productproperties = new hashset<productproperties)(0); (...) } when update product class adding or removing rows "productproperties" field, rows updated correctly in product_properties table. the problem when "productproperties" null or empty, hibernate throws constraintviolationexception. since need "productproperties" empty sometimes, there proper solution problem (something @zerotomany annotation) ? the answer given dev blanked in comments. solution : @onetomany(mappedby="foo", orphanremoval=true)

drawing - How do I draw a line on a Lazarus form? -

Image
i use tpanel or tgroupbox group form controls. now need draw straight line border of panel or groupbox. how do on lazarus? thanks in advance! note: technique must work on both linux , windows as optical line separator should use either tbevel component shape property set 1 of following values bstopline , bsbottomline , bsleftline or bsrightline depending on line need , resize smaller size (in case can use bstopline or bsbottomline , resize bevel vertically): or can use special component called tdividerbevel except single line adds optical divider caption:

java - How to run different methods parallely -

i have 1 java method contains 5 different internal methods. performance improvement, want call these methods parallely. e.g. run method1, method2, ... method5 parallel using thread. private void getinformation() throws sqlexception, classnotfoundexception, namingexception { method1(); method2(); method3(); method4(); method5(); } but these 5 methods have different business logic. do this: for each method, create callable object wraps method. create executor (a fixed thread pool executor should fine). put callables in list , invoke them executor iterate on each future returned executor, wait thread complete, , results. here's simple example: public void testthread() { //create callable each method callable<void> callable1 = new callable<void>() { @override public void call() throws exception { method1(); return null; } }; callable<void> callable2

Why does the AVL tree in Map of OCaml use balance factor (height diff) 2 instead of 1? -

according avl tree wiki the balance factor calculated follows: balancefactor = height(left-subtree) - height(right-subtree). each node checked, if balance factor remains −1, 0, or +1 no rotations necessary. however, in ocaml, seems uses balance factor of 2 let bal l x d r = let hl = match l empty -> 0 | node(_,_,_,_,h) -> h in let hr = match r empty -> 0 | node(_,_,_,_,h) -> h in if hl > hr + 2 begin match l empty -> invalid_arg "map.bal" | node(ll, lv, ld, lr, _) -> if height ll >= height lr create ll lv ld (create lr x d r) else begin match lr empty -> invalid_arg "map.bal" | node(lrl, lrv, lrd, lrr, _)-> create (create ll lv ld lrl) lrv lrd (create lrr x d r) end end else if hr > hl + 2 begin match r empty -> invalid_arg "map.bal&q

c - In which cases do we use heapsort? -

in cases heap sort can used? know, heap sort has complexity of n× lg (n) . it's used far less quick , merge sort. when use heap sort , drawbacks? based on wikipedia article sorting algorithms , appears heapsort , mergesort have identical time complexity o(n log n) best, average , worst case. quicksort has disadvantage there worst case time complexity of o(n 2 ) (a) . mergesort has disadvantage memory complexity o(n) whereas heapsort o(1) . on other hand, mergesort stable sort , heapsort not. so, based on that, choose heapsort in preference mergesort if didn't care stability of sort, minimise memory usage. if stability required, choose mergesort. or, more correctly, if had huge amounts of data sort, , had code own algorithms it, i'd that. vast majority of cases, difference between 2 irrelevant, until data sets massive. in fact, i've used bubble sort in real production environments no other sort provided, because: it's incredibly easy w

javascript - Regex to find pattern, return subpattern -

var s = "lala url(ok) tee hee url( oh ya ) kk"; s.match( /url(([^)]+))/g ); from 's' trying extract: ['ok', ' oh ya '] but, getting: ["url(ok", "url( oh ya "] i can iterate on list , remove 'url(', suspect regex-fu can remove too. in other language regex support lookbehind using regex (?<=url\()(([^)]+)) but unfortunately javascript regex doesn't support lookbehind this example , must iterate it. except don't realy need url word included.

Android UIAutomator how to tilt device -

is there anyway perform tilt action using uiautomator android? looked @ uiautomatorapi unable find direct method. there methods change device orientation. assume want. try: getuidevice().setorientationright(); getuidevice().setorientationleft(); getuidevice().setorientationnatural(); for more details on how use them can access link: auiautomator uidevice

php - Change att of the video to its corresponding item when you press the enter key -

i have application podcasts , accurate when press "enter" change attribute of corresponding item of video, can not reload page, change video. know how do? javascript: $.getjson("http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3d'http%3a%2f%2frss.cnn.com%2fservices%2fpodcasting%2fac360%2frss.xml'%20and%20itempath%3d%22%2f%2fchannel%22&format=json&diagnostics=true&callback=?", function (data) { // load titles patch json console.log(data.query.results.channel.item); var titles = data.query.results.channel.item.map(function (item) { return item.title; }); var urls = data.query.results.channel.item.map(function (item) { return item.origlink; }); console.log(titles); $(".container-list-podcast ul").append('<li>' + titles.join('</li><li>')); $(".container-list-podcast ul li").each(function (key, value) {

mysql - PHP post two values in one field, one of which is hidden -

is there way can post 2 values @ same time single field in table hide 1 user? i following form post values id , reason_name when submitted have user able see (and edit in text box) reason_name . <form name="add_positioning" method="post" action="<?php echo $_server['php_self']; ?>"> <table border="1" class="autotable_pos"> <tr> <td>positioning</td><td> </td></tr> <? $sql= "select * gradereason reason_userid = $user_id , category = 'positioning' , current = 1"; $result = mysqli_query($mysqli,$sql) or die(mysqli_error($mysqli)); while($row = mysqli_fetch_array($result)){?> <tr> <td> <input type="text" name="reason[]" size="25" value="<? echo $row['reason_name']; ?>"/> <