Posts

Showing posts from February, 2013

android - Producing optimised NDK code for multiple architectures? -

i have c code android lots of low-level number crunching. i'd know settings should use (e.g. android.mk , application.mk) files code produced run on current android devices takes advantage of optimisations specific chipsets. i'm looking default android.mk , application.mk settings use , want avoid having litter c code #ifdef branches. for example, i'm aware armv7 has floating point instructions , armv7 chips support neon instructions , default arm supports neither of these. possible set flags can build armv7 neon, armv7 without neon , default arm build? i'm know how latter 2 not 3. i'm cautious settings use assume current defaults safest settings , risks other options have. for gcc specific optimisation, i'm using following flags: local_cflags=-ffast-math -o3 -funroll-loops i've checked 3 of these speed code. there other common ones add? another tip have add "local_arm_mode := arm" android.mk enable speed on newer arm chips (although

Ruby on Rails Routes Issue -

i have controller called head_buses_controller.rb , in routes have mapped map.resources :head_buses this results in urls being http://domain.com/head_buses i have urls dash - instead of underscore _ . is possible have urls dashes go head_buses controller? cheers eef try use one: resources :head_buses, :as => 'head-buses'

mysql - SQL Query over identical table on multiple systems -

overview of application: have delphi application allows user run queries on mysql databases on different systems, using tadoquery component retrieve data. user can retrieve data identical tables on 2 different systems (e.g. table_xyz in database_abc on system1 , system 2) running 2 separate queries, , 2 sets of data written file , manually joined on pc form 1 report. question: possible select data identical table/database on different systems 1 query? i'm pretty confident isn't possible due limitation of tadoquery's connection string having point single system, want make sure correct. i know it's possible retrieve data 2 identical tables in 2 different databases on same system using union statement, e.g.: select * database1.table_xyz union select * database2.table_xyz what need similar above example, retrieving data databases on different systems. basically, possible somehow incorporate connection string in sql statement, or connect in different way somehow

android - Get Current System Time -

how current system's time , date without using calender.getinstance() ? try date d = new date(); charsequence s = dateformat.format("eeee, mmmm d, yyyy ", d.gettime()); you can edit format string like..

multithreading - How to find which thread currently owns the lock in java -

i have synchronized method in singleton class called many threads simultaneously. there java api available check thread owning lock ? you perhaps print out thread.currentthread() in synchronized method.

.net - Create Setup, which installs Microsoft SQL Server 2005, if not installed (with Visual Studio 2008) -

i want create setup requires microsoft sql server 2005 , .net framework 3.5. if software isn't installed, setup should offer user install them now. i don't know if can include either of 2 in installation package itself. however, can tell setup app check if .net framework , sql server 2005 express edition installed. if not, download , install them , continue installation of application. of course, require internet connection. these options available when right-click on setup project, select properties, , click on prerequisites button. note paddy said, sql server 2005 different story.

Run web application on android -

i developed web service works on windows using vs2005 .can run on android mobile? you cannot run web service application created visual studio on android device. can consume individual web service android application if configured on server.

How does Webdriver / Selenium "talk" to your local web browser? -

for example firefoxdriver, how sending out clicks , commands firefox instance? it having webserver within webdriver addon firefox. language bindings rest-ish type call done, clicks, typing etc. you can see rest-ish interface here . call json wire protocol. have more native events via advanced user interactions api . more native clicks , typing, @ os level. each language binding takes care of dont need worry it.

Google App Engine: who is an admin? -

in app.yaml configuration file can required login: admin . question "what" or "who" admin? in app engine console in administration -> permissions section they're talking admin . however, if add new user can choose between owner , developer , viewer . which of admin ? owner or owner + developer or three? when working users either on own apps domain or normal google users: owners can supported ui. only owners can make changes on permissions tab (invite, change role, remove). developers can except changes on permissions tab. viewers cannot change anything. everyone admin before feature went live owner. (this available since version 1.4.2) all 3 roles given admin status when application runs (i.e., users.is_current_user_admin() returns true).

c# - Get object associated with selected rows in DataGridView -

i have datagridview bound array of objects. list<node> nodes = getnodelist(); m_grid.datasource = nodes; i handle selectionchanged event. in handler selectionchanged event want access selected objects. all seem able access value each cell in grid rather overall object associated row. void onselectionchanged( object sender, eventargs e ) { foreach ( dataviewgridrow row in m_grid.selectedrows ) { /* here want able access node object associated row*/ } } i'm sure must possible can't figure out. row index , array seems bit hacky. try this... datagridviewselectedrowcollection rows = mydatagridview.selectedrows; foreach (datagridviewrow row in rows) { datarow myrow = (row.databounditem datarowview).row; // datarow }

php - How do late static bindings work in this scenario? -

the following code outputs 'x set in class a', how make output 'x set in class b' without changing class b? <?php class { public static $x = 'x set in class a'; public static function getx() { return self::$x; } } class b extends { public static $x = 'x set in class b'; } echo b::getx(); self always refers class, defined. looking "late static binding" (as suggest, dont use). static keyword within code block refers "actual" class, means: either called class ( xy::method() ), or class of called object ( $x->method() ). return static::$x; the static keyword @ property declaration has nothing to lsb. common declartion class properties. note, lsb not available in php<5.3

CSS after pesudo class text decoration in link -

this question has answer here: “text-decoration” , “:after” pseudo-element, revisited 10 answers the goal of question create code adds filetype after link (so people know whether should expect special files). there options using image, don't , prefer have file type between square brackets in different size. approach use :after pseudoclass in following way a[href$='.doc']:after, a[href$='.rtf']:after { content: " [doc]"; font-family: monospace; font-size: 60%; font-weight:bolder; color:red; position:relative; top: -0.8em; } however, gets me strange problem. content seems in block part of link. therefore link underlining continues after link under "[doc]". so question pretty straightforward: there way either in way or make sure can control under "[doc]" separately under link? try adding display: inlin

jquery - Dynamically position element -

i have following: http://jsfiddle.net/oshirowanen/2vqvd/ how dynamically position .dropdown element no matter .navigation placed on screen? edit 1: for example, whereever .navigation on screen, .dropdown's top left corner should directly below bottom left corner of .navigation making single element when .navigation clicked on. here go: http://jsfiddle.net/2vqvd/2/ btw, re-factored code changing both javascript , css.

smtp - How can I send a thanks email in asp.net? -

i have send email (if emails particular account automatic email saying "thanks sending"). how should in asp.net mvc 2? logic? consider using brilliant library mvcmailer you can use send text or html email, body define view. can use whatever model need , render emails specific data. it available nuget package easy install.

vbscript - VB Script - Undefined variable -

i'm getting 'variable undefined', i'm guessing has scope of variables in vbscript, knowledge limited this. i know loading of email addresses works , actual emailing because have checked these separately. i'm trying loop through list of email addresses , send log file each.. any additional information great! first, there var array @ top of file: dim emails() function getemailaddresses() dim objfso dim objconfigfile dim strline dim icounter const forreading = 1, forwriting = 2, forappending = 8 set objfso = createobject("scripting.filesystemobject") set objconfigfile = objfso.opentextfile("emailaddresses.config", forreading) icounter = 0 while not objconfigfile.atendofstream redim preserve emails(icounter) strline = trim(objconfigfile.readline) emails(icounter) = strline icounter = icounter + 1 loop objconfigfile.close end function function writetolo

delphi - IDL to Type Library -

is there way in delphi 7 generate tlb idl? or class/ interface definition? you can use idl2pas.bat batch file (check in location c:\program files\borland\delphi7\bin) or midl.exe application.

xml - WCF Array Serialization - REST -

i have rest web service returns structure containing array of more structures. return structure looks this: [datacontract] public class response { private responserecord[] m_record; [datamember] public int totalrecords { get; set; } [datamember] public responserecord[] record { { return m_record; } set { m_record = value; } } } the responserecord class this: [datacontract(name="record")] public class responserecord { [datamember(order = 0)] public string recordid { get; set; } /* many more objects */ } my web service returns xml this: <response> <totalrecords>1</totalrecords> <record> <responserecord> <recordid>1</recordid> ... many more objects ... </responserecord> </record> </response> what rid of "responserecord" hierarchal level, adds no new information. web service runs soap , xml, , (name="record") attribute did trick. not

.net - Display unicode chars in VB.NET -

i can't manage display unicode characters in vb.net. i'm doing in c#: string mystring = "\u03a3"; //upper case sigma (sum) but doesn't work in vb , can't find way make work. visual studio source files unicode enabled. in cases, can put unicode character want right in source. failing that, try chrw() function.

compiler construction - can I make/build VB6 (aka classic Visual Basic) exe file in incremental, fast manner? -

i not first 1 observe vb6 "run full compile" fast , nice (hence incremental, compile needed process) whereas make exe takes long time. way long, when have no choice test , troubleshoot behavior of executable , standalone process rather debug version running under ide process. so, there compiler option or other magic transition make fast, incremental mode compile changed modules , link them precompiled other stuff? or agonizingly slow make matter of slow linker rather module compiler? go project|properties... dialog. select compile tab. choose compile p-code. compiling native code involves 2 compiler passes , link pass. i'm not sure why seems slow unless you've never compiled large programs using other languages.

php - Getting A Specific Twitter Status -

i've been trying contents of specific status using status url e.g http://twitter.com/#!/jquery/status/36102693709680640 , username associated status. in case, @jquery is there way in php and/or jquery? the best way use twitter api . must perform http request on correct uri , data returned in xml format. you'll parse xml needed data. the twitter username under the screen_name tag.

c++ - mongoose web server helloworld program -

i came across embedded web server named mongoose , http://code.google.com/p/mongoose/ , read wiki great , searched sample hello world program couldn't find it... found example written in c++ windows , can 1 provide example c program run webserver.. it quite simple, first need implement call function: void *event_handler(enum mg_event event, struct mg_connection *conn) { const struct mg_request_info *request_info = mg_get_request_info(conn); static void* done = "done"; if (event == mg_new_request) { if (strcmp(request_info->uri, "/hello") == 0) { // handle c[renderer] request if(strcmp(request_info->request_method, "get") != 0) { // send error (we care http get) mg_printf(conn, "http/1.1 %d error (%s)\r\n\r\n%s", 500, "we care http get", "we care http get");

c# - Co Browsing using Silverlight -

i want implement silverlight based component co-browsing. can please me started? thanks okay, first things first. i'm going assume figured out how commands "admin" "client". if not true, let me know. second: outrageously difficult thing build third: here's start ;-) to use default sl4 webbrowser component, need run application out-of-browser elevated trust. should set first. in test app, added webbrowser component , subscribed loadcompleted event. in eventhandler can use like: void webbrowser1_loadcompleted(object sender, system.windows.navigation.navigationeventargs e) { //pseudo code event update clients onadminnavigated(e.uri); } clientside use like: void adminnavigated(mycustomnavigationeventargs e) { clientbrowser.navigate(e.uri); } hope helps.

web services - PHP SoapClient Generating Different Formatted SOAP Request -

so tring connect third party service , having issues in php. when try service request in webservice studio works fine , sent request looks this: <?xml version="1.0" encoding="utf-16"?> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <soap:body> <createuser xmlns="http://ws.example.com"> <arg0 xmlns="">test@test.com</arg0> <arg1 xmlns="">123</arg1> <arg2 xmlns="">1234</arg2> <arg3 xmlns="">1234567890abcdef</arg3> <arg4 xmlns="">test</arg4> <arg5 xmlns="">user</arg5> <arg6 xmlns="">02472</arg6> <arg7 xmlns=""

java - Marshaling object with StringBuffer attributes -

when marshaling object via jaxb stringbuffer attribute, attribute becomes blank. wrote small program demonstrate problem: import javax.xml.bind.jaxbcontext; import javax.xml.bind.marshaller; import javax.xml.bind.annotation.xmlelement; import javax.xml.bind.annotation.xmlrootelement; @xmlrootelement public class jaxbtest { private string valueone; private stringbuffer valuetwo; public static void main(string[] args) throws exception { jaxbtest object = new jaxbtest(); object.setvalueone("12345"); object.setvaluetwo(new stringbuffer("54321")); jaxbcontext context = jaxbcontext.newinstance(jaxbtest.class); marshaller marshaller = context.createmarshaller(); marshaller.marshal(object, system.out); } @xmlelement public string getvalueone() { return valueone; } public void setvalueone(string valueone) { this.valueone = valueone; } @xmlelement public s

javascript - Centering Google Map Dynamically -

i trying ajax call find out lat/lng dynamically center google map. running strange scope issues lat/lng found, can not put map. here url testing this: http://www.comehike.com/hikes/hike_carpool.php?hike_id=125 the map should appear towards bottom. somehow isn't. idea on might causing problem? i made typo. people commented , helped me.

java - JFreechart & Servlet: How to compute datapoint from mouse position -

i'm drawing within servlet scatterplot , serve browser. user can click somewhere on plot , want determine datapoint of scatter plot user has pointed. mouse click of user can determine on pixel of image has clicked, how can info coordinates on domain , range axis? i found tipps how it, uses chartpanel. serving directly browser use instance of jfreechar object. anybody has clue or example how it? thanks, dieter i think have found solution. solution need chart again, either have create new or save somehow. when have reference chart solution following: jfreechart chart = functionwhichretrievesthechart(); chartrenderinginfo info = new chartrenderinginfo(); // plot_size size if graph , has same size original drawn chart.createbufferedimage(plot_size, plot_size, info); graph, otherwise pixel position points somewhere else plotrenderinginfo plotinfo = info.getplotinfo(); xyplot plot = (xyplot)chart.getplot(); point p = new point(x,y); // x , y pixel positions // d

java - Single Frame image from Camera Preview Android -

i want able take snapshot of preview camera screen being displayed on surfaceview. know has onpreviewframe() method , returns byte array in yuv format have no idea how call onpreviewframe() method on it's own. i have used in conjunction camera.setpreviewcallback() continuous thing keeps generating image, need once on onclick() , pretty take photo without making preview window stop. ideas? for else similar problem solved using setoneshotpreviewcallback() method on camera object give me byte[] information image. can used create yuv , compressed bitmap or whatever need.

scripting - How would i parse a multiline stdout string with a variable in bash script, i am getting error "unary operator expected" -

i have bash script: #!/bin/bash java_version="1.6.0_17" _stdout=`java -version` if [ $java_version = $_stdout ]; echo "matched" else echo "not matched" fi i result: java version "1.6.0_17" openjdk runtime environment (icedtea6 1.7.5) (rhel-1.16.b17.el5-x86_64) openjdk 64-bit server vm (build 14.0-b16, mixed mode) t4.sh: line 8: [: 1.6.0_17: unary operator expected not matched how match $java_version $_stdout when $_stdout has multiple lines use quotes. #!/bin/bash java_version="1.6.0_17" _stdout=`java -version` if [ "$java_version" = "$_stdout" ]; echo "matched" else echo "not matched" fi

linux - VMware virtual machines wont resume from the command line -

i'm running vmware workstation on ubuntu 10.10. have series of virtual machines clone every week. i've written bash script cycles through each of virtual machines, softly suspends it, clones it, , attempts resume it. the problem is, vm's not resume, have manually resume them. i'm trying figure out how can modify script i've written ensure vms resume. i've included script , sample of generated logfile showing error message. #!/bin/bash ##author: william cooper ##date: 2/15/2011 ## purpose: perform full backups of virtual machines ## running under vmware workstation ## script won't run if /nas directory doesn't exist ## /nas directory mounted buffalo terastation ## check /etc/fstab if mountpoint broken backupdest="/nas" ## no need modify host=`hostname` datefile=`/bin/date +%g%m%d` ## run command find list of vm names: ## name of vm, no path , no .vmx vmlist=`vmrun list | grep '/' | cut -d'/'

entity framework 4 - Linq to Entities: How to copy records from one table to another efficiently? -

we have event system organizes data date , time. copy data old event new event starter, modify it. this in linq: get source objects locally .tolist() for each item create new object copy non-primary key values new object , set new primary key add object table this generates tremendous amount of database calls. it's wrapped in transaction @ least. this statement in sql. way make linq efficient without embedding sql? insert targettable (eventid, two, three, 4 five) select @neweventid eventid, two, three, four, 5 targettable eventid = @eventid no can't make ef code more efficient. how ef works. if want efficiency wrap sql stored procedure, map stored procedure in ef designer , call sp. if can't create stored procedure execute sql directly. can use: objectcontext.executestorecommand(...) this method available in ef4.

windbg - Cannot download microsoft symbols when running cdb in a windows service -

i have .net windows service calling cdb.exe analyze crash dumps. want download symbols http://msdl.microsoft.com automatically when needed, using argument: -y srv*c:\symbols*http://msdl.microsoft.com/download/symbols if run application console application, works expected , downloads needed symbols each dump. the problem when start app windows service, symbols not downloaded and, if turn symnoisy on, @ cdb's output log have entry each symbol saying symbol hasn't been found @ http://msdl.microsoft.com so, i've checked using sniffer , funny thing no request made microsoft symbols server when running service. googling little, i've found i'm not 1 issue , seems problem when running application windows service, using winhttp library http requests, instead of wininet, think root of problem : http://support.microsoft.com/kb/238425 so, don't know why, cdb not able connect ms symbols server using winhttp library , need way force cdb use wininet defau

javascript - update existing option in select list -

let's have select list 3 options inside: <select> <option>1</option> <option>2</option> <option>3</option> </select> now, want update 1 of these options, create textfield & button. option appear inside textfield everytime press on 1 of options @ select list. can direct me need do? thanks adding first example had morning jsfiddle html: <select id='myselect'> <option value='1'>1</option> <option value='2'>2</option> <option value='3'>3</option> </select> <input type='text' value='1' name='mytext' id='mytext' /> <button value='add' id='addbtn' name='addbtn'>add</button> <button value='edit' id='editbtn' name='editbtn'>edit</button> <button value='delete' id='deletebtn' nam

webforms - Hide asp:panel used with a modalpopupextender on pageLoad -

i have several asp:panels on webform page used ajax modalpopupextender. on page load panels visible small fraction of time (depending on how fast page loads). what's quick , easy solution hiding these on page load, visible when modalpopupextender triggers them? i've experienced setting visible="false", has strange impact on other elements on webform. setting css display:none panel work, if somehow remove setting when modalpopupextender fires. setting style="display: none;" panel solved issue :)

Call outlook VBA from Excel -

i have function in outlook vba want call when excel workbook closed. there way beforeclose event of excel? know how write functions event, not sure how link them current outlook session function. ms office applications can interact each other method (this based on office 2007, others similar): add reference app excel in excel vba, tools\references menu select microsoft outlook 12.0 object library in beforeclose event include dim olapp outlook.application set olapp = new outlook.application you can access outlook through olapp object. don't know outlook object model, others may able more here on...

design patterns - Wrapping a COM object/dynamic type in C# -

i working com objects in managed code , using new dynamic type this. works in areas can issue in others. i think how best of both worlds, flexibility of dynamic type (late bound) support say, rcw (early bound) somehow wrapping dynamic type in more manageable stucture. wondering if there preferred method (if idea) or things should consider. the 2 basic ideas came far follows: firstly, creating static class allows me call methods of dynamic type in managed way. public static class comobjectwrapper { public static void somemethod(dynamic comobject, int x) { comobject.somemethod(x); } public static bool getsomeprop(dynamic comobject) { comobject.getsomeprop(); } public static void setsomeprop(dynamic comobject, bool foo) { comobject.setsomeprop(foo); } } secondly, creating class constructed using com object, mapping members managed properties, methods, etc. public class comobjectwrapper { private dynamic comobject = null;

multithreading - Dealing with deadlocks in long-running Hibernate transactions -

i have hibernate application may produce concurrent inserts , updates (via session.saveorupdate ) records same primary key, assigned . these transactions long-running, perhaps 15 seconds on average (since data collected remote sources , persisted comes in). db isolation level set read committed, , i'm using mysql , innodb. the problem scenario creates excessive lock waits timeout, either result of deadlock or long transactions. leads me few questions: does database engine release locks when transaction committed? if case, should seek shorten transactions? if so, practice use separate read , write transactions, write transaction made short , take place after of data gathered (the bulk of transaction length involves collecting remote data). edit: here's simple test approximates believe happening. since i'm dealing long running transactions, commit takes place long after first flush. illustrate situation left commit out of test: @entity static class person {

Losing variable scope inside a Python decorator -

this simple decorator works expected: def protect(*permissions): def outer(f): def inner(*args): print permissions[0] return f(*args) return inner return outer @protect('protected') def func(var): return var print func('something') the output is: protected moving beyond python shell , using decorator in larger scope of project, strange happening: while inside of inner function, permissions not defined. i'm thinking there must python variable scoping/decorator subtleties i'm unaware of causing this. insights appreciated. in mind figure out going on - let me try spell out: it has python not "perceiving" "permissions" variable existing on scopes outside "inner" function - since when "inner" defined, "permissions" long have been defined in 'outsidemost' scope of protect. thus, when compiling inner variale taken being global

windows - vbscript to download a file (bypassing invalid certificate errors) -

dim xhttp: set xhttp = createobject("microsoft.xmlhttp") dim bstrm: set bstrm = createobject("adodb.stream") xhttp.open "get", "https://www.website.com/apps/certmgr.exe", false xhttp.send bstrm .type = 1 '//binary .open .write xhttp.responsebody .savetofile "c:\certmgr.exe", 2 '//overwrite end using above code i'm trying download file secure site install security certificate automatically, works fine http site, i'm needing bypass security errors. ideas? you need switch msxml2.xmlhttp msxml2.serverxmlhttp , use setoption method value sxh_server_cert_ignore_all_server_errors . place call between open , send. here's example updated new code. const sxh_server_cert_ignore_all_server_errors = 13056 dim xhttp: set xhttp = createobject("msxml2.serverxmlhttp") dim bstrm: set bstrm = createobject("adodb.stream") xhttp.open "get", "https://www.website.com/

Rails (newbie) - How to store a token variable in a link in db on create action -

i have problem create action , don't understand why wrong here. users can follow link contain token variable. here route. routes.rb match "/:token" => "invitations#new", :via => :get on create action want token stored in sender_token instance in db. i tried this: invitation controller def new @invitation = invitation.new end def create @invitation = invitation.new(params[:invitation]) if @invitation.save # here pb ??? @invitation.sender_token = :token session[:invitation] = @invitation mailer.invitation(@invitation).deliver redirect_to invite_request_path else render :action => 'new' end end thank you! shouldn't be @invitation.sender_token = params[:token]

Can Android's internal memory be mapped to a drive letter on PC? -

when android device plugged in pc (through usb?), internal file system mapped drive letter on pc? 1 can copy files , android under windows? and, can emulator simulate situation when it's plugged in? how? thank in advance! you can mount device via usb (in win7 @ least) doesn't appear have own drive letter; rather it's treated camera or media device. doesn't mount automatically; need "opt-in" in notification area "turn on usb storage" don't know emulators.

java - How does JAXB map a class name to an XML element name? -

i using jaxb (the version included jdk 6) marshall objects xml. following piece of code yields unexpected results: public class jaxbtest { @xmlrootelement public static class vipperson {} public static void main(string[] args) throws jaxbexception { stringwriter sw = new stringwriter(); vipperson p = new vipperson(); jaxb.marshal(p, sw); system.out.println(sw.tostring()); } } output above is <?xml version="1.0" encoding="utf-8" standalone="yes"?> <vipperson/> i expecting see class name mapped vipperson element rather vipperson based on section 8.12.1 in jaxb specification , says class name: class name mapped xml name de capitalization using java.beans.introspector.decapitalize(class name ). the javadoc decapitalize method says this: utility method take string , convert normal java variable name capitalization. means converting first character upper case lo

Reducing html size -

does have suggestion on how can reduce home page size please http://www.floorsandchores.net all of other answers correct, there additional fine tuning can do. ;-) 1.) have million-and-one non-breaking spaces used alignment... use css instead of this: &nbsp; &nbsp; &nbsp; 2.) there has better image preloading macromedia preloaders circa 1999. 3.) use server-side comments, don't pushed client 4.) have ton of empty onclick="" handlers in code. if don't need them, rip them out. 5.) delete empty font tags, , strong tags, , divs aren't being used 6.) unless overrode inline, don't need add display:block div's 7.) favicon bmp file... should ico ie (and/or png modern browsers) 8.) drop right-click blocker - there's no point in anymore. browsers expose entire html/js/css see in ways can't block. 9.) remove/refactor javascript targetting ie4 , netscape6 - both of these browsers died years ago 10.) have meta

Javascript Image Reloading; flickers -

i have image, out.jpg , updated more or less every second. want image displayed in html file, , date. original solution reload image every half second. worked fine, image flicker white second while loading. any solutions? what tried fix load image separate hidden <img> tag, , load visible <img> tag, , let open cache, eliminating flickering. worked part of time, out.jpg have changed time hidden tag loaded , visible tag loaded it... causing more flickering. how loading image? probably preload technique need. can create image in jquery , bind load( ) event it. when event fires swap img.src of image in html http://api.jquery.com/load-event/

javascript - Why doesn't Safari decodeURIcomponent() a URI-ecoded piece of JSON automatically, like Firefox? -

i'm passing uri-encoded json string secure iframe non-secure grandparent iframe. when reaches parent, parse using yui's yahoo.lang.json.parse() in firefox, works perfectly, , string looks "{\"cntctnm\":\"mike\", in safari, looks "{%22cntctnm%22:%22mike%22, and yahoo.lang.json.parse() chokes. so, how viable hackaround of looking uri encoding, , decoding string if find it? if(jsonstr){ secrjsonresp.indexof("22:%22")>-1; var updtjsonobj = cmn.parsejson(decodeuricomponent(jsonstr)); }else{ var updtjsonobj = cmn.parsejson(jsonstr); };

apache - How do I connect to a remote URL which requires Spring Security forms authentication (Java)? -

i've searched , searched can't seem find answer seems straightforward authentication scenario. we have existing java web application uses form-based authorization provided spring. attempting access application via our portal site without challenging user enter credentials (sso). the portal has credential vault , can access secrets remote web application on server side. using apache's http components utility post login request j_spring_security_check , authenticating. response post sends 302 redirect application home page , sets cookie session id. now have somehow send authenticated session browser , having trouble. redirecting browser home page doesn't work - redirects login page. forwarding of response headers browser received on server-side doesn't work either - still returned login page. so, how authenticate server-side , still able load target page client-side? i relatively new apologize if silly question. or advice regarding alternative approach a

Getting conditional counts on to the same row in MySQL / SQL -

suppose have table, foo, looks this: id | name | gender | team 1 | bob | male | 2 | amy | female | 3 | cat | female | b 4 | dave | male | b 5 | evan | male | b if wanted list of number of males , females per team on same row , how that? i know select count(name) "#", team, gender foo group team, gender , , that's fine purpose. but give me 2 rows per team, below, , can pain. # team gender 1 | | male 1 | | female 1 | b | female 2 | b | male how structure query such appear on same row? ie, team | males | females | 1 | 1 b | 2 | 1 select team, sum(case when gender='male' 1 else 0 end) male, sum(case when gender='female' 1 else 0 end) female tbl group team for comment imagine each row has arbitrary numeric score associated it, in score column. how have 'male points' , 'female points? sum(case when gender="male" select points else 0 end) "male points&q

Duplicate Elimination in java -

i need write program enter 5 numbers 10 100 don't know how can eliminate duplicates? got bright ideas on how can it? use set implementation whic definition not contain duplicates... treeset<integer> ints = new treeset<integer>(); int[] int_array = { 1, 2, 3, 4, 3, 5, 4, 2, 3, 4, 3 4, 2, 1 }; (int n : int_arr) ints.add(n); (int n : ints) system.out.preintln(n); outputs: 1 2 3 4 5

F# Type Inference -

i kind of new f# maybe question dumb. wrote program in f# used generic types. compiler determined types not way desired because had bug in deepest function call had instantiated type wrong type. resulted in type mismatch elsewhere had used type had expected. have mention find root of problem tried explicitly enforce higher level functions use types desired generic type. type mismatch shown in high-level functions not low level function type instantiated. think it's not convenient way of determining types because easier programmers determine type on higher level functions , explicit type assignment should result in type error in lower level function type has been determined. in experience seems automatic type determination of compiler overrides explicit type declaration. understanding wrong here? something code below: type test<'a,'b>={func:'a->'b; arg:'a} let c(a)= a.func(2)|>ignore let b(a)= c(a) let a(a:test<int64,int64>)= b

javascript - PHP generated JS not running on IE7+ -

i've been playing around js generated in php , far i've had no luck ie. other browsers firefox , chrome parse , execute js code. for example page http://crusthq.com/projects/crusttalk/ loads javascript http://crusthq.com/projects/crusttalk/_js/?page=demo i tried sending following headers in php script http://crusthq.com/projects/crusttalk/_js/ content-type: text/javascript , content-type: application/x-javascript , content-type: application/javascript with no luck. has idea why ie not parsing , executing js code? i used this instance of google closure compiler service attempt pretty-print javascript. it failed error: number of errors: 1 jsc_trailing_comma: parse error. internet explorer has non-standard intepretation of trailing commas. arrays have wrong length , objects not parse @ all. @ line 190 character 183 in ?page=demo ...ully",delay:4,clear:false,method:"append",xbutton:true,onclose:function(){},}

flash - How can a PHP application tell if the loaded swf movie uses the clickTAG -

that , other information movie, width, height, duration, framerate , if make other urlrequest. i need banner management system. you maybe using external interface , let swf tell php app whats what. the swf call javascript function in page sending list of parameters interested in , pass on php. applies if swf not viral though. if have no control of swf embedded send post request name pair values (width, height etc) php page. also timwebdev says amfphp solution swf / backend communication. if had better idea of requirements might able suggest more relevant solution.

groovy - Grails - save() failing with MissingMethodExcepition in integration test -

i'm learning groovy / grails, , writing first integration test. it's failing with: groovy.lang.missingmethodexception: no signature of method: com.mangofactory.scurry.user.save() applicable argument types: () values: [] my test isn't doing fancy: class usereventcontrollertests extends controllerunittestcase { protected void setup() { super.setup() } protected void teardown() { super.teardown() } void testaddingauser() { def user = new user(emailaddress: "martypitt@test.com") user.save() } } saving entity works fine when through scaffolded pages provided grails. what have missed? if want integration tests shouldn't extend 1 of unit test base classes, change to class usereventcontrollertests extends groovytestcase { ... } and make sure it's in test/integration, not test/unit. but looks want test controller (it's called usereventcontrollertests) should

javascript - How to get focus node for ie -

i have div, want find current focus node(element) in div ie. firefox , chrome got focus node using selection attribute. there no kind of attribute ie. selection.focusnode pls give ideas. in advance. try: document.activeelement demo

Code (C++) to html converter for Forums -

i have searched quite time , unable find program able convert code html use in forums, not web-pages, in case cannot use style-sheets , not output (or has option turn off) extraneous tags such html, body etc. exist? if not, know next side project be... passing noclasses=true pygment's htmlformatter tell use inline styles instead of css. should supported in pygmentize command.

iphone - Multiple UIBarButtonItems in UINavigationBar -

how create multiple bar button in navigation bar? you must use uitoolbar , set toolbar buttons: // create toolbar can place buttons uitoolbar *toolbar = [[uitoolbar alloc] initwithframe:cgrectmake(0, 0, 100, 45)]; [toolbar setbarstyle: uibarstyleblackopaque]; // create array buttons nsmutablearray *buttons = [[nsmutablearray alloc] initwithcapacity:3]; // create standard save button uibarbuttonitem *savebutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemsave target:self action:@selector(saveaction:)]; savebutton.style = uibarbuttonitemstylebordered; [buttons addobject:savebutton]; // create spacer between buttons uibarbuttonitem *spacer = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemfixedspace target:nil action:nil]; [buttons addobject:spacer]; // create standard delete button trash icon uibarbuttonitem *deletebutton = [[uibarbuttonitem alloc] initwithbarb

php - Mysql retrieve polygon data -

i have been developing site stores spatial data in mysql database, of buildings, gardens, etc. in form of polygons (latitudes , longitudes). i want know how retrieve polygon data in mysql. i have seen sample query insert polygon data: http://amper.110mb.com/spat/mysql_initgeometry2.htm but want know how retrieve data table, based on constraints like: "where latitude < 9.33 , longitude > 22.4" how find whether point lies inside or outside of polygon here page lots of examples: http://howto-use-mysql-spatial-ext.blogspot.com/ this 1 of examples retrieve rows points intersect specified bounding box: set @bbox = 'polygon((0 0, 10 0, 10 10, 0 10, 0 0))'; select name, astext(location) points intersects( location, geomfromtext(@bbox) ); the mysql documentation says these spatial functions work geometries (looks point geometry). can check if geometry in database intersects 1 specify in select statement.

caching - Does Postgres provide a command to flush buffer cache? -

hi need sql tuning task, such tests on test db. after excute sql statments, want flush buffer cache containing sql statements , sql result, command in oracle "alter system flush buffer_cache" pg server provide commond of this? check out answer, see , clear postgres caches/buffers?

php - Getting HTML before first <br/> tag -

i've been trying extract content of variable before first break tag occurs in php. e.g $content = "this content <br /> continues <br /> break tag"; i want part before first tag , store in variable $first. above example, $first should contain "this content" any idea how in php? i'm stuck split() php function... $content = "this content <br /> continues <br /> break tag"; $parts = explode("<br />", $content); $first = trim($parts[0]); explode function: http://php.net/manual/en/function.explode.php split string string trim function: http://www.php.net/manual/en/function.trim.php strip whitespace beginning , end of string

c++ - Why function template cannot be partially specialized? -

i know language specification forbids partial specialization of function template. i know rationale why forbids it? not useful? template<typename t, typename u> void f() {} //allowed! template<> void f<int, char>() {} //allowed! template<typename t> void f<char, t>() {} //not allowed! template<typename t> void f<t, int>() {} //not allowed! afaik that's changed in c++0x. i guess oversight (considering can partial specialization effect more verbose code, placing function static member of class). you might relevant dr (defect report), if there one. edit : checking this, find others have believed that, no-one able find such support in draft standard. this thread seems indicate partial specialization of function templates not supported in c++0x . edit 2 : example of meant "placing function static member of class": #include <iostream> using namespace std; // template<typ

c++ - C instruction is being reordered when cin cout and gets is used consecutively -

does knows why c instruction being reordered when cin cout , gets used consecutively here? using dev-c++ 4.9.9.2. #include<iostream> using namespace std; int main(){ char a[10],b; for(;;){ cout<<"\ncin>>b:"; cin>>b; cout<<"gets(a):"; gets(a); cout<<"cout<<a<<b:"<<a<<" "<<b<<"\n\n"; } } i got output like: cin>>b:132 gets(a):cout<<a<<b:32 1 cin>>b:465 gets(a):cout<<a<<b:65 4 cin>>b:312242 gets(a):cout<<a<<b:12242 3 cin>>b:1 gets(a):cout<<a<<b: 1 cin>>b: it seemed input cin passed in gets.. , appears instructions reordered like: cin>>b; gets(a); cout<<"gets(a):"; instead of, cin>>b; cout<<"gets(a):"; gets(a); cin>>b read character, leaving rest of input read

iphone - How to read a random line from a textfile? -

i'm absolute beginner xcode , objective-c, hey sounded book i'm reading rory lewis ! i'm trying write simple question game ios. this first app, except few versions "hello world" ;-) have read large number of forums, , haven't yet found i'm looking for. so read out random line plain textfile, let's "file.txt" wich contains 500 lines. when press button, app fetch random line file.txt , present on screen. have tried number things, , feel i'm fumbling in dark ! hoping point me in right direction (a basic 1 please ;-). something should work: #include <stdlib.h> #include <time.h> nsstring *file = [[nsbundle mainbundle] pathforresource:@"file" oftype:@"txt"]; nsstring *filecontents = [nsstring stringwithcontentsoffile:file]; nsarray *lines = [filecontents componentsseparatedbystring:@"\n"]; /* initialize random seed: */ srand ( time(null) ); /* generate random number: */ in

moving file in android -

can move file 1 folder through code? have @ file.renameto method.

c++ Setting a pointer variable in parent class from child and use it in parent class -

i'm sorry title. seem have problem. i'm beginner , i'm sorry if asked before.. couldnt find straight answer on one. (when search class, pointer , child results passing parent or child pointers... not want pass (this) child or parent pointer, want pass pointer initialized on child class.. parent). i'm trying here better explained code: class app { public: virtual void init(void) { window = &basicwindow(); } virtual void createwindow(void) { window->create(); } protected: window *window; }; class game : public app { public: virtual void init(void) { window = &openglwindow(); } }; int main () { app *game = &game(); game->init(); game->createwindow(); return 0; } is legal? have abstract window class basicwindow , openglwindow derives. however, when create window access violation reading location error breaking @ window->create() inside app::createwindow() function. thanks i&

Perl Win32::API() return type -

can give example of how string can returned call using win32::api() function? need return string , print using $val . please give example if same can handled using pointer return type. use win32::api; $res = new win32::api('abc.dll','myfun','_argument type list_','_return type list_')or die $^e; $val= $res->call(); print ($val); the documentation win32::api 's call() method suggests must pass call() scalar used buffer store returned value; call() return whether call succeeded or not. example: my $return_buffer = " " x 80; if ($res->call(80, $return_buffer)) { print "ok, api call returned '$return_buffer'\n"; } else { print "the api call failed reason.\n"; } edit: quoting the docs completeness: the 2 parameters needed here length of buffer hold returned temporary path, , pointer buffer itself. numerical parameters, can use either constant expression or variable,

python - Seem to have a problem with returning an order.pk value with Django -

(r'^search/(?p<client_id>\d+)/(?p<order_no>\d+)/test_items/$', views.test_items), i want link can go url views.service_order2, unfortunately, keep getting noreversematch error. (r'^quote/service_order/(?p<client_id>\d+)/(?p<order_no>\d+)/(?p<request_type>\d+)/$', views.service_order2), caught noreversematch while rendering: reverse 'tiptop.views.service_order2' arguments '('', 17l, 1)' , keyword arguments '{}' not found the problem seems order not have pk value. have done same procedure test_items view , worked out fine. why in 1 of views can return order.pk value, in (service_order2 view) can't question. #views.py def service_order2(request, client_id = 0, order_no = 0, request_type = 1): # lot of code order=request.session['order'] return render_to_response('service_step1__2nd.html', {'contacts':contacts, 'addresses':addresses, 'title':ti

c++ - How to check what shared libraries are loaded at run time for a given process? -

is there way check libraries running process using? to more specific, if program loads shared libraries using dlopen , readelf or ldd not going show it. possible @ information running process? if yes, how? other people on right track. here couple ways. cat /proc/nnnn/maps | awk '{print $6}' | grep '\.so' | sort | uniq or, strace: strace cmd.... 2>&1 | grep '^open(".*\.so"' both of these assume shared libraries have ".so" somewhere in paths, can modify that. first 1 gives pretty output list of libraries, 1 per line. second 1 keep on listing libraries opened, that's nice. edit: , of course lsof ... lsof -p nnnn | awk '{print $9}' | grep '\.so'