Posts

Showing posts from May, 2014

generics - List.AddRange Has Some Invalid Arguments -

i want create list of flowers (for example) conform predefined iflower interface below. public interface iflower { string colour { get; } int petals { get; } } public class rose : iflower { public rose() { string[] colours = new string[]{ "pink", "orange", "red", "crimson", "cerise" }; random random = new random(); colour = colours[random.next(0, 4)]; } public string colour { get; set; } public int petals { { return 8; } } } public class daisy : iflower{ public daisy() { string[] colours = new string[]{ "white", "yellow", "purple" }; random random = new random(); colour = colours[random.next(0, 2)]; } public string colour { get; set; } public int petals { { return 18; } } } public class flowers { public list<daisy> daisies { { ...

c++ - Optimal virtual machine/byte-code interpreter loop -

my project has vm executes byte-code compiled domain-specific-language. i'm looking @ ways can improve execution time of byte-code. first step i'd see if there way improve byte-code interpreter before venture machine code compilation. the main loop of interpreter looks this: while(true) { uint8_t cmd = *code++; switch( cmd ) { case op_1: ...; break; ... } } question: there faster way implement loop without resorting assembler? the 1 option see gcc specific use dynamic goto label addresses. rather break @ end of each case jump directly next instruction. had hoped optimizer me, looking @ disassembly apparently doesn't: there repeated constant jump @ end of op_codes. if relevant vm simple register based machine floating point , integer registers (8 of each). there no stack, global heap (that language not complicated). one easy optimisation instead of switch /case/case/case/case/case, just define array function pointers (where each f...

c# - Serialize a derived type without the type and namespace attributes -

i have xml api have mimic character character. i'm trying use built-in xml serialization functionality in .net, it's adding attributes. in normal web service or xml api, these attributes wouldn't hurt , might serve purpose. unexpected characters and, unfortunately, cannot allow them. here's i'd (with hypothetical objects of course): i have base type public abstract class instrument { } ...and have derived type public class guitar : instrument { } ...and serialize derived type this: <guitar /> instead, this: <instrument d1p1:type="guitar" xmlns:d1p1="http://www.w3.org/2001/xmlschema-instance" /> here's test i'm working with: [testclass] public class when_serializing_a_guitar { private xmlserializer _serializer; private string _expectedxml; private stringwriter _stringwriter; private string _actualxml; private xmlserializernamespaces _ns; private xmlwriter _xmlwriter; private ...

Flex TitleWindow (or NativeWindow) skinned as a Fancybox? -

the customer working wants display popup in air application (designed in flex 4).i therefore use titlewindow , popupmanager (or nativewindow option too). pretty basic, can handle this. trouble is, customer popup looking fancybox , is, close button, out of popup. do know how ? easy enough. create custom skin based titlewindow can change appearance , location of close button (among other things). setup straightforward, should how skin in flex 4 .

java - Why does System.getProperty("line.seperator") return null? -

exactly title asks, why system.getproperty("line.seperator") returning null. from looking around gather shouldn't. running code shows seems set line separator broken: class test { public static void main( string[] args ) { system.out.println(system.getproperties()); } } $ java test {java.runtime.name=java(tm) se runtime environment, sun.boot.library.path=/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/i386, java.vm.version=19.1-b02, java.vm.vendor=sun microsystems inc., java.vendor.url=http://java.sun.com/, path.separator=:, java.vm.name=java hotspot(tm) server vm, file.encoding.pkg=sun.io, sun.java.launcher=sun_standard, user.country=gb, sun.os.patch.level=unknown, java.vm.specification.name=java virtual machine specification, user.dir=/home/niko, java.runtime.version=1.6.0_24-b07, java.awt.graphicsenv=sun.awt.x11graphicsenvironment, java.endorsed.dirs=/usr/lib/jvm/java-6-sun-1.6.0.24/jre/lib/endorsed, os.arch=i386, java.io.tmpdir=/tmp, line.sepa...

objective c - looping in iphone -

possible duplicate: for loop , if statement hi everyone, have following loop , preeceding if else condition.m using following code. for (int intprjname=0 ; intprjname<[arrprjname count] ;intprjname++) { if ([strselectedprojectname caseinsensitivecompare:[arrprjname objectatindex:intprjname]) { //some code } else { //some code } } suppose strselectedprojectname "aaa"and arrprjname contains "aaa" "bbb" "ccc" .. after first iteration of loop if condition gets true i.e string "aaa" matches string in array list,it should out of loop @ second iteration,i.e should not enter else condition.. add break; command for (int intprjname=0 ; intprjname<[arrprjname count] ;intprjname++) { if ([strselectedprojectname caseinsensitivecompare:[arrprjname objectatindex:intprjname]) { //some code break; } else { //some code } } ...

How to pass NULL value for integer/fixnum type in ruby for SOAP request -

i need invoke method getquotedata() through soap request using parameters: username , password , id , revnum revnum revision number of data fetching. can have values ... 1,2,3... , on. if pass null value it, latest data. how can initialize integer null value in ruby method call? method call not work if pass nil revnum or if not send parameter. below our sample method call: getquotedata(:username => user, :password=> pass, id => "xks32", revnum=> 0) the wsdl definition of method is: <s:element name="getquotedata"> <s:complextype> <s:sequence> <s:element minoccurs="0" maxoccurs="1" name="username" type="s:string" /> <s:element minoccurs="0" maxoccurs="1" name="password" type="s:string" /> <s:element minoccurs="0" maxoccurs="1" name="cartcompositenumber" type="s:str...

apply_filters from within a Class (WordPress) -

i'm writing plugin makes use of wp_mail function. want change from: address. wp provides filters - wp_mail_from_name , wp_mail_from - i'm not sure how call them within class. if place them outside of function there's parse error (unexpected t_string, expecting t_function). if place them within function nothing seems happen class myplugin { public function setfromname($fromname) { apply_filters( 'wp_mail_from_name', $fromname ); $this->fromname = $fromname; } public function setfromemail($fromemail) { apply_filters( 'wp_mail_from', $fromemail ); $this->fromemail = $fromemail; } } how possible affect these filters within class? in wordpress filters must have call back, can not use variable. class myplugin { public function myplugin { add_filter( 'wp_mail_from_name', array($this, 'filter_mail_from_name')); add_filter( 'wp_mail_from', a...

workflow - Trying to get Persistence Participant Promotion to work with a xamlx service in WF4 -

i have implemented workflow persistence participant promotion, shown here on microsoft's website:http://msdn.microsoft.com/en-us/library/ee364726%28vs.100%29.aspx , while seems works. not see data saving database when query? think missing step or microsoft missed something. i using workflow application .xamlx service , have overridden workflowservicehost. seems working fine, not sure problem can be? so question here have real working example of how implement persistence participant? i tried few different takes on this andrew zhu's here http://xhinker.com/post/wf4promote-persistence-data.aspx microsoft samples but cannot seem work. just fyi-this code works when changed xnamespaces match. maurice workflowservicehost code: public class servicehostfactory :workflowservicehostfactory { private static readonly string m_connectionstring = "data source=localhost;initial catalog=workflowinstancestore;integrated security=true"; p...

How to build WiX so that it copies files based on where .msi is being installed? -

i have build .msi using wix gets deployed several environments. each env. has own config file. right now, build 1 msi per environment , want move away practice. there way build 1 msi intelligent copy specific files based on running? once have decided target environment is , based on whatever characteristics define, can create discrete component each of config files want deploy per environment, , give each component condition evaluates true target environment, , false otherwise. if environment change, need make component condition transitive repair\upgrade deploy correct config file. one difficulty may face components supposed represent unique resources. looks have lots of different config files same name , destined same target folder. may find easier give config files different 'pseudo' names , use copyfile copy pseudo version terminal destination.

java - How to use Jena TDB to store local version of Linked Movie Database -

i have local version of linkedmdb in n-triples format , want query it. now, want use jena tdb, can store data can used querying later. checked documentation tdb java api , unable load n-triples file , query sparql. i've used following code: string directory = "e:\\applications\\tdb-0.8.9\\tdb-0.8.9\\bin\\tdb"; dataset dataset = tdbfactory.createdataset(directory); // assume want default model, or named model here model tdb = dataset.getdefaultmodel(); // read input file - needs done once string source = "e:\\applications\\linkedmdb-18-05-2009-dump.nt"; filemanager.get().readmodel( tdb, source, "n-triples" ); and got following exception exception in thread "main" com.hp.hpl.jena.tdb.base.file.fileexception: not directory: e:\applications\tdb-0.8.9\tdb-0.8.9\bin\tdb @ com.hp.hpl.jena.tdb.base.file.location.<init>(location.java:83) @ com.hp.hpl.jena.tdb.tdbfactory.creat...

callback - Android call back after layout rendering has completed? -

how can create/bind service after activity layout rendered? -- update i have 2 tabs (both separate activities)on main activity , data used tabs comes service. right i'm binding service inside oncreate method. issue layout not rendered till statements inside oncreate gets finished. blank screen shown till service bind see viewtreeobserver more info here: https://stackoverflow.com/a/7735122/338479

asp.net - WCF Security Message vs Transport speed -

how slower message security typically compared transport security? this going depend on scenario, here performance comparisons benchmarks .

multithreading - Java: nice way to stop threaded TCP server? -

i have following structure tcp client-server communication: on server startup server starts acceptor thread, accepts client connections , passes serversocket it. when client connection arrives, acceptor thread calls accept() on serversocket , submits client processing job worker thread (by executor/thread pool) , provides client socket it. worker in loop reads data client socket stream, processes , sends replies. the question how gracefully stop whole system? can stop acceptor thread closing serversocket. cause accept() blocking call throw socketexception. how stop workers? read stream , call blocking. according this streams not throw interruptedexception , worker cannot interrupt()'ed. it looks need close worker socket thread, right? this, socket should made public field or method should provided in worker close it. nice? or may whole design flawed? your model works appropriately. best way of interrupting non-interruptable constructs io...

python - for loop to insert things into a tkinter window -

i have tkinter program has add significant amount of data window tried write loop take care of since have use string variable name of object tkinter running .insert() on object. didn't explain here method def fillwindow(self): global filedirectory location = os.path.join(filedirectory, family + '.txt') file = open(location, 'r') ordersdict = {} line in file: (key, value) = line.split(':', 1) ordersdict[key] = value key in ordersdict: ordersdict[key] = ordersdict[key][:-2] item in ordersdict: if item[0] == '#': if item[1] == 'o': name = 'ordered%s' %item[2:] right here problem line because have variable matches name of entry object created 'name' string variable gives me error "attributeerror: 'str' object has no attribute 'insert'" ...

python - Pythonic way to parse list of dictionaries for a specific attribute? -

i want cross reference dictionary , django queryset determine elements have unique dictionary['name'] , djangomodel.name values, respectively. way i'm doing to: create list of dictionary['name'] values create list of djangomodel.name values generate list of unique values checking inclusion in lists this looks follows: alldbtests = dbp.test_set.exclude(end_date__isnull=false) #django queryset vctestnames = [vctest['name'] vctest in vcdict['tests']] #from dictionary dbtestnames = [dbtest.name dbtest in alldbtests] #from django model # compare tests in protocol in fortytwo's db protocol vc obsoletetests = [dbtest dbtest in alldbtests if dbtest.name not in vctestnames] newtests = [vctest vctest in vcdict if vctest['name'] not in dbtestnames] it feels unpythonic have generate intermediate list of names (lines 2 , 3 above), able check inclusion after. missing anything? suppose put 2 list comprehensions in 1 line ...

Change rectangle color in Rave runtime Delphi -

we print database records in rave using rvproject1 , rvdatasetconnection1 , works. how acomplish in rave: if adotabel1.fieldbyname('something').asstring = 'something' rectangle1 on data band.color=black else rectangle1 on data band.color=green rawn, i believe must download visual designer guide.pdf located here http://www.nevrona.com/rave/downloadbe.html . want accomplish can done in several ways(with editor events, delphi code, etc). in manual find how code band or datatext onbeforeprint event(rave report 'language' similar delphi). @ moment don't have time making example. best regards, radu

in app purchase - Android: in-app product ID -

how in-app product id should like? if application id looks com.example.test , can define product id item ? or should com.example.test.item ? ok, i've tested that. product id should unique within application. item can used. everywhere reflected com.example.test:item .

Javascript Number and Currency localization -

i've run numbers , currency localization in javascript what need convenient library that. i responsible setting decimal separators, currency, etc. please post best links think most modern browsers have built in support internationalisation in form of global intl object , extensions number, string & date. var money = 123456.12; // display correct formatting money.tolocalestring('de-de'); // "123.456,12" // currency money.tolocalestring('en-gb', { style: 'currency', currency: 'gbp' }); // "£123,456.12"

java - When should I create a new activity? -

when should new activity created in android? should create new activity each large task or switch views? what's best practice? as general rule, whenever expect button reverse operation, start new activity. the reason why there 100s of questions on stack overflow asking how override button developers not take approach, have dig out of resulting mess.

Ignore Sibling-Modules During Maven Javadoc/Site Compilation -

i have maven-managed project contains few modules, 1 of actual library of interest. other modules add-ons or examples build off of library. i'm looking generate maven site library , have automatically deployed (as standalone site , not part of multi-module site) having trouble javadoc plugin. when executing javadoc:javadoc goal, javadoc plugin attempting access jar other modules causing failure. i have created simple example demonstrates phenomenon. make sure run clean goal before others flaw shown. though executing packaging first solve error, cannot done because use case occurs during maven-managed release process starts clean state. is there way me disable functionality in javadoc plugin documetation library module? i can think of 2 options depending on preference. both include using profiles. if want default build create javadocs library of interest. make other modules use property inside of default profile in order skip javadocs. if okay passing in ...

sql server - How to resolve error loading DB project in Visual Studio 2010 -

i started getting following error in "general" ouput window of visual studio 2010 when loading database project part of pretty large solution: cannot evaluate item metadata "%(fullpath)". item metadata "%(fullpath)" cannot applied path "obj\debug|any cpu\database.dbschema". illegal characters in path. c:\windows\microsoft.net\framework\v4.0.30319\microsoft.common.targets nothing has changed in .net framework recently, , there not mention of fullpath in database.dbproj file. googling around yielded blog entry, resetting visual studio environment did not help: http://social.msdn.microsoft.com/forums/en/vstsdb/thread/14eecc38-87fe-4234-b5fa-c2fa7cab9ae9 after banging head against wall, occurred me try , load db project on own, outside solution. lo , behold, worked. gave me clue wrong solution itself. compared .sln file generated when opened project on own contents of large solution, nothing obvious jumped out. in end, delete...

asp.net - Retrieve XML from HTTP POST Request Payload -

i have activex posts server (http handler) payload of xml document. is there better way retrieve payload xml below? private static byte[] requestpayload() { int bytestoread = httpcontext.current.request.totalbytes; return (httpcontext.current.request.binaryread(bytestoread)); } using (var mem = new memorystream(requestpayload())) { var docu = xdocument.load(mem); } once have "docu" can query using linq xml. thanks simply load xml inputstream of request e.g. xdocument doc; using (stream input = httpcontext.current.request.inputstream) { doc = xdocument.load(input); } there no need memorystream in view.

iphone - How to prevent UITableView interaction while UITextField is FirstResponder -

is there simple way prevent user interaction while entering text in uitextfield (the textfield in cell of tableview)? i've tried this: - (void)textfielddidbeginediting:(uitextfield *)textfield { self.tableview.userinteractionenabled = no; } with result keyboard stops showing up... the first thought comes mind adding transparent uiview overlay "mask" surrounding cell, intercepting touch events. suppose have 2 overlays - 1 above cell , 1 below.

mysql - database convertor -

i have table many data ... , have new structure in other database , system ... there program convert database new structure? this program must read structure of both of them , ask me field fill field in new table , field drop , etc ... can body suggest application these things me? also sql file mysql , structure (new table) postgersql there several mysql => postgres scripts listed in postgres wiki, , there's a guide on syntax changes here

Question about sample rate and frame rate sizes with Java Sound API -

i inherited code uses java's sourcedataline sound api. below how setup audioformat object. seems strange frame-rate , sample-rate set same. make sense? also, there point have 20000000 frame rate or sample rate? don't our ears top out @ 20000? audioformat af = new audioformat(audioformat.encoding.pcm_signed, 20000000, 16, 1, 2, 20000000, true); if stream encoded in pcm format , not compressed, frame contains samples each channel, 1 time index. if stream compressed, frame contains samples each channel, 1 or more time indexes. exact structure of frame depends on compression type. check out audioformat class definition more details: http://download.oracle.com/javase/6/docs/api/javax/sound/sampled/audioformat.html most sound systems consider top frequency human ear 22khz, that's why sampling frequency 44khz (according niquist rule).

flex3 - Setting disabled button appearance in Flex -

i'm making trivia in air application, question, 3 buttons, after choose one, right button gets coloured green, wrong ones coloured red. trying changing styles, created button.right , button.wrong style, need disable buttons don't clicked more once while i'm showing correct answers. so i'm having trouble making buttons don't greyish , alpha turned down when set enabled property false. i'm trying minimalistic possible here, changing disabled-overlay-alpha or disabledoverlayalpha in css file doesn't seem trick, neither changing disabledbordercolor any fast tricks this? this might dirty workaround, try disabling buttons setting mouseenabled property false forbid them interacting mouse.

eclipse - Folders inside the webapps folder (css, jsp etc.) not getting copied in svn repository -

i have created svn repository , done commit of newly created maven web project. problem folders except web-infand meta-inf inside src/main/webapps folder did not copied in repository (eg. css, javascript, jsp, images)......when right click on 1 of these folders (from eclipse ide)which haven't got copied , try commit, folders , content doesn't listed in list of items copied , when click finish error message 'at least 1 resource should selected'. tried using subclipse instaed of subversive use. question how add these folders repository ?? i had copied these folders project imported workspace different repository above mentioned folders contained .svn folder pointing repository , hence problem :)

java - read from file with a delimiter -

i want know how can read file in java until file pointer arrives @ delimiter or specific number of characters. in c++ used getline() . well can use bufferedreader.readline(), or maybe scanner class.

javascript - disabling onclick functionality parent/child container in jquery -

i want overrule onclick on parent div, when image-link in child container clicked. i using onlick on container called ".sight-title" to: - change class toggleclass("active"); - change content ajax call initial state: <div class="sight-title" id="s2851"> <div class="row1"></div> <div class="row2"></div> </div> after clicking: <div class="sight-title active" id="s2851"> <div class="detail1"> <a class="wikilink" target="_blank" title="en.wikipedia.org/wiki/marollen" href="http://en.wikipedia.org/wiki/marollen"><img src="img/contact/culisite_wikipedia.png" border="0"></a> </div> <div class="detail2"></div> </div> when de parent ".sight-title" clicked again changes initial state. but when class=...

jquery - Google Maps v2 GGroundOverlay not rendering until screen resize -

i'm working on google map based thing using v2 (which know deprecated, it's legacy code). have function call in several places (picking existing "pin", dropping new "pin") renders images "range" around selected point. the "map" that's passed in here gmap object. centrept glatlng, , rangevalue int, gotten jquerytools slider control. function drawcircle(map, centrept, rangevalue) { if (circle) { map.removeoverlay(circle); } var boundaries = getboundaries(centrept, rangevalue); circle = new ggroundoverlay("/images/map_range.png", boundaries); map.addoverlay(circle); } i have running on many pages, , in many contexts works great. in 1 particular page, image @ /images/map_range.png doesn't display. slider slides, values underlying update (i'm watching firebug), function fires (and writes console, when had in there), no circle... until window resizes. literally can slide on slid...

Selecting not joined data from several tables in MySQL -

i have several mysql tables same structure. have date field. have build 1 list in php shows rows in these tables, ordered date. rows mixed in list, criterium ordering date. for instance: table1.name; 2011-4-11 05:45h table6.name; 2011-4-11 10:30h table3.name; 2011-4-11 15:45h table2.name; 2011-4-16 09:30h is possible doing these using mysql query or have make 1 select per table , mix data php? there aren't joined tables, equal tables , have show data. p.s.: can't make 1 unique table , add type field, have being asked keep tables are. well, arguably can sort of. select 'table1' name, mydate table1 union (select 'table2' name, mydate table2) tmp ... order mydate union works assuming same structure, eg in case name, date, , appends them 1 list , can sort them

How to create file directories and folders in Android data/data/project filesystem -

i working on video editor program , new android , java. happen when user presses "create new project" button, dialog pops asking user name of project. have part down, want, when user presses "ok" on dialog, code take name , create directory inside of data/data file project , inside of directory create folders titled 1 5 or more. don't know how go this, input appreciated. as sgarman proposed can use sd card (and think it's better) if want use application dir can calling getfilesdir() activity, return file object of /data/data/your.app/files can path , append new directory: string dirpath = getfilesdir().getabsolutepath() + file.separator + "newfoldername"; file projdir = new file(dirpath); if (!projdir.exists()) projdir.mkdirs(); ...

c++ - Is it possible to emulate template<auto X>? -

is somehow possible? want enable compile-time passing of arguments. suppose it's user convenience, 1 type out real type template<class t, t x> , types, i.e. pointer-to-member-functions, it's pretty tedious, decltype shortcut. consider following code: struct foo{ template<class t, t x> void bar(){ // x, compile-time passed } }; struct baz{ void bang(){ } }; int main(){ foo f; f.bar<int,5>(); f.bar<decltype(&baz::bang),&baz::bang>(); } would somehow possible convert following? struct foo{ template<auto x> void bar(){ // x, compile-time passed } }; struct baz{ void bang(){ } }; int main(){ foo f; f.bar<5>(); f.bar<&baz::bang>(); } after update: no. there no such functionality in c++. closest macros: #define auto_arg(x) decltype(x), x f.bar<auto_arg(5)>(); f.bar<auto_arg(&baz::bang)>(); sounds want generator: template <typename t> stru...

setting values [jquery or javascript] -

so have input box, , when user types in want second textarea change value match of input's, on click. how can using javascript, jquery, or simpler, or php... here's code: this first input: <form class="form1" action=../search.php method="post"> <input class="askinput" type="text" name="q" value="search tags , users or ask question" onclick="if(this.value == 'search tags , users or ask question') this.value='';" onblur="if(this.value.length == 0) this.value='search tags , users or ask question';"></input> <input class="searchenter" type="image" name="submit" src="../images/askquestion.png"></input></form> this textarea: <div id="askcenter"> <img class="close" src="../images/closeask.png"></img> <h1><img src=...

tsql - Is there a "Default Order By Column" in SQL Server? -

when execute query select col1, col2, col3 table , gets sorted primary key ascending. i'm wondering if there way specify different column, order createddate desc if there no order clause? i doubt (since unintuitive, wondering anyway. no. ordering see artifact of query optimizer's strategy. relational theory forbids there implicit ordering of set of data. you can't count on same ordering next time same query because optimizer strategy depends on context , data might change.

Problem in Creating a View Dynamically ( in Android ) [Error : couldn't save which view ...] -

i'm trying create view dynamically (on click). person have idea why not work. opens blank (black) screen. when click moves previous screen well. , need know way i'm trying set team correct. public class details extends activity { protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); //settheme(android.r.style.theme_dialog); textview label = new textview(this); label.settext("hello text"); label.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); label.settextsize(20); label.setgravity(gravity.center); tablerow tr = new tablerow(this); tr.addview(label); tablelayout tl = new tablelayout(this); tl.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); tl.setgravity(gravity.center); tl.addview(tr); scrollview sv = new scrollview(th...

actionscript 3 - Get an array of specific added children -

i'm using following array add children stage: for(var i=0;i<6;i++) { var acherry=new ccherry() acherry.y=10 acherry.x=10+100*i stage.addchild(acherry) } now want modify each cherry based on array. this: var cherryletter:array=[1,0,0,0,0,0] for(i=0;i<6;++) { if(cherryletter[i]) stage.getchildbyname("acherry")[i].y+=90 } clearly stage.getchildbyname("acherry")[i] isn't correct, coming javascript makes sense me , should accurately portray i'm trying achieve guys reading this. so, how this? being getting array of children added stage under name or class (so array of ccherry work too, if necessary), using them in way similar above loop. here recommendation how code might look, based on desire use getchildbyname() find instances of ccherry class. please note i've changed class name cherry in example (which recommend, since capitalizing class names as3 convention). also, it's practice end stat...

mysql - How to retrieve the password from a java.sql.Connection object -

i'm looking way password java.sql.connection object. know there's getusername() method in databasemetadata object, unfortunately no corresponding getpassword() method. using debugger in netbeans can see field password, there must way information using reflection, far i've been unable figure out how. as commented, way must looking code. instance, mysql using latest driver (5.1.15). can password this: public static void main(string[] args) throws exception{ connectionimpl con = (connectionimpl) drivermanager.getconnection("jdbc:mysql://localhost:3908/mydb?user=edalorzo&password=mandrake"); system.out.println(con.getproperties().get("password")); con.close(); } but this, need know class hierarchy , implementation details. other databases different. if database open source, mysql can know details of inner construction , find ways retrieve password.

concurrency - boost::unique_lock/upgrade_to_unique_lock && boost::shared_lock can exist at the same time ? it worries me -

i did experiments boost::upgrade_to_unique_lock/unique_lock && boost::shared_lock, scenario is: 1 write thread, has boost::unique_lock existing boost::shared_mutex, in thread, write global aclass 3 read thread, each 1 has boost::shared_lock same boost:;shrared_mutex, have loop read global aclass i observed threads holding locks( 1 unique, 3 shared ) @ same time, , running data access loops. my concern aclass not thread-safe, if can read/write @ same time in different threads, read crash. it's not aclass, use primitive types, reading them surely not crash, data dirty, isn't ? boost::shared_lock<boost::shared_mutex>(gmutex); this not "unnamed lock." creates temporary shared_lock object locks gmutex , temporary shared_lock object destroyed, unlocking gmutex . need name object, making variable, example: boost::shared_lock<boost::shared_mutex> my_awesome_lock(gmutex); my_awesome_lock destroyed @ end of block in declare...

Amazon S3 link expiration during download? -

does know happens if amazon s3 link expires during download process? i'm using s3 offer downloads of 1.6gig file want set shortest expiration time possible, somewhere in neighbourhood of 15 minutes. if download initiated within 15 minute period, download takes 1 or 2 hours issue? i'm assuming once download initiated fine right? any downloads initiated before expiry time continue work. just aware may run problems file downloaders attempt download multiple segments @ once. downloader may not able begin new segments after expiry time , user may not able pause/resume downloads.

javascript - Disabling enter key for form -

i have been trying disable enter key on form. code have shown below. reason enter key still triggering submit. code in head section , seems correct other sources. disableenterkey: function disableenterkey(e){ var key; if(window.event) key = window.event.keycode; //ie else key = e.which; //firefox return (key != 13); }, if use jquery, quite smiple. here go $(document).keypress( function(event){ if (event.which == '13') { event.preventdefault(); } });

java - Spring not injecting DAOs into JSF managed beans with abstract superclass -

i have jsf 2.0 application , integrating spring can make use of hibernatetemplate. consulted spring documentation on jsf integration , have taken steps set up. of bean classes extend abstract super class called superbean. superbean desired point of injection, saving me having declare of beans in spring. hoping declare abstract="true" , subclass bean extending superbean class have dao injected. @ runtime null. <bean id="servicetemplate" class="org.springframework.transaction.interceptor.transactionproxyfactorybean" abstract="true"> <property name="transactionmanager" ref="transactionmanager"/> <property name="transactionattributes"> <props> <prop key="*"/> </props> </property> </bean> <bean id="daoservicetarget" class="com.example.service.daoservice"> <property name="maindao" ref...

What's wrong with this DB2 SQL Query? -

select getorgname(bc.manageorgid), count(case when (exists (select fo.objectno flow_object fo fo.objectno=cr.serialno) , nvl(cr.finallyresult,'') in ('01','02','03','04','05')) bc.manageorgid else null end) business_contract bc, classify_record cr cr.objecttype='businesscontract' , cr.objectno=bc.serialno group bc.manageorgid, cr.serialno, cr.finallyresult the error message receive is: 11:01:32 [select - 0 row(s), 0.000 secs] [error code: -112, sql state: 42607] db2 sql error: sqlcode=-112, sqlstate=42607, sqlerrmc=sysibm.count, driver=3.57.82 ... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec [0 successful, 0 warnings, 1 errors] "the operand of column function name (in case, count) includes column function, scalar fullselect, or subquery." db2 doesn't allow this. see documentation on sql112 more. i'm not sure how fix query perhaps can...

common lisp - Acessing values of ltk widget options -

i trying make gui application in common lisp ltk , , there 1 thing cannot figure out. know can set options of ltk widgets configure , cannot figure out way read values. for example, create instance of canvas (make-instance 'canvas :width 400 :height 400) then want write method use width , height in calculations. how access these? i've asked same question in ltk user list , got answer. in short, cget function counterpart of configure so, set canvas width (configure canvas :witdh value) , retrieve (cget canvas :width). regards, andré

android - Dialog icon missing in 2.3 -

i've been testing app on emulator running 2.2 , ic_dialog_generic icon on context menus , alert dialogs appear when switch 2.3, don't show up. ic_dialog_info , ic_dialog_alert icons though. how handle show on versions? i'm using android.r.drawable.ic_dialog_xxxx access them. you try copying icons yoursdk/platforms/android-x/data/res/drawable res file in app.

Is there an easy way to turn a MySQL table into a Redis equivalent? -

is there easy way turn mysql table redis equivalent? i have myisam table in mysql used key-value store want "move" redis super fast. there easy way this? thanks. the easiest way dump of mysql table , parse relevant data entries redis commands. for example, data dump produce following: create table carousel( id int(11), path varchar(200), title varchar(200), comments varchar(200) ); insert carousel values (3,'7.jpg','inspirar','inspiration'); insert carousel values (4,'d.jpg','pilotar','pilotar'); insert carousel values (5,'8.jpg','sentir','sentir'); insert carousel values (6,'6.jpg','volar','volar'); first need decide on key structure want use in redis. 1 idea use table key , store ids of each row in set. for each table need create key hold ids, lets call them idx:$table. using our example create idx:carousel. as parse file, pull ids first column...

flash - crossdomain.xml not honored by jwplayer -

i have video player on site http://aiskacang.com/crawl/pseudo.html the player loads flv video file seeon.flv domain. currently, without crossdomain.xml in server seeon.flv located, video loaded fine. not behavior want or expect be. i tried putting crossdomain.xml following content: <?xml version="1.0"?> <!doctype cross-domain-policy system "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <site-control permitted-cross-domain-policies="none"/> </cross-domain-policy> from firebug, see there's request crossdomain.xml before accessing video file (seeon.flv). returns content fine , content-type of application/xml, still allow cross domain behavior. any idea ? it sounds may confusing use of crossdomain policies. disallowing crossdomain access doesn't prevent content being loaded , displayed. limits access between content different domains after target has been loaded , disp...

How to include external javascript functions -

i trying refer external javascript file calling function in file <script type="text/javascript" src="external.js"> display('hell0'); </script> but code not working. if refer file in separdate script tag works fine. <script type="text/javascript" src="external.js"></script> <script type="text/javascript"> display('hell0'); </script> why first case not working? if use src attribute specify external javascript file included cannot have contents script tag. second case correct way. quote specification : the script may defined within contents of script element or in external file. if src attribute not set, user agents must interpret contents of element script. if src has uri value, user agents must ignore element's contents , retrieve script via uri

java - Can Spring's LocalContainerEntityManagerFactoryBean be used in a J2SE environment? -

i'm using spring in glassfish , have need configure works outside of container, development purposes. i'm uncertain of, , couldn't find answer to, whether can use localcontainerentitymanagerfactorybean class without container. name, localcontainer , seems can in docs says: factorybean creates jpa entitymanagerfactory according jpa's standard container bootstrap contract so i'm uncertain issue. thanks, ittai i wanted note spring supports running jpa stuff outside of container, , doesn't require in way of transaction manager. question ask whether using spring's declarative transaction management (e.g., "@transactional"). if are, then need provide implementation of "platformtransactionmanager." here still, not need use full on jta support (as provided atomikos in above example. can use jpatransactionmanager instance (which expects reference entity manager factory) provided not doing "xa" etc....

php - How to get Age in Months using BirthDate column by MySQL query? -

first asked this question , accepted answer helped me. problem have calculate age in months. question: i have birthdate column in mysql database table store user's date of birth. have form in html/php 2 fields(1. age 2. age to). if user want users ages between 400 months , 600 months, possible mysql query using birthdate column. thanks select * [table] birthdate&gt= date_sub(curdate(),interval 600 month) , birthdate&lt= date_sub(curdate(),interval 400 month)

mysql - does (SQL) JOINING on TABLES ALWAYS create Cartesian products of those tables? -

does joining on tables create cartesian products of tables ? if problem can solved sub-query , joining should prefer ? 1 fast , memory saving ? all questions tightly coupled, please dont tell open thread :( mysql 5 does joining on tables create cartesian products of tables ? yes, normall filtered down , query optimizer smart enough take more efficient approach. anyhow, joins without conditions cartesian products ni start. if problem can solved sub-query , joining should prefer ? depends lot on query optimizer , data in question. in: try out. prettym uch way. which 1 fast , memory saving ? again - try out. this stuff depends no table sizes involved , filter conditions. materialized cartesian product in cases bad programming (ups, forgot fitler conditions) or bad query plan. in cases cartesian product iwll never materialize , query optimizer use different approach.

jquery - Toggle DIV when Radio Buttons are checked -

i trying make div toggle visible , not visible when group of radio buttons yes or no. for example have a list of stores in div want list of stores visible when radio button checked yes. edit script view <div id="script_form_wrapper"> <%= form_for(:script, :url => {:action => 'update', :id =>@script.id}) |f| %> <div id="script_form_visibility"> <div class="issue_section_header" align="center">visibility</div> <div class="line-break"></div> <div class="standardtext"><span class="boldtext">all stores:</span> <%=f.radio_button(:all_stores, true)%> yes <%=f.radio_button(:all_stores, false)%> no </div> <br/> <div id="script_stores"> <div class="issue_section_...

iphone - Core Data Duplicating TableView Cells Upon App Launch -

when relaunch app, cells in table view duplicated. otherwise fine when being added , deleted, etc. here code: @implementation routinetableviewcontroller @synthesize routinetableview; @synthesize eventsarray; @synthesize entered; @synthesize managedobjectcontext; #pragma mark - view lifecycle - (void)viewdidload { if (managedobjectcontext == nil) { managedobjectcontext = [(curlappdelegate *)[[uiapplication sharedapplication] delegate] managedobjectcontext]; } nsfetchrequest *request = [[nsfetchrequest alloc] init]; nsentitydescription *entity = [nsentitydescription entityforname:@"routine" inmanagedobjectcontext:managedobjectcontext]; [request setentity:entity]; nserror *error = nil; nsmutablearray *mutablefetchresults = [[managedobjectcontext executefetchrequest:request error:&error] mutablecopy]; if (mutablefetchresults == nil) { // handle error. } [self seteventsarray:mutablefetchresults]; ...

objective c - IOS : fill a tableview with tableviewcell -

how can fill uitableview uitableviewcell (customized)? follow tutorials - http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html http://adeem.me/blog/2009/05/30/iphone-sdk-tutorial-part-6-creating-custom-uitableviewcell-using-interface-builder-uitableview/

.htaccess - Wildcard subdomains, block all other -

i'm having few issues new vps bought. i'm trying configure apache accept wildcare subdomains on main website, allowing means can't block others except 1 created. to more explicit, i'm having this: subdomain1.domain.com -> redirects correctly (cname added, folder ok, ok) subdomain2.domain.com -> same subdomain1 subdomainn.domain.com -> subdomainn doesn't exist. thus, if write "stackoverflowreallyrocks.domain.com" i'm being redirect stackoverflowreallyrocks.domain.com, content of domain.com - isn't good. is there way redirect subdomains doesn't exists domain.com? the httpd.conf main domain is: <virtualhost *:80> documentroot "/home/domain" servername www.domain.com serveralias domain.com </virtualhost> <virtualhost *:80> servername subdomain1.domain.com documentroot "/home/domain/_subdomain1" </virtualhost> <virtualhost *:80> servername subdomai...

java - Integrating web app with facebook events api -

hi have web app user creates event. java/j2ee based web application , have used mysql 5.1 @ end. once user creates event on web app, event information when,where,start-time,end-time etc should transferred user's facebook profile , should le invite attendees via fb. there library readily available or should dirt hands coding. have used jquery , javascript, if there jquery or js library available please let me out to accomplish need 2 things: authenticate user app build using facebook platform use access token retrieve after authenticating them publish event on facebook step 1 can done in number of ways, explained on authentication docs , considering familiar javascript, should use facebook javascript sdk this, in particular fb.login method. 'scope' (or permissions) need request step 2 are: user_events , publish_stream once have access token user after step 1, can proceed publish event on behalf using graph api. simple. again, using javascript sdk ma...

java - Understanding Spring context initialization order -

i have complex set of beans , dependencies between them. beans @service , @repository or @controller annotated , use @postconstruct annotation. there circular dependencies still system correctly initialized spring. then added simple controller dependency 1 of services. theoretically, system should able boot because theoretically first set system before , new controller. spring complains cannot set context: error creating bean name 'userservice': requested bean in creation: there unresolvable circular reference? can somehow assists spring in how order context initialization? think main issue userservice used lot through system authentication purposes. best solution take out circular dependency; have not yet encountered scenario such structure warranted. if want stick perhaps above problem due fact have constructor injection somewhere: circular dependencies if using predominantly constructor injection possible write , configure classes , beans such u...

php - Calling a child object in the parent object -

i want know if can create child object in parent object use it... i mean posible? is idea? what have care if so? i using child classes on own , want use them in private function of parent class well. thanks here source imagine meaning: class a{ private $child_class1; private $child_class2; private function somefunction(){ $this->child_class1 = new b(); $this->child_class1->do_something(); $this->child_class2 = new c(); $this->child_class2->do_something(); } } class b extends a{ public function do_something(){ ... } } class c extends a{ public function do_something(){ ... } } this seems bad idea imho - it's going require high maintenance , creating tight couplings between classes. i recommend creating abstract function in parent each of children implement it's own logic. [edit] since trying iterate on child objects recommend create base class handles logic n...

iphone - Creating views on the fly from array -

i need create a bunch views on fly. wondering best way go doing ill need define coordinates, tag, colours of each view. would need create multidimensional array , if how can this? cgrect viewrect1 = { 80.0, 200.0, 160.0, 100.0 }; uiview *myview1 = [[uiview alloc] initwithframe:viewrect1]; [myview1 setbackgroundcolor:[uicolor darkgraycolor]]; you need define structure hold data needed create uiview . @interface myviewdataholder :nsobject { cgrect mviewrect; uicolor* mdarkgraycolor; nsinterger mtag; } @end then create object of above class , assign values in member add in nsarray ... edited: in myviewdataholder.h class @interface myviewdataholder :nsobject { cgrect mviewrect; uicolor* mdarkgraycolor; nsinteger mtag; } @property (nonatomic,assign) cgrect mviewrect; @property (nonatomic,retain) uicolor* mdarkgraycolor; @property (nonatomic,assign) nsinteger mtag; @end in myviewdataholder.mm class #import "myviewdataholder.h...

ajax - decoding with jquery .serialize() -

i all. posted yesterday question regarding dates not sent jquery-ajax , found solution .serialize() function. unfortunately serialize() function decodes date inputs , result this: arrival= 13%2f04%2f2011 &departure= 28%2f04%2f2011 &ap_id=2 i know how use decodeuricomponent() single fields post this: var arrivalval = $('#arrival').val(); arrivalval = decodeuricomponent(arrival); but how use long string made .serialize() function? sorry if seems pretty obvious question can't way around it. try that var editserialize = $('form#edit').serialize(); editserialize = decodeuricomponent(editserialize.replace(/%2f/g, " ")) ...