Posts

Showing posts from January, 2011

javascript - What is the best way to check for XHR2 file upload support? -

if xhr2 supported file-upload capabilites, application needs different preparation. safe way check if these capabilities supported. sufficient, example, check xmlhttprequest (or ms equivalents) upload property? like... var xhr = new xmlhttprequest(); if (typeof xhr.upload !== "undefined") { nice stuff } else { oldschool stuff } or not safe? if (new xmlhttprequest().upload) { // welcome home! } else { // not supported }

SVN checkout issue -

i have project locally had 3 files, .h, .m , .xib. i deleted them , created new ones. commited usual svn repo, , files dont show in commit options. but when checking out project, 3 files in red, if have been deleted. i cant seem overwrite them or replace them. how issue solved? thanks a commit required after delete before add new files.

javascript - Set a timeout limit for Google Maps, and how to test it? -

is out there using timeout on google maps api? have google map gets loaded fusion table. client wants me resort different solution if maps doesn't load in x seconds. i tried using javascript timeout function , $(document).ready, found jquery ready firing before map rendered screen. with said... 1 know way force timeout test of solutions available. thanks, andy could use tilesloaded event? code this: // set map , timeout var map = new google.maps.map(document.getelementbyid("map"), someoptions), timeoutseconds = 4, usingmap = false; function doalternatestuff() { // whatever fallback requires } // set timeout , store reference var timer = window.settimeout(doalternatestuff, timeoutseconds * 1000); // listen tilesloaded event google.maps.event.addlistener(map, 'tilesloaded', function() { // cancel timeout window.cleartimeout(timer); usingmap = true; // etc });

c# - Button (In silverlight) does not have Click property -

i need silverlight button call specific method, button doesn't have click property. intellisense shows "clickmode" no "click" i'm using system.windows.controls.button control here's code xaml file <usercontrol xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:telerik_windows_controls="clr-namespace:telerik.windows.controls;assembly=telerik.windows.controls.charting" x:class="..." mc:ignorable="d" d:designheight="300" d:designwidth="400"> <grid x:name="layoutroot" background="white"> <telerik_windows_controls:radchart name="radchart" content="radchart" mar...

Workaround for history animation in Safari for OS X Lion? -

in safari os x lion, when use swipe gesture navigate forward or backward in history, window animates though moving through physical pages. problem behavior many apps listen changes in history state, , respond appropriately -- either when hash changed, or when html5 pushstate used. a perfect example github, when navigating in , out of folders -- https://github.com/johndyer/mediaelement , example. if click on folder, swipe previous page, end state "snapshot" shown, , animated again beginning state, not confusing, nullifies informational value of animation. today first day using lion, i'm curious if other web devs have encountered issue, , whether you've found workaround? sadly seems there's no documentation in safari developer library . but there (ugly) workaround disable them on client machine @ least. in trackpad settings, if set swipe between pages swipe 2 or 3 fingers can use 2 fingers fancy animations, , 3 fingers if don't them. feel...

function - JavaScript: Distinguish between native and non-native member -

is there way detect whether given function, array.prototype.foreach , native function (e.g. browser implements ecmascript5) or function added page's javascript script(s)? you can try putting console , seeing comes there.

javascript - How do you get a JS DOM/JQuery Object for Form Tag in form_remote_tag's :complete callback? -

in rails 2.3.3, want like: <% form_remote_tag :url => "/some/path/", :loading => "loadingfunction(this)", :complete => "completefunction(this,request)" %> basically, want able pass specific form tag :complete or :loading callback functions (in relative way - don't want use id - want able tag :complete call corresponds natural result of :complete call being form tag**). see rails documentation form_remote_tag . in particular, rails generates code following onsubmit event: new ajax.request('/some/path/', {asynchronous:true, evalscripts:true, oncomplete:function(request){completefunction(this,request)}, onloading:function(request){loadingfunction(this)}, parameters:form.serialize(this)}); return false;" . note how function calls wrapped within function(request){} inside new ajax.request(). so, "this", "jquery(this)", "jquery(this).closest('.someparentelementoftheform')" etc....

events - Node.js code problem -

i new node.js. having few problems in code trying. take @ code: var http =require('http'); var url = require('url'); var events=require('events'); var e=new events.eventemitter(); var i=0; var clientlist=new array(); function user(nam,channel) { this.nam = nam; this.chan=channel; } server = http.createserver(function(req,res) { res.writehead(200,{'content-type':'text/html'}); res.write('welcome'); var pathname = url.parse(req.url).pathname; pathname=pathname.substring(1); pathnames=pathname.split("&"); var c=new user(pathnames[0],pathnames[1]); clientlist[i++]=c; console.log("user "+pathnames[0]+" joined channel "+pathnames[1]); e.emit('userjoined',clientlist[i-1].nam,clientlist[i-1].chan); e.on('userjoined',function(n,c) { res.write("new user joined name: "+n+" , joined channel "+c+"\n"); }); }); server.listen(2000); the problems having are: ...

c# - LINQ with multiple left join and where clause -

i have following query, , converting linq. select acq.acqpub prev_acqpub , ve.companyid , ve.entityid , ve.roundid , ve.entityname , ve.date , ve.roundtypecode , ve.eventtype , ve.postvalue_djvs , ve.postval , ve.preval , fin.financestat valuationevents_pit_new ve left join acq_publicdummy acq on ve.entityid = acq.entityid left join finstat_new fin on ve.entityid = fin.entityid ve.eventtype in('acq','lbo') , acq.acqpub null i wanted double check if i've done right or there better way of doing it. here code: return (from ve in valuationevents ve.eventtype == eventtypes.acq || ve.eventtype == eventtypes.lbo join acq in acqpublicdummies on ve.entityid equals acq.entityid veacq x in veacq.defaultifempty() x != null && x.acqpub == null join fin in fins...

startup - Start up script for node.js repl -

is there way configure node.js's repl? want require jquery , underscore automatically whenever repl starts. there file (noderc?) node.js loads when starts repl? the equivalent in python edit ~/.ipython/ipy_user_conf.py with: import_mod('sys os datetime re itertools functools') i don't know of such configuration file, if want have modules foo , bar available in repl, can create file myrepl.js containing: var myrepl = require("repl").start(); ["foo", "bar"].foreach(function(modname){ myrepl.context[modname] = require(modname); }); and when execute node myrepl.js repl modules available. armed knowledge can put #!/path/to/node @ top , make executable directly, or modify version of repl.js module (source available @ https://github.com/joyent/node/blob/master/lib/repl.js inspection) or whatever :)

php - How can I trim all strings in an Array? -

this question has answer here: how trim white spaces of array values in php 6 answers if have array: array(" hey ", "bla ", " test"); and want trim of them, how can that? the array after trim: array("hey", "bla", "test"); array_map() need: $result = array_map('trim', $source_array);

3d - Texture change (and other state-change) costs on modern GPUs -

i'm writing scene-graph based graphics engine modeling purposes. i'm using xna 4. on many places have been reading, texture changes (and other state changes) should minimized during rendering (so have order primitives materials, etc.). i created small test application in xna 4, rendering hundreds of stanford bunny models single texture, doing same toggling 2 different textures. there no difference in rendering time (however used small ~100x100 textures). so questions are: should care sorting primitives texture/color/other material parameters? or less important on modern gpus? what expectable percentage of performance loss, if don't? are there other state changes, can effect performance? where can find date literature/best practice guide this? thank or links! state changes haven't been expensive long time. batches expensive. (and state change necessitates new batch). batch call draw*primitives function. this pdf nvidia explains in detail....

Operating System, C and process memory allocation -

we global variables , static variables initialized 0. question is, why have separate sections in binary initialized , uninitialized data. i wrote following code - int i; int j=0; static int k; static int l=0; int main() { static int m=0; static int n; printf("%d, %d\n",i,j); printf("%d, %d\n",k,l); printf("%d, %d\n",m,n); return 0; } and output - 0, 0 0, 0 0, 0 i checked output of objdump of bss section , section contained variables. per link - http://www.cprogramming.com/tutorial/virtual_memory_and_heaps.html typically, in each process, virtual memory available process called address space. each process's address space typically organized in 6 sections illustrated in next picture: environment section - used store environment variables , command line arguments; stack, used store memory function arguments, return values, , automatic variables; heap (free store) used dynamic allocation, 2 data sec...

How to Import .bson file format on mongodb -

i've exported database on server using mongodump command , dump stored in .bson file. need import in local server using mongorestore command. it's not working. correct mongorestore command , other tools restore db ? it's simple import .bson file: mongorestore -d db_name -c collection_name path/file.bson incase single collection .try this: mongorestore --drop -d db_name -c collection_name path/file.bson for restoring complete folder exported mongodump : mongorestore -d db_name path/

authentication - using Ruby handsoap craft AuthHeader -

how go adding authheader soap header of request using handsoap? so example want: <soap:header> <authheader xmlns="thenamespace"> <userguid>xxxxxxxxxx</userguid> <userkey>yyyyyyyyy</userkey> </authheader> </soap:header> thanks in advance suggestions or direction - haven't been able track down in sample or documentation explaining how done.

download - PHP or javascript to verify a broadband connection (client Side) -

is there way use php script in website verify given visitor has broadband connection (some minimum downstream kbs ) before proceding render or elements of webpage? let's see... when client requests page #1, store timestamp in session. add javascript page #1, client start downloading large file (say, 5mb) page loaded, , request page #2 download has completed. should ajax, happens in background. now, page #2 compares current timestamp original timestamp stored in session. difference tell how long took client download large file. if you're satisfied speed, send more page elements via ajax again. but bad idea. not method require transferring unnecessary file (which can cost money mobile clients), it's extremely unreliable. latency (think "ping") between client , server, cpu usage on client side, congestion on wire, , myriad other factors affect download time. might send real content in time takes run speed test. in conclusion, there's no w...

algorithm - What's a good one-pass pseudo-random shuffle? -

the fisher-yates shuffle gives nice algorithm shuffle array a of length n in single pass: for k = 1 n pick random integer j k n swap a[k] , a[j] after single pass through algorithm, entries of a occur uniformly @ random. a common way botch algorithm following: for k = 1 n pick random integer j 1 n swap a[k] , a[j] the resulting distribution single pass through algorithm not uniformly random, , there nice discussion of @ post: what distribution broken random shuffle? i read delightful article diaconis, fulman , holmes entitled analysis of casino shelf shuffling machines authors describe physical machine following batch shuffle: for k = 1 n pick random integer j 1 10 randomly choose place card k on top or bottom of stack j the question authors address whether or not gives reasonably random ordering after single pass. answer decidedly not. 1 way see flaw in shuffle start deck of cards has n/2 red cards atop of n/2 black cards. resulting...

ms dos - Dos32 Extender help needed -

i want write c apis set/getirqhandler dos32 extender. document of dos32 not updated since long time. please can me out in writing c apis above mentioned functions. i found below information dos32 website. dpmi function 0204h - protected mode interrupt vector returns address of current protected mode interrupt handler specified interrupt. in: ax = 0204h bl = interrupt number out: cf clear cx:edx = selector:offset of exception handler notes: a) value returned in cx valid protected mode selector, not real mode segment address. b) client should use dpmi function 0202h obtain addresses of exception handlers, since interrupt , exception handler's addresses may different interrupts in range int 00-0fh. and **dpmi function 0205h - set protected mode interrupt vector sets address of protected mode handler specified interrupt interrupt vector. in: ax = 0205h bl = interrupt number cx:edx = selector:offset of exception handler out: if successf...

Javascript pastes the html into itself? -

ok, sounds kind of weird, here i'm dealing with. on website, when try load it, there nothing in body tags. when @ chrome developer console, stops after fetching stylesheet, inside ajax.js file of html goes inside body. contents of ajax.js file not contain body of html, why showing there? here shows up: :( cant post image html: <?php $_session['framestart'] = $_post['framestart']; $_session['framestop'] = $_post['framestop']; $_session['format'] = $_post['format']; $_session['currframe'] = $_post['framestart'] - 1; ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>openrender - free online rendering</title> <link rel="stylesheet" type="text/css" href="main....

iphone - How To Apply Warping Technique for UIImage? -

Image
currently working on image processing. found warping algorithm techniques. don't know apply techniques in uiimage. guys if u know show me correct route achieve. here equation found: you can perform affine transformations using cgaffinetransform .

sql server 2005 - Having a Login ID and a PersonID in SQL -

i creating application require user register , create account. should use person's login id (this email address) unique record identifier or should create personid (or rec_id). why should (or should not) create rec_id ? if use email address primary key in person table , foreign key in related tables, it hard implement change email feature - instead of single update, forced add new record person , update related records , delete record old email.

php - Recursive BBCode Parsing -

i'm trying parse bbcode in script. now, works seamelessly, until try indent bbcode that's more bold or underline - such spoiler, url, font size, etc. - screws up. here's code: function parse_bbcode($text) { global $db; $oldtext = $text; $bbcodes = $db->select('*', 'bbcodes'); foreach ($bbcodes $bbcode) { switch ($bbcode->type) { case 'simple': { $find = '{content}'; $replace = '${1}'; $text = preg_replace( '/\['.$bbcode->tag.'\](.+)\[\/'.$bbcode->tag.'\]/i', str_replace($find, $replace, $bbcode->html), $text); break; } case 'property': case 'options': { $find = array ( '{property}', '{content}' ); $replace = array ( '${1}',...

sql server 2008 - SQL top 1 within WITH statement -

i have sql query makes use of statement. query looks this: with topage ( select top 1 * ages order age ) select * topage agegroup = 1 my question whether where clause gets executed after top statement, because query retrieves no records whereas know there records in database should retrieved. thanks in advance help. the answer is: yes, agegroup = 1 predicate applied after selecting top 1 . query equivalent this select * ( select top 1 * ages order age ) agegroup = 1 what maybe want this select top 1 * ages agegroup = 1 order age

sql server - Apparently, Stored Procedure syntax is harder to understand than I anticipated -

so i'm trying replicate query stored procedure. use thisdb select firstname + ' ' + lastname fullname , sum(unitprice * quantity) 'total sales', year(orderdate) salesyear employees e join orders o on o.employeeid = e.employeeid join [order details] od on od.orderid = o.orderid group lastname +' ' +firstname, year(orderdate) order 'total sales' desc edit: noticed old query gonna fail, don't change /edit unfortunately, haven't found examples me translate know queries stored procedure syntax. here understand far: use thisdb; go create procedure empsalesbyyear @emp out begin set emp = (select employees.firstname, employees.lastname , totalsales = sum([order details].unitprice * [orderdetails].quantity), year(orders.orderdate) salesyear employees e join orders o on o.employeeid = e.employeeid ...

silverlight - Disable ConvertBack() on TwoWay binding when using UpdateSource() -

i maintaining silverlight app, , had resort manually rebind textboxes' text. so use: mytextbox.getbindingexpression(textbox.textproperty).updatesource(); problem is, textbox needs have twoway binding, set it. control uses unorthodox ivalueconverter, should never convertback, since got twoway binding... gets called. is there way disable convertback(), , yet let convert() job? thanks ;) you should use converter handle both directions... subclass existing converter , have convertback hide existing 1 (and return harmless) while convert calls base.convert.

Hot deployment of java web module with maven in weblogic 10.3 -

i tried search steps involved in hot deploying java web application in weblogic 10.3, couldn't succeed. can 1 me out in describing steps required hot deployment. using maven multi-module project(web module, .war file) eclipse. each time if changes there java files rebuilding entire project , redeploying test in web logic 10.3. also want under stand can find web-inf/classes (.class files) in weblogic directory? able see files except files under web-inf/classes in /servers/adminserver/tmp/_wl_user//war/... thanks santhosh

.net - StrechBlt doesnt work -

protected override void onpaint(painteventargs e) { win32helper.stretchblt(this.handle, 0, 0, 200, 300,bitmap.gethbitmap(), 0, 0, bitmap.width, bitmap.height, win32helper.ternaryrasteroperations.srccopy); this.creategraphics().drawrectangle(new pen(color.black), 0, 0, 100, 100); base.onpaint(e); } rectangle drawn.. bitmap isnt... have set picturebox1.image=bitmap , works bitmap isnt empty ... idea doing wrong ? in compact framework. i'm not sure "this.handle" is, might not handle dc. , suspect leaking resources each creation of pen , graphics object. (the garbage collector release eventually, it's not idea leave these handles lingering around). in case, rather thunking stretchblt, use graphics object image blit. protected override void onpaint(painteventargs e) { system.drawing.graphics g = e.graphics; // or call creategraphics function pen p = new pen(color.black); g.drawimage(bitmap, 0, 0, 200,...

generics - Java DAO factory dynamic returned object type -

i'm trying write simple dao create entity objects based on type stored in string field. how return type changed dynamicly? method findbyid() of userdao class should return user class object. same method productdao should return product. don't want implement findbyid in every class extends dao, should done automatically. example code: class dao { protected string entityclass = ""; public (???) findbyid(int id) { // db query return (???)entityfromdatabase; // how this? } } class userdao extends dao { protected string entityclass = "user"; } class productdao extends dao { protected string entityclass = "product"; } class user extends entity { public int id; public string name; } modify to class dao<t> { // protected string entityclass = ""; public t findbyid(int id) { return (t)entityfromdatabase; // how this? } } class userdao extends dao<user> { //protecte...

java - Android: how to use Rsync in own app? -

is there rsync api or other way use in own app, without direct user interaction? to use rsync need download binaries http://rsync.samba.org/download.html , read "how can put own native executable in android app?" http://gimite.net/en/index.php?run%20native%20executable%20in%20android%20app#hddd196e

Drawing hex tiles in Cocos2d for iOS -

i want draw hexagonal tile map. tmx files include more heavyweight hex grid need. don't need images black/transparent background hex outline on top. so far have this: cctmxtiledmap *map = [cctmxtiledmap tiledmapwithtmxfile:@"hexa-test.tmx"]; is there built-in routine or standard approach doing this? (i new cocos2d ios.) thanks as far i've seen in cocos2d, tilemap built-in way draw hex map. if want else, you'll have roll own -- don't think it's going difficult do. try this page info on basic hex drawing algorithm. there's this page draws many hexagons in map. hope helps. mike

sql server 2008 - Not contained in aggregate or having. . -

back query again. thought doing correctly subquery. . . use northwind select * ( select firstname + ' ' + lastname 'full name', sum(unitprice * quantity) 'total sales', year(orderdate) salesyear employees e join orders o on o.employeeid = e.employeeid join orderdetails od on od.orderid = o.orderid) subst group 'full name', salesyear order 'total sales' desc the error "invalid in select list because isn't contained in either aggregate function or group clause. had without subquery earlier , worked fine . . . the aggregate function (e.g. sum) , grouping have done @ same "level" of query: use northwind select 'full name',salesyear,sum(sale) 'total sales' ( select firstname + ' ' + lastname 'full name', unitprice * quantity sale, year(orderdate) salesyear employees e join orders o on o.employeeid = e.employeeid join orderdetails od on od.orderid = ...

java - how to get the id value From one mxml file to another mxml file in flex? -

my apllication in flex 3.5...my code here,how take id value of textare? button.mxml <mx:button width="20" height="20" label="textarea" id="textarea" click="setshape(drawobject.text);showtextarea()"/> my file here: main.mxml private function domousedown_canvas():void { if(this.shapestyle==drawobject.text) { if(isdrawing) { isdrawing = false; this.d = drawfactory.makedrawobject(this.shapestyle,segment, this.drawcolor, this.thickness, textarea.text); dispatchevent(new event(boardmediator.send_shape)); textarea.visible = false; }else { ...

java me - J2ME LWUIT Menubar three Softbuttons and Style -

i'm using lwuit-current java me on nokia s40 phones. i'd imitate style as possible default look. i discovered, there's commandbehavior native gives default menubar , nice. 1.) i'm using three buttons , show them time - not 1 button + options button, possible? see http://img194.imageshack.us/img194/8877/menubarx.jpg i tried display.getinstance().setthirdsoftbutton(true); still have empty unused third button. the softbuttons added via form.addcommand(buttonname); 2.) native softbuttons layout gives me additional title program line + clock; see screenshot. can title removed or changed lwuit? thanks in advance. using native menus not work 3 softbutton mode since native menus forfeit control lwuit has on ui underlying os. 3 softbutton mode requires deep knowledge of ui , lwuit has no midp api communicate knowledge device. native title bar appearing in top of screen part of devices ui can no longer control. furthermore, lwuit's (and nokia...

google app engine - error-handlers on app.yaml -

how handle different error codes on app engine? in app.yaml file, have- error_handlers: - file: error/notfound.html - error_code: over_quota file: error/over_quota.html handlers: ..some handlers.. this doesn't seem work. if site doesn't have folder name foo , user looks http://mysite.com/foo , returns standard 404 error, not page specified on app.yaml. my static dir separate error dir. both error , static dirs inside project dir. missing? is there way show custom page rather custom response message? the 404 error handler page displayed if url fails match patterns in app.yaml. if app returning 404, it's app display error page want - there's no way tell framework display default error page instead.

toggle - jQuery Panels - Weird Content Effect -

i getting weird jquery effect on website building. http://www.real-visual.com/site/technology/ on page, in left panel, see 4 orange links. if click one, slides open content panel. then, if click different orange link, slides closed first panel , slides open second one. however, notice weird effect where, when slide sliding closed, content inside changes. here example of jquery code powers these slides: $("#panel-2-button").click(function() { if ($('.togglepanel').is(':visible')) { $(".togglepanel").hide("slide", { direction: "left" }, 1000); } $("#content-inner-panel-2").toggle("slide", { direction: "left" }, 1000); }); $("#panel-2-button-medium").click(function() { if ($('.togglepanel').is(':visible')) { $(".togglepanel").hide("slide", { direction: "left" }, 1000); } $("#content-inner-panel-2-medium").t...

iphone - ASCII eqivalent of the symbol ampersand (&) in Obj C -

i sending emails iphone app calling web service , in email body need send url contains ampersand symbol (&). if use symbol in url web service not send email, if remove ampersand symbol works , webservice sends email fine. question is, should use ascii eqivalent of symbol ? , if so, ascii eqivalent '&'? can 1 me? this url has ampersand symbol http://xx.xxx.1.xx/xxx/aspxapprvcontrct.aspx?partyemail=xx@xxxx.com&devid= 1xx23 thanks in advance. you need escape whole string (email body) sending webservice. question has been asked before on so, see link included below. got link @caleb included, in , of not solve particular problem. recommend looking @ second answer posted @michael waterfall. objective c html escape/unescape

wpf - C# toggle visibility in Grid - slow speed -

i'm creating interactive slideshow control in wpf/c#. i've want create similar lightbox , coverflow. i'm using fading effect: http://www.codeproject.com/articles/57175/wpf-how-to-animate-visibility-property/?display=mobile and code testing coverflow: http://d3dal3.blogspot.com/2009/04/wpf-cover-flow-tutorial-part-7.html everything works ok if don't many covers in coverflow... if there more 5 takes > 3 - 4 seconds start fading animation (animation ok). when fade out layer , again fade in working perfectly, how ever when restart app , want fade in element need wait animation more 3, 4 seconds. seems wpf need render(?) collapsed element , animation starts... how can fix problem? here code window: <window> <grid> . . . . other content <border x:name="panelloading" visibility="collapsed" common:visibilityanimation.animationtype="fade"> <grid> <border background="black" o...

c# - Sockets receive hangs -

i trying download, search page of bing, , ask using sockets, have decided use sockets, instead of webclient. the socket.receive(); hangs after few loops in case of bing, yahoo, google works ask. google loop receive 4 - 5 times, freeze on call. i not able figure out why? public string get(string url) { uri requesteduri = new uri(url); string fulladdress = requesteduri.host; iphostentry entry = dns.gethostentry(fulladdress); stringbuilder sb = new stringbuilder(); try { using (socket socket = new socket(addressfamily.internetwork, sockettype.stream, protocoltype.ip)) { socket.connect(entry.addresslist[0], 80); networkstream ns = new networkstream(socket); string part_request = string.empty; string build_request = string.empty; if (jar.count != 0) { part_request = "get {0} http/1.1\r\nhost: {1} \r\nuser-agent: mozilla/5.0 (windows; u; windows n...

Ocaml libraries for mp3 editing? -

in ocaml , there library manipulate mp3 files editing (for ex. splitting, blank detection)? yes, see things should have been easier in other languages. as stéphane gimenez mentioned, ocaml-lame liquidsoap project looking for.

xml - php simplexml get maximum value -

how possible highest existing guid value existing xml file (simplexml). xml-structure example: <xml blabla> <blog name=""> <post> <guid>3</guid> <author></author> <content>...</content> </post> <post> <guid>1</guid> <author></author> <content>...</content> </post> </blog> i tried following ($xml simplexml object) max($xml->xpath(/blog/post/guid)); seems no array... any suggestions? there way handle per xpath? google search wasn't successful. you use array_map('intval'... feed max() "understands". <?php $xml = getdoc(); $ns = $xml->xpath('//blog/post/guid'); $ns = array_map('intval', $ns); echo max($ns); function getdoc() { return new simplexmlelement( <<< eox <xml> <blog name=""> <post> <guid>3</guid> ...

javascript - CSS Jquery vertical navigation menu with horizontal submenus -

i'd create navigation menu this: |main-item1| |main-item2| |sub-item1| |sub-item2| |sub-item3| |main-item3| |main-item4| what see this: |main-item1| |main-item2| |sub-item1| |sub-item2| |sub-item3| |main-item3| |main-item4| i've found question here on stackoverflow, couldn't manage adapt code. the html code have this: <div> <nav> <ul id="mainmenu"> <li><a href="chi_siamo">chi siamo</a></li> <li><a href="servizi">servizi</a> <ul class="submenu"> <li> <a href="speciale">speciale</a> </li> <li> <a href="#">privati</a> </li> <li> ...

jquery - function is not defined when using $.mobile.changepage -

i want execute initialize() function on page load, simple <body onload="initialize()"> didn't work when page called other page using $.mobile.changepage . i've tried this, works fine when type url of page directly in browser, not redirecting. firebug: initialize not defined <body> <div data-role="page" id="page" data-theme="c" class="sss"> <div data-role="header"> <h1>skopje info guide</h1> </div> <div data-role="content"> <div id="map_canvas" style="width:100%; height:400px;"></div> </div> <div data-role="footer"> <h1>test</h1> </div><!-- /footer --> <script type="text/javascript"> $('.sss').live('pageshow', function (event, ui) { poptable(); initialize(); ...

c++ - Reading in HEX number from file -

this has me pretty bothered should able when read in hex number , assign unsigned int when print out different number. advice great. thanks #include <iostream> #include <fstream> #include <string> using namespace std; int main() { fstream myfile; myfile.open("test.text"); unsigned int tester; string test; myfile >> hex >> tester; cout << tester; system("pause"); return 0; } i bet don't "different number". i bet same value, in decimal representation. you're extracting hex-representation value ( myfile >> hex >> tester ); insert one, ( cout << hex << tester )!

c# - Storing a property of the type specified in a string -

there's xml scheme says this: <extrafields> <extrafield type="int"> <key>mileage</key> <value>500000 </value> </extrafield> <extrafield type="string"> <key>carmodel</key> <value>bmw</value> </extrafield> <extrafield type="bool"> <key>hasabs</key> <value>true</value> </extrafield> </extrafields> i want store info in class , want field of specified type. thought of generic approach static class consts { public const string int32type = "int32"; public const string stringtype = "string"; public const string booltype = "bool"; } public class extrafieldvalue<tvalue> { public string key; public tvalue value;public static extrafieldvalue<tvalue> createextrafield(string strtype, string strvalue, string strkey) { idictiona...

android - Get spinner value when button click -

is possible return spinner selected value when click in button in same activity, instead of using onitemselected() method? yes. have several options value. of these are: spinner.getselecteditem() spinner.getselecteditemid() spinner.getselecteditemposition() just take @ this link see different methods can call on spinner.

Watch Window in Visual Studio -

is there way specify members of object see in watch window without expanding tree properties. example: p = new point(10 ,10) display on value column in watch : {x = 10 y = 10} . for own classes displays : {mynamespace.myclass} or {mynamespace.mystruct} . could change in order display : { mystringproperty = "" myintproperty = 0 ... } ? see using debuggerdisplay attribute if have marked class attribute: [debuggerdisplay("x = {x} y = {y}")] public class myclass { public int x { get; private set; } public int y { get; private set; } } output appearing in value column of watch window following: x = 5 y = 18

Filtering a List using LINQ -

hello have class called empowercalendarcode: it has following fields calendarcode, calendarname, effectivestartdate, empowertaxtype, longagencycode, taxdepositfrequencybasetypeid. i want filter list based on longagenycode , empowertaxtype. lets say: public ilist<empowercalendarcode> getempowercalendarcodes(string longagencycode, string empowertaxtype) { //todo: } if more 1 empowercalendarcode same longagencycode, empowertaxtype has same taxdepositfrequencybasetypeid , should pick 1 has recent effectivestartdate. how ould able write linq query. okay if have 2 3 queries result. any ideas , suggestions appreciated! try this: ctx.empowercalendarcodes .where(a=>a.longagencycode == longagencycode && a.empowertaxtype == empowertaxtype) .orderbydescending(a=>a.effectivestartdate) .firstordefault();

jquery - what is return type of window.open() in Javascript -

i writing code download pdf file using window.open() . passing url path of pdf file on server. window.open(url, name, "width=910,height=750,scrollbars=yes"); i want check if downloading of file successful or not. return type of window.open() ? i tried try { window.open(url, name, "width=910,height=750,scrollbars=yes"); alert("success"); } catch(e) { alert("failer"); } when change url wrong url, shows same result success. http://www.javascripter.net/faq/openinga.htm the return value reference new window. can use reference later, example, close window (winref.close()), give focus window (winref.focus()) or perform other window manipulations.

jsp - How to track user session in struts 2 -

i using struts 2 mysql. using jsp presentation.in application have 3 users , admin,tester,ba .for example if admin user logged in show him adminindex.jsp page, have done coding in action class return corresponding userindex pages.what want show logged in user in adminindex.jsp , need implement logout functionality. kindly guide or provide me tutorial links. the user should logged out after few minutes if there no activity. thanks in advance the auto-logout comes free. session has timeout. if user idles long, session terminated automatically. default value tomcat 30 min. also see here: what default session timeout java ee website? if need implement further logout functionality, kill users session calling: request.getsession().invalidate(); maybe build our own logout.action in struts2. cheers, mana

How Lucene reduces CPU usage over full-text search of sql server? -

i had read article how stackoverflow reduced cpu usage using lucene. but question how ? is due caching of lucene ? and if yes. if implement sqlserver fts memcache. same lucene ? or lucene uses different data structures search ? lucene using indexing , full text search - it's more caching. sql set-based relational language. it's not built ad hoc queries of documents. technology different.

iPhone - MPMusicPlayerController - Is there any limit on number of songs to select -

i created own music player runs on iphone using class mpmusicplayercontroller . i'm using class mpmediapickercontroller select songs , add player. i've around 900 songs in iphone. when i'm adding songs selecting "add songs" mpmediapickercontroller , app crashing. can 1 tell me whether there solution stop crash? or there limit on number of songs selection i've impose app won't crash? no, there no limit on selection of songs.

objective c - How to use .NET web service in iPhone, with POST method? -

i communicating .net web service in iphone application, using post method, not getting xml response. here code: nsurl *url = [nsurl urlwithstring:[nsstring stringwithformat:@"myserver/eventservice.svc"]]; nsstring *api = @"/registeruser"; nsdata *body = [[nsstring stringwithformat:@"%@/%@/%@/%@/%@/%@/%@/%@/%@", api, txtfname.text ,txtlname.text, txtuname.text, txtemail.text, txtpassword.text, txtcity.text, txtstate.text, str] datausingencoding:nsasciistringencoding allowlossyconversion:yes]; nslog(@"url %@",url); nslog(@"body %@",[nsstring stringwithformat:@"%@/%@/%@/%@/%@/%@/%@/%@/%@", api, txtfname.text, txtlname.text, txtuname.text, txtemail.text, txtpassword.text, txtcity.text, txtstate.text, str]); nsmutableurlrequest *request = [[[nsmutableurlrequest alloc] init] autorelease]; [request seturl:url]; [request sethttpbody:body]; [request setvalue:@"text/xml" forhttpheaderfield:@...

c++ - cvCreateFileCapture() -

in learning opencv book, following mentioned statement: cvcapture* capture = cvcreatefilecapture(argv[1]); the function cvcreatefilecapture() takes argument name of avi file loaded , returns pointer cvcapture structure. can explain sentence: "then returns pointer cvcapture structure"? it allocates new cvcapture structure , returns pointer structure. don't access fields of structure pass pointer other functions work on file capture, cvqueryframe or cvsetcaptureproperty . , don't forget free resources cvreleasecapture when you're done file. this shouldn't hard understand basic c-knowledge, respect many opencv function work way. by way, question tagged c++, consider using c++-interface of opencv, abstracts many of things away. although there no real book it, c-interface.

sql server - SQL performance on LEFT OUTER JOIN vs NOT EXISTS -

if want find set of entries in table not in table b, can use either left outer join or not exists. i've heard sql server geared towards ansi , in case left outer joins far more efficient not exists. ansi join perform better in case? , join operators more efficient not exists in general on sql server? joe's link starting point. quassnoi covers too. in general, if fields indexed, or if expect filter out more records (i.e. have lots of rows exist in subquery) not exists perform better. exists , not exists both short circuit - record matches criteria it's either included or filtered out , optimizer moves on next record. left join join all records regardless of whether match or not, filter out non-matching records. if tables large and/or have multiple join criteria, can very resource intensive. i try use not exists , exists possible. sql server, in , not in semantically equivalent , may easier write. these among operators find in sql server g...

java - Http Post With Body -

i have sent method in objective-c of sending http post , in body put string: nsstring *requestbody = [nsstring stringwithformat:@"mystring"]; nsmutableurlrequest *request = [nsmutableurlrequest requestwithurl:url]; [request sethttpmethod:@"post"]; [request sethttpbody:[requestbody datausingencoding:nsutf8stringencoding]]; now in android want same thing , looking way set body of http post. you use snippet - httpurlconnection urlconn; url murl = new url(url); urlconn = (httpurlconnection) murl.openconnection(); ... //query body urlconn.addrequestproperty("content-type", "application/" + "post"); if (query != null) { urlconn.setrequestproperty("content-length", integer.tostring(query.length())); urlconn.getoutputstream().write(query.getbytes("utf8")); }

c - Sending broadcast in Linux via Sockets -

solved please close question (but not know how :/ bad day) im trying send broadcast in linux via sockets, going out through both interfaces(ive got active eth0 , eth1, both in different segments), suddelny, going out through first one, eth0 here code: void sendbroad(char *dstip, char *localip) { int sock; /* socket */ struct sockaddr_in broadcastaddr; /* broadcast address */ int broadcastpermission; /* socket opt set permission broadcast */ unsigned int localiplen; /* length of string broadcast */ /* create socket sending/receiving datagrams */ if ((sock = socket(pf_inet, sock_dgram, ipproto_udp)) < 0) perror("socket() failed"); /* set socket allow broadcast */ broadcastpermission = 1; if (setsockopt(sock, sol_socket, so_broadcast, (void *) &broadcastpermission, sizeof(broadcastpermission)) < 0) perror("setsockopt() failed"); /* construc...

SQL/PHP: Counting average male/females -

$sql = $connect->prepare("select e.id, u.sex discos_events e inner join discos_events_guests eg on (e.id = eg.eid) inner join users u on (eg.uid = u.id) e.did =:id"); $sql->bindvalue(":id", $cid); $sql->execute(); $total = $sql->rowcount(); $male = 0; $female = 0; while($sex = $sql->fetch()){ if($sex["sex"] == "male"){ $male++; }else{ $female++; } } $averagemales = $male/$total; $averagefemales = $female/$total; can done simpler? if not, not work properly, if there's 2 males , 0 females, $averagemales return 1 , $averagefemales return 0. i want return in procentages, e.g 100% when theres not females, , females 0%. no need use separate queries: select count(males.id) / (count(males.id) + count(females.id)) * 100 male_percentage discos_events join discos_events_guests on discos_events_guests.eid = discos_events.id left join users males on males.sex = 'male' , males.id = dis...

objective c - Deleteing more than one file from iphone documents folder? -

my iphone application saving photos document folder. want delete these file form document folder after use. know how delete 1 file @ time using path if ([filemgr removeitematpath:filepath error:&error] != yes) nslog(@"unable delete file: %@", [error localizeddescription]); but want delete file in 1 go. files in .png format tried out *.png not working. /* dir: directory files */ nsfilemanager *fm = [nsfilemanager defaultmanager]; nserror *error = nil; nsarray *items = [fm contentsofdirectoryatpath:dir error:&error]; if (error) { /* ... */ } /* delete png files */ (nsstring *item in items) { if ([[item pathextension] isequaltostring:@"png"]) { nsstring *path = [dir stringbyappendingpathcomponent:item]; [fm removeitematpath:path error:&error]; if (error) { /* ... */ } } }

I cant import a flash builder 4.0 project into flash builder 4.5 -

we have flex app , correspoding swc project works great in flash builder 4.0, , have imported bunch of times fresh installation no problem. however, there doesnt seem way import or run in fb 4.5. first, projects checked out into: c:\dev\flash_ws\apitester (this flex project) c:\dev\flash_ws\flashapi (this bunch of actionscript , swc project). now in fb4.5, hit file->import flash builder project, chose c:\dev\flash_ws\apitester , picks .actionscriptproperties or similar , loads project. imports half project - has lost flashapi part. if same thing in fb4.0, picks flashapi library project too. the second problem, fb4.5 has no option import existing library project, or link it. if go project->properties->library path, neither "add project" "add swc folder" nor "add swc" take directory c:\dev\flash_ws\flashapi contains source want able edit , use. i notice in source path this: ${documents}\flashapi\src so did remember d...

HttpWebRequest limitation? -

i created com object makes query website. it's works perfectly, when use com object many threads (50 example), many timeout errors, , changed httpwebrequest timeout 45 seconds. how possible? is there limitation in method? how can solve problem? thanks! since don't have code, not tell happened. assumptions: firstly, maxed out default limit number of connections per application web host. default, number 2. can increase looking @ this document secondly, connections not terminated after transmitted data. can verify http connections typing netstat -n if you're on windows. connections have same destination ip (should be). if case, need close httpwebresponse.getreponsestream() . terminate http connection quickly.

include and require functions in PHP are not adding contents but not erroring out -

i'mu using codeigniter framework , have include_once('filename'); @ beginning of function. in stepping through code in debug mode caller function evaluates filename properly. can steps through file line line i'm attempting include. variables show i'm in included file properly, , exit out of include file , caller function has include_once() call, data gone , variables set in 'filename' uninitialized. possibly causing type of behavior? maybe (i.e., surely) problem that, said, you're including file inside function. so, variables exist inside scope of function, , not outside of it. you either declare variables global (which frowned upon), or better have function return values need variables of included file. learn more on php variable scopes

asp.net mvc - MVC cold startup not connecting -

notice how not connecting rather being slow. this has been difficult reproduce, yet happen consistently , went far move application on fresh machine thinking hardware related alas, new machine - same issue. some captures fiddler seems indicate connection never completed. any suggestions on further investigative measures? apologies in advance vagueness of question, @ loss. can instrument iis side? request tracing tell if taking long request times out before returns . . .

c# - Using same specification for code and NHibernate QueryOver<T> -

scenario i'm working on application has little section dedicated displaying statistics current state of system. includes such things how many items overdue, count of pending items, count of items without filters. when user opens application must select item labels wish work on before seeing items in ui. once done database gets queried , returns list user. each item has associated label. item label auto-generated before users see it. 1 of these labels "overdue", indicates user should completed first. problem i'm struggling find way centralize logic determines if item overdue. the way simple create future nhibernate query , statistic counts in 1 database transaction. issue once retrieve items database (which assigned label, if item overdue system supposed override label). once data retrieved (after users select labels) parse tree , need check each item whether it's overdue or not. logic quite simple located in 2 places because 2 different parts of syste...