Posts

Showing posts from May, 2015

sql server - T-SQL IF statements in ORDER BY clauses -

is there way can like @sorttype select * table order -- if sorttype == id table.id -- else if sorttype == date table.date how syntax look? thanks. there's gotcha here... can't mix data types in case statement, need create different groups of case statements different data types. select * table order case when @sorttype = id table.id end asc, case when @sorttype != id table.date end asc related blog post: http://dirk.net/2006/11/14/dynamic-order-by-with-case-statement-in-sql-server-data-type-issues/

image - How to read the original alpha channel from PNG in J2ME? -

i'm writing simple j2me game uses png images 8-bit alpha channel. problem: not hardware supports full alpha transparency rendering. however, since game pretty static in nature (at beginning, "sprites" layed out onto background image, based on current screen size, , that's it), thought possible prerender transparent images directly onto background during game initialization , use later in game. can't prerender them in photoshop positions not known in advance. but, seems there no way read original alpha channel on devices not support semi-transparency gets resampled during png loading. there library can that? or idea store alpha channels separately (e.g. separate 8-bit png images) , manually apply them? thanks! png images have transparency support if want create transparent image have read rgb data along alpha channels , process alpha image transpng=image.createimage("/trans.png"); //load tranparent image int rgbdata[]; transpng.getrgb(

Fastest Way to Parse a Large File in Ruby -

i have simple text file ~150mb. code read each line, , if matches regexes, gets written output file. right now, takes long time iterate through of lines of file (several minutes) doing file.open(filename).each |line| # stuff end i know looping through lines of file taking while because if nothing data in "#do stuff", still takes long time. i know unix programs can parse large files instantly (like grep), wondering why ruby (mri 1.9) takes long read file, , there way make faster? file.readlines.each |line| #do stuff each line end will read whole file 1 array of lines. should lot faster, takes more memory.

html - Unnecessary lines appearing between image-links -

Image
i'm using 3 images side-by-side, , adding url.action each 1 of them. code works fine, images being displayed w/ sort of line between them. here code: <a href="@url.action("subcribe", new { id = item.id })"> <img src="images\subscribe.png" style="border:0" alt="subscribe" /> </a> <a href="@url.action("edit", new { id = item.id })"> <img src="images\edit.png" style="border:0" alt="edit" /> </a> <a href="@url.action("delete", new { id = item.id })"> <img src="images\delete.png" style="border:0" alt="delete" /> </a> edit - happening when tried alternate, non-url.action method: <a href="subcribe\@item.id"> <img src="images\subscribe.png" style="border:0" alt="subscribe" /> </a> here how images displa

c# - Regex to match full lines of text excluding crlf -

how regex pattern match each line of given text be? i'm trying ^(.+)$ includes crlf... i'm not sure mean "match each line of given text" means, can use character class exclude cr , lf characters: [^\r\n]+

visual studio 2010 - This beta version has expired -

Image
i developing monodroid application , seems working fine [i able run android project before] till 1 fine day , got error message while running android application vs2010. than downloaded monodroid installer here http://go-mono.com/monodroid-download/ , when tried run getting below error i confused. how resolve error? monodroid isn't free, need license it. sounds license expired.

c++ - How to get "server console" -

i write server application has read in of users commands still outputting new events during read in. should e.g. minecraft server console. tried things nothing worked , i'm out of ideas. check out http://www.amazon.com/pocket-socket-programming-kaufmann-practical/dp/1558606866 this great guide learning sockets. i start simple tcp listener example in book. you'll want server listen socket, read (parse) user commands, , respond accordingly. if you're not tied c++, can pretty darn perl/python/ruby or c#.

Entity Framework saving data in one-to-one associations -

i'm trying use foreign key association approach achieve one-to-one association in ef. in case there's association between user , team, , need navigation property in each of them. bumped problem when trying save data. this models like: public class team { public int id { get; set; } public string name { get; set; } public int ownerid { get; set; } public virtual user owner { get; set; } } public class user { public int id { get; set; } public string username { get; set; } public int teamid { get; set; } public virtual team team { get; set; } } i added these bits dbcontext onmodelcreating() , instructed in blog post referenced above: modelbuilder.entity<user>() .hasrequired(u => u.team) .withmany() .hasforeignkey(u => u.teamid); modelbuilder.entity<team>() .hasrequired(t => t.owner) .withmany() .hasforeignkey(t => t.ownerid) .willcascadeondelete(false); and when adding data this

java - How do I specify the adapter(s) which JAXB uses for marshaling/unmarshaling data? -

is there way specify adapter jaxb uses marshaling/unmarshaling objects in xml schema? for example, if want parse following integer: <specialvalue>0x1234</specialvalue> i can use following in schema: <xs:simpletype name="hexint"> <xs:annotation> <xs:appinfo> <jaxb:javatype name="int" parsemethod="integer.decode" /> </xs:appinfo> </xs:annotation> <xs:restriction base="xs:string"> <xs:pattern value="0x[0-9a-fa-f]+" /> </xs:restriction> </xs:simpletype> <xs:element name="specialvalue" type="hexint" /> when run schema through xjc tool, string "0x1234" should decoded using integer.decode() integer value 0x1234, or 4660 in decimal. adapter class generated reflects properly: public integer unmarshal(string value) { return (integer.decode(value)); } however, when

android - EditText hint disappears with gravity -

i have seen many similar questions 1 think still covers new ground: 1) hint text disappears when set gravity 2) android:ellipsize="start" fixes can have centered hints , centered text 3) why code below still show centered hint text? <edittext android:id="@+id/details" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:hint="use area provide specific identification information including approximate size, vessel name , registration numbers if available" android:background="@android:drawable/editbox_background" android:layout_below="@id/details_title" /> is because of fill_parent instead of wrap_content? thought maybe because hint multiline, shortened , still appeared , centered. differences between , other edittexts needed android:ellipsize="start" display correctly. bug? you need u

tomcat - How do I find what Java version Tomcat6 is using? -

is there os command find java version tomcat6 using? need use perl (including system()) command. i using linux. ubuntu , centos is there like? tomcat6 version at first need understand first, tomcat java application. so, see java version tomcat using, can find script file tomcat started, catalina.sh. inside file, below: catalina.sh:# java_home must point @ java development kit installation. catalina.sh:# defaults java_home if empty. catalina.sh: [ -n "$java_home" ] && java_home=`cygpath --unix "$java_home"` catalina.sh: java_home=`cygpath --absolute --windows "$java_home"` catalina.sh: echo "using java_home: $java_home" by default, java_home should empty, mean use default version of java, or can test with: echo $java_home and use "java -version" see version default java is. and vice versa setting property: java_home, can configure java version use when starti

jquery - Why am I getting this JS error? -

this error: uncaught syntaxerror: unexpected token illegal d.d.extend.globalevaljquery-1.5.1.min.js:16 d.ajaxsetup.converters.text scriptjquery-1.5.1.min.js:16 bqjquery-1.5.1.min.js:16 vjquery-1.5.1.min.js:16 d.support.ajax.d.ajaxtransport.send.c here jquery: $("div#notif_js").html(' '); $("div#notification_box").html('<div class="notification"> <p><img alt="justin meltzer" class="feed_image_notif" src="/system/photos/46/tiny/justin meltzer.jpeg?1303109121" /> jmeltz added comment <b>second</b> <img alt="justin meltzer" class="feed_image_notif" src="/system/photos/45/tiny/justin meltzer.jpeg?1303109101" /> justin meltzer</p> <a href="/videos/506"></a> </div> <div class="notification"> <p><img alt="justin meltzer" class="feed_image_notif" src="/sys

vb.net - New page per a group in crystal report -

Image
i'd show new page per group in crystal report. please check images below report design report review how set show 1 group box per page? in groupfootersection1, set property newpageafter always.

c# - How can I correctly unit test methods that depend on each other? -

consider code: private readonly dictionary<type, component> _components = new dictionary<type, component>(); public component [type type] { { component component; _components.trygetvalue(type, out component); return component; } } public void addcomponent(component component) { _components.add(component.gettype(), component); } as can see, addcomponent adds private _components variable. way test happening using indexer. that's fine, in order test indexer i'd have call addcomponent too! in other words, in unit tests indexer , addcomponent , each test have call both of these methods. seems creating unnecessary coupling. if there bug in indexer, there no reason testaddcomponent fail. what best practice here? use reflection @ _components ? mocking? else? well have 2 options: use reflection or mstest private accessor classes , set private field va

asp.net - onblur and clique button problem? -

i have probleme mytextbox , have button , textbox onblur , onfocus event works fine after type text , clique button onblur event handled wich error want save text not oblur message , s mean how can distinct between clique button , onblur event textbox when clique in page , textbox not empty (theres text) oblur event handled , dont know how manage event , should place them thanks i think we'd need see sample of code understand little more doing in order answer question. can post short segment demonstrate problem?

c - Cost of context switch between threads of same process, on Linux -

is there empirical data on cost of context switching between threads of same process on linux (x86 , x86_64, mainly, of interest)? i'm talking number of cycles or nanoseconds between last instruction 1 thread executes in userspace before getting put sleep voluntarily or involuntarily, , first instruction different thread of same process executes after waking on same cpu/core. i wrote quick test program performs rdtsc in 2 threads assigned same cpu/core, stores result in volatile variable, , compares sister thread's corresponding volatile variable. first time detects change in sister thread's value, prints difference, goes looping. i'm getting minimum/median counts of 8900/9600 cycles way on atom d510 cpu. procedure seem reasonable, , numbers seem believable? my goal estimate whether, on modern systems, thread-per-connection server model competitive or outperform select-type multiplexing. seems plausible in theory, transition performing io on fd x fd y involve

sockets - Consuming a web service on a .net smart device application -

i trying consume web service locally on .net smart device application , getting error:- system.net.sockets.socketexception: no connection made because target machine actively refused it any suggestions.. probable causes: your emulator not allow connection the server not responding a firewall prevents connection

opengl es 2.0 - iOS Simulator GL_OES_standard_derivatives -

on ios4 gl_oes_standard_derivatives supported on device (from see when output extensions), there way able to: detect in fragment shader if extension supported or not if not supported, have code dfdx , dfdy? can't seems find on google. tia! i had same issue antialiasing sdm fonts. can calculate similar dfdx/dfdx translating 2 2d vectors using current transform matrix : vec2 p1(0,0); vec2 p2(1,1); p1=transformusingcurrentmatrix(p1); p2=transformusingcurrentmatrix(p2); float magic=35; // you'll need play - it's linked screen size think :p float dfdx=(p2.x-p1.x)/magic; float dfdy=(p2.y-p1.y)/magic; then send dfdx/dfdy shader uniforms - , multiply parameter same functionality i.e. dfdx(myval) becomes dfdx*myval; dfdy(myval) dfdy*myval; fwidth(myval) abs(dfdx*myval)+abs(dfdy*myval);

java - Using Gson to unserialize an array of objects -

i have json response looks this. want extract values of "text" , put them set of strings (i.e. don't need entire json derialised). i using gson library so far method looks (it's wrong): public static response deserialise(string json){ gson gson = new gson(); response r = gson.fromjson(json, response.class); return r; } i calling deserialise this: response r = deserialise(json); system.out.println("[status]: "+r.getstatus()); // works fine collection<keyword> coll = r.getkeywords(); iterator<keyword> itr = coll.iterator(); while(itr.hasnext()){ system.out.println(itr.next().getword()); //prints null every time } response class following member variables (with getters , setters): private string status; private string usage; private string language; private collection<keyword> keywords; keyword class following member variables (with getters , setters): private string word; priva

wcf - prevent MVVM ServiceAgent event hooking up multiple times -

developing silverlight application communication wcf service. mvvm -> serviceagent -> wcf service so in viewmodel have: serviceagent.searchexternalpatients(name, (s, e) => { externalpatients = e.result; }); in service agent have: public void searchexternalpatients(string name, eventhandler<searchpatientexternalcompletedeventargs> callback) { _proxy.searchpatientexternalcompleted += callback; _proxy.searchpatientexternalasync(name); } the problem each time click on search button hooks event again, , when result receive several times. what best way unhook these events in mvvm serviceagent pattern? do way: public void searchexternalpatients(string name, eventhandler<searchpatientexternalcompletedeventargs> callback) { eventhandler<searchpatientexternalcompletedeventargs> wrapper = null; wrapper = (s, e) => {

.net - What is MSBuild and it's purpose -

possible duplicate: msbuild: it, , when need it? i never use msbuild , have no idea purpose of msbuild. nice if describe briefly in kind of situation people use msbuild. basically msbuild building project/solution. can use msbuild commandline prompt build project rather right click , build. msbuild useful when comes automated build servers build projects once checkin new code. another advantage of msbuild is, it's capable build project without having vs ide. don't need vs ide build project in automated build servers. below few sites provide information you. http://msdn2.microsoft.com/en-us/library/wea2sca5.aspx msdn msbuild documentation http://channel9.msdn.com/wiki/default.aspx/msbuild.homepage msbuild wikki http://msdn2.microsoft.com/en-us/library/0k6kkbsd.aspx msbuild reference http://blogs.msdn.com/msbuild/default.aspx msbuild team blog

appcelerator - Using Global Function in Titanium -

i making titanium mobile project want make 1 global function can use throughout application. have created other .js file have defined function , including .js file need use function , able call function. but question : can create new window in function? have added 1 label , 1 mapview in window not showing, while @ start of function have added alert('functioncalled') , showing me alert not showing me label have added in window. so can me find out whether can open window through function. if yes sample example, can find out mistake making. thanks, rakesh gondaliya you approach can work not best practice, should create global namespace, add function namespace , include file function once in app.js // apps.js var myapp = {}; ti.include('global.js','ui.js'); myapp.ui.openmainwindow(); then create seperate file our ui functions //ui.js (function(){ var ui = {}; ui.openmainwindow = function() { // open window stuff // call glo

Web application using JSP,servlets and Struts -

i'm developing web application using jsp,servlets , struts.it has many dynamic web pages in pages login , other user details getting pages used taglibrary tags bean files,but in more complex pages did'nt used taglib tags developed java coding directly ajax coding. question how , use appropriate taglibrary tags? how use ajax , java script codes library tags? idea desing web application? you design own tag when view repeatable , reuse view. you should import js files in jsp , in jsp add tags.

jquery - how to implement facebook phototheater kind of overlay? -

hi want jquery on lay works more facebook photo theater. want window scroll bars scroll overlay not page below. how can achieved? tried many jquery plugins none worked out.. it's called lightbox - search google lots of plugins work way. used pretty photo time ago , worked great.

flex - change applicationcontext from in code -

i have little problem. hope can me. i'm developping application thesis. have application-context.properties.txt define: host= (ip address) port=8080 now static , change ip address server want connect to. isn't verry usefull user because can't access file. now question can change host ip address in flex code? , how do that. hope can me. kind regards, thibault heylen usually configurations i.e services.xml embeds @ compile time, blog externalizing service configuration using blazeds , lcds pointed towards way externalizing service configuration, hopes works,

android - What's the difference between commit() and apply() in Shared Preference -

i using shared preference in android app. using both commit() , apply() method shared preference. when use avd 2.3 shows no error, when run code in avd 2.1, apply() method shows error. what's difference between these two? , using commit() can store preference value without problem? apply() added in 2.3, commits without returning boolean indicating success or failure. commit() returns true if save works, false otherwise. apply() added android dev team noticed no 1 took notice of return value, apply faster asynchronous. http://developer.android.com/reference/android/content/sharedpreferences.editor.html#apply()

Can we create windows service from Java? -

can create windows service java? want (possibly non-java) application run service , want configure within java program. also: can pass parameters services? also, please me deleting existing service , restarting on crash. this question not same running java program service other way round want create service using java program, on server side you need install software, right? advancedinstaller this.

java - How do I change the property of an enum with Spring? -

i need hide menu options in production environment, not in development. i implemented enum this: public enum functionality { function_1(true), function_2, function_3(true); private boolean usable; functionality() { this(false); } functionality(boolean usable) { this.usable = usable; } public boolean isusable() { return usable; } } and then, when need show menu options, check whether functionality needs shown. so need able change usable boolean when environment development. cannot find way in spring. do know of way this? you could change fields of enum , it's considered bad idea , design smell. a better approach possibly not have usable field @ all, instead make calculated property: public enum functionality { function_1(true), function_2, function_3(true); private final boolean restricted; functionality() { this(false); } functionality(boolean restr

c# - RPC error when reading excel sheet -

am getting error when trying read excel sheet remote server using excel interop in .net application. "the rpc server unavailable. (exception hresult: 0x800706ba)" when run app again, dont error.may know reason , how avoid it? thanks. hi getting same "weird" error, since i'm using excel interop (ns: microsoft.office.interop.excel) on local machine having highest privilegies (event on target file/folder). did chance reading multiple files using same excel app instance? if guess correct, try create new instance of excel each file need parse, of course close app when read completes.

iphone - NSNotification removeObserver problem -

i either brain damaged or lacking of understending of nsnotificationcenter the problem if create observer , in next line try delete so: [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(removeallvisiblemapviews) name:@"clearvisiblemaps" object:nil]; [[nsnotificationcenter defaultcenter] removeobserver:self forkeypath:@"clearvisiblemaps"]; i *** terminating app due uncaught exception 'nsrangeexception', reason: 'cannot remove observer <myapp 0x592db70> key path "clearvisiblemaps" <nsnotificationcenter 0x4e0fbb0> because not registered observer.' i add , remove observer line after line make point. in code using remove in dealloc. so ideas why tell me didn't add , observer in first place? you're removing observer keypath, not notification name. removal should this: [[nsnotificationcenter defaultcenter] removeobserver:self name

scala - Lift CRUD "list all" problem -

i'm trying follow this tutorial. i've got non empty db. table not propagated. tried debugging it: correct records returned toshow method, on each iteration of flatmap has correct, non-empty instance of item, result, method returns this: list(\n{16 spaces here},\n{16 spaces here}) . , table not propagated. updated code follows: listcar snippet: class listcar { def list(xhtml: nodeseq) : nodeseq = { toshow.flatmap(car => bind("car", xhtml, "name" -> car.name.is, "owner" -> car.owner.name ) ) } private def toshow = { car.findall(); } } list.xhtml: <table> <thead> <tr> <th>name</th> <th>owner</th> </tr> </thead> <tbody> <lift:list_car.list> <tr> <td> <car:name/> </td>

c# - I want to retrieve an Image from database and crop it as per the user needs -

i want crop photo retrieved database, have done following retrieve image database protected void page_load(object sender, eventargs e) { memorystream stream = new memorystream(); sqlconnection connection = new sqlconnection(@"data source=localhost;initial catalog=card;user id=sa;password=db2admin;"); try { connection.open(); sqlcommand command = new sqlcommand("select photo iffcar", connection); byte[] image = (byte[])command.executescalar(); stream.write(image, 0, image.length); bitmap bitmap = new bitmap(stream); response.contenttype = "image/gif"; bitmap.save(response.outputstream, imageformat.jpeg); } catch (exception ee) { connection.close(); stream.close(); httpcontext.current.response.write(ee.message); } } the image retrieved displayed inside browser. now stuck @ how crop image,i want allow user crop image retrieved database ,

cocoa touch - iPhone: Incrementing the application badge through a local notification -

is possible increment application badge through local notification while app not running? i know how set badge, haven't found way increment value. localnotification.applicationiconbadgenumber = 23; update: found (far being perfect) solution. can predict happen, if user doesn't open app , add notifications every +1 event. an example: for day 1: count = 0 for day 2: localnotification.applicationiconbadgenumber = 1; for day 3: localnotification.applicationiconbadgenumber = 2; for day 4: localnotification.applicationiconbadgenumber = 3; ==> put these notifications in array , set them before application exits. however, i'm searching better solution workaround. the way you're going able dynamically set badge number when application isn't running push notifications. you'll have track updates on server side.

internet explorer - Javascript code not displaying wanted output -

i've written code display favorites in ie8 unknown reason have no output on screen despite fact page accepted ie , test text 'this test' displayed. my code : <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso 8859-1" /> <script type="text/javascript"> var = 0; var favstring = ""; var fso; function getfavourites(folder) { var favfolder = fso.getfolder(folder); //gets favourite names & url's given folder. var files = new enumerator(favfolder.files); (; !files.atend(); files.movenext()) { var fil = files.item(); if (fil.type == "internet shortcut") { var textreader = fso.opentextfile(fil.path, 1, false, -2); var favtext = textreader.readall(); var start = favtext.indexof("url&q

Python Option Parser: Boolean flag with optional parameters -

i'm using optparse.optionparser manage arguments scripts, , wondering / have boolean flags (i.e action=store_true ) can accept parameter. to put context, i've got application can use many gpu/processors finds on machine. variety of reasons want limit number of devices uses, , instead of further cluttering command line, i'd able to: script -c -g meaning use can of cpus , gpus, , script -c 2 -g 3 meaning limit script execution 2 cpus , 3 gpus. after reading optparse documentation, i'm none wiser. oh great gurus! lend me wisdom! you can use callback action implement quite easily. in particular, example 6 in documentation of callback action of optionparser discusses variable number of arguments. here's telling quote example: things hairy when want option take variable number of arguments. case, must write callback, optparse doesn’t provide built-in capabilities it.

android - dialog not displayed properly if using different functions for both orientations -

well in oncreate method have defined different function both orientations using if (getresources().getconfiguration().orientation == configuration.orientation_portrait) { //some code }else { //some other code } , if 1 message displayed in portrait mode gives problem when changed landscape mode , vice-versa. can it??? you need make sure dismiss current dialog showing in ondestroy dismissdialog - if use showdialog , oncreatedialog methods android automatically assumes want dialog managed activity, means recreates old dialog when rotate.

sql - HQL query not working, Incorrect syntax near ',' error. Using Spring and Hibernate -

i trying execute following update query , getting error, query is= @transactional public list<order> getclosedorders(string userid) throws dataaccessexception { try { string sql_select_query = "from order o o.orderstatus='closed' , o.account.profile.userid='"+userid+"'"; string sql_update_query = "update order set orderstatus=completed orderstatus=closed , account.profile.userid='"+userid+"'"; list<order> orderlist = (list<order>) list(sql_select_query); if(!orderlist.isempty()) { batchupdate(sql_update_query); return orderlist; } return null; } catch(exception ex) { ex.printstacktrace(); throw new dataaccessexception(errormessage); } } however select query working update query giving following error: warn [http-8080-2] (jdbcexceptionreporter.java:71) - sql error: 102, sqlstate: s0001 error [http-8080-2] (jdbcexceptionreporter.java:72) - incorrect syntax near ',

sql - MySQL full inner join -

i have select clientreport.id clientreport left join report02 on (report02.id = clientreport.id) report02.id null; that equivalent of select clientreport.id clientreport.rownumber not exists ( select clientreport.rownumber report02, clientreport report02.id=clientreport.id); i need, presumably, full inner join mismatches in report02, not clientreport. how write join this? the below should work. select clientreport.id,report02.id clientreport full outer join report02 on (report02.id = clientreport.id) report02.id null or clientreport.id null; it should doesn't (as mysql not support full outer join .) this more work: ( select clientreport.id report01 , report02.id report02 clientreport left outer join report02 on (report02.id = clientreport.id) report02.id null ) union ( select clientreport.id report01 , report02.id report02 clientreport right outer join report02 on (report02.id = clientreport.id) cl

iphone - Application constants used at compilation time -

i have many constants in application used many classes of project. these constants have set @ compilation time (they not modified later). now, use #define statements @ top of each classe requires constant. problem have repeat these statement in each classe requires constant. i plan define these constants in main.m or in .h imported main.m think not idea. -> there xcode / ios mechanic or file made purpose ? -> if not, idea define constants in main. ? thanks help kheraud you can write constants in .h file , can import file in projectname_prefix.pch file . then don't need import file in other source file . directly imported .

How to open infopath templates in code and change data connections URL -

i need iterate through infopath templates (xsn files) , change url of data connections, , save changes templates. the data connections want change, points lists in sharepoint environment. so, how accomplish task? i thinking doing console application. infopath doesn't make easy deploy different servers. have used powershell script can use console app or scripting language. steps follow: 1. extract files xsn (either use extrac32 util ms or rename zip , use zip library) 2. change data connection (string replace) in manifest.xsf, template.xml, , sampledata.xml 3. repackage files xsn (either use cabarc util ms or zip , rename) it pain have entire script less page long , runs pretty fast. 1 caveat ran needed delay between steps 1 , 2 - files weren't finished extracting , script trying change them.

c++ - Odd(?) behaviour of a temporary std::ostringstream -

i messing around std::ostringstream whilst looking @ question: sprintf in c++? , , noticed stringbuilder() wrapper nawaz , thought, ought work std::ostringstream . so first attempt following: std::cout << (std::ostringstream("select * foo limit") << max_limit).str() << std::endl; now fails compile (correctly) result of operator<< std::ostream - doesn't have member str() . thought cast should trick, , cast const reference (works cast normal reference too), second attempt: std::cout << static_cast<std::ostringstream const&>(std::ostringstream("select * foo limit") << max_limit).str() << std::endl; now compiles fine , runs, output is, well, not expecting. 10lect * foo limit now - here's question, invoking undefined behaviour somewhere - , if where? , how different approach nawaz has taken (i guess aside result of operator stringbuilder rather std::ostream ). edit: here ideone code

sql - Store XAML to DB -

i'm working on designing workflow , output xaml file, need store file in sql database .. how can that? think suitable extension convert to? i used google find this . pro tip - google search engine. can use search engines find things.

ide - Xcode 4: cannot refactor projects located in /Developer -

Image
i've upgrade xcode 4 , genuinely hoping new version might put xcode on more equal footing other ides eclipse , intellij, it's looking increasingly apple still way behind. i looking forwarding new refactoring options. can't use @ all! whenever try refactor lovely dialog saying refactoring not supported projects located in /developer. i keep dev projects in /developer. dialog suggests copy project location enable refactoring, extremely loathe because of pain of broken file references follow (yet 1 of xcode's major detractions). is there way around this? need able refactor. don't want copy project out of /developer. can do? thanks. don't keep projects in /developer. that's owned xcode, , if you're not careful might end deleting when install update. make own directory code, , work. you mentioned don't want move projects because fear broken file references. in cases, shouldn't problem, file references default relative. you'

ios4 - Setting the UILabel text from one UIControllverView to another UIControllerView before pushing it on navigation controller -

this trying do. myviewcontroller *viewcontroller = [[myviewcontroller alloc] initwithnibname:@"myviewcontroller" bundle:nil]; uilabel *lbltempstoreno = [[uilabel alloc] init]; [lbltempstoreno settext:@"1234"]; viewcontroller.lblstoreno = lbltempstoreno; [activerouteticketlistview setlblstoreno:lbltempstoreno]; [[self navigationcontroller] pushviewcontroller:viewcontroller animated:yes]; [lbltempstoreno release]; [viewcontroller release]; basically setting label in view controller push on navigation controller, value of label not changing :@. wondering if possible? you changing label, , not text of label. shouldn't code be: viewcontroller.lblstoreno.text = @"1234"; ?

linq - IQueryable to IQuerable<T> -

is possibile convert iqueryable object iqueryable t mapped entity? (t poco class). thanks in advance. just cast<t>() it. assuming queryable of same type. otherwise use oftype<t>() filtering method filter out items of type. iqueryable query = ...; iqueryable<mytype> x = query.cast<mytype>(); // assuming queryable of `mytype` objects iqueryable<myderivedtype> y = query.oftype<myderivedtype>(); // filter out objects derived `mytype` (`myderivedtype`) however in case, using dynamic linq , doing dynamic projection. consider made query: var query = dc.sometable .where("someproperty = \"foo\"") .select("new (someproperty, anotherproperty)"); it results in query of type iqueryable . cannot cast query of specific type iqueryable<t> after all, t ? dynamic linq library creates type derives dynamiccass . cast iqueryable<dynamicclass> ( query.cast<dynamicc

javascript - functionality changes after inserting text to textarea -

my questions arises this topic . i'm stumped , have been trying hours. this fiddle shows text inserted textarea when 1 of options chosen. by typing words in textarea text of textarea not change when choose option. that's ok. when delete words whole functionality lost somehow. if helps understand mean , want i'll write small 'testplan' because i'm absolutely stumped: open the fiddle type 'a' after 'text' in textarea. select option 2 ->'texta' stays in textarea now delete 'texta' select option1 -> can see textarea stays empty though selected option 1 how can prevent behaviour? added words textarea shall stay time. if thereis no addition, behavior shall not change. have got idea? html() wrong way set contents of textarea. use val() instead. the reason textarea gets initial value text contained between start , end tags. current value stored in value property. changing textarea's child node

Jquery datetimepicker - Advance time by 1 hour -

i'm using jquery datetimepicker add-on here it works perfectly, i'm stumped on how add small bit of functionality it. have 2 instances on page, 1 start-time , 1 end-time. when choose start-time, i'd automatically fill in end-time start time + 1 hour. can accomplished without extending core script @ all? the following add 1 hour end-time datepicker. $('#dtstartdate').datetimepicker({ onselect: function(){ var startdate = $('#dtstartdate').datetimepicker('getdate')); var enddate = new date(parsefloat(startdate.sethours(startdate.gethours()+1))) //get ending date datepart var enddatedatepart = enddate.getfullyear() + '/' + enddate.getmonth() + '/' + enddate.getdate(); //calculate ending date time part including am/pm var enddatetimepart; if (enddate.gethours() > 12) { enddatetimepart = enddate.gethours()-12 + ':' + enddate.getminutes() + ' pm';}

Can we use Linq for geting value from collection object in java? -

now days working on blackberry within parse json array string , convert hashtable this this json string [ { "stdid":"a1", "rollno":"23", "class":"first" }, { "stdid":"a2", "rollno":"13", "class":"first" }, { "stdid":"a3", "rollno":"53", "class":"second" }, { "stdid":"a4", "rollno":"33", "class":"third" }, ] and parse hashtable as hashtable t1=new hashtable(); t1.put("stdid","a1"); t1.put("rollno","23"); t1.put("class","first"); hashtable t2=new hashtable(); t2.put("stdid","a2"); t2.put("rollno","13"); t2.put("class","first"); hashtable t3=new hashtable(); t3.put

c# - How can I convert a generic List<T> to a List? -

how can convert generic list list? i using listcollectionview , need provide ilist not ilist<t> . i see plenty of examples convert ilist ilist<t> , not other way. do convert manually ( new list().addrange(ilist<t> )? as list<t> implements ilist interface, can provide list<t> . if needed, cast it: list<int> list = new list<int>(); ilist ilist = (ilist)list;

java - Getting Stale Connection using OracleDataSource with OCI driver -

i getting stale connection error when there no requests database java application couple of hours. its simple java application runned on linux box oci (type driver). dont ask me why oci, why not thin. using oracledatasource , oracleconnectioncachemanager maintaining cache of connection objects. here code snippet: import java.sql.connection; import java.sql.sqlexception; import java.util.properties; import oracle.jdbc.pool.oracleconnectioncachemanager; import oracle.jdbc.pool.oracledatasource; import org.apache.log4j.logger; import com.exception.dataexception; public class connectionmanager { private static oracledatasource pooldatasource = null; private final static string cache_name = "connection_pool_cache"; private static oracleconnectioncachemanager occm = null; public static void init(string url,string userid,string password) throws pctdataexception{ properties cacheprops = null; try { pooldatasource = new oracledatasource(); pooldatasource.

php - Auto Authorize Twitter Web App -

i using oauth create way users of our website login using twitter account. however, it's quite annoying everytime click sign in twitter account have grant access each , every time. couldn't work if has been granted once don't have keep granting access? therefore removing step. i'm using steps found in: http://net.tutsplus.com/tutorials/php/how-to-authenticate-users-with-twitter-oauth/ thanks feedback! i found answer after talking developers on twitterapi irc bascially going https://twitter.com/oauth/authorize oauth, need go https://twitter.com/oauth/authenticate instead. gives forever authorization.

Intellij IDEA 9: How can I disable the inspection error when using a 'with' clause in HQL? -

how resolve intellij v9 inspection error of 'where, group by, having or order expected' on following hql string: select obja inner join a.column b with b.variable=:bvar a.variable=:avar it's not inspection, result of code parsing. solution disable particular language injection in settings.

mysql - Select day of week from date -

i have following table in mysql records event counts of stuff happening each day event_date event_count 2011-05-03 21 2011-05-04 12 2011-05-05 12 i want able query efficiently date range , day of week. example - "what event_count on tuesdays in may?" currently event_date field date type. there functions in mysql let me query column day of week, or should add column table store day of week? the table hold hundreds of thousands of rows, given choice i'll choose efficient solution (as opposed simple). use dayofweek in query, like: select * mytable month(event_date) = 5 , dayofweek(event_date) = 7; this find info saturdays in may. to fastest reads store denormalized field day of week (and whatever else need). way can index columns , avoid full table scans. just try above first see if suits needs , if doesn't, add columns , store data on write. watch out update anomalies (make sure update day_of_week column if change event_dat

web services - Java Jax-WS client and PHP Server -

i try access simple php server class java client via soap wsdl file. error. searched lot in search engines , altered here , there. unfortunately no success. i'm using eclipse java , xampp local server. changed well-functioning wsdl file this (java client , java server) webservice. the error message following: exception in thread "main" com.sun.xml.internal.ws.protocol.soap.messagecreationexception: couldn't create soap message due exception: xml reader error: javax.xml.stream.xmlstreamexception: parseerror @ [row,col]:[1,1] message: content not allowed in prolog. @ com.sun.xml.internal.ws.encoding.soapbindingcodec.decode(unknown source) @ com.sun.xml.internal.ws.transport.http.client.httptransportpipe.process(unknown source) @ com.sun.xml.internal.ws.transport.http.client.httptransportpipe.processrequest(unknown source) @ com.sun.xml.internal.ws.transport.deferredtransportpipe.processrequest(unknown source) @ com.sun.xml.internal.ws.api.

jQuery + PHP getting AJAX data -

whats best way pass data jquery ajax method via php. , constructing query based of can loaded via ajax , displayed on page. ex: clicking viewer.php?note_id=2 modular window show , ajax data in regards note_id 2 viewer.php out going viewer.php directly. the problem using list of notes on page , separated li tags. so best way go around this? , assure correct note_id passed notes href link? php code selects db need fix since seems not follow desc limit 12 syntaxes $q_asl32 = mysql_query("select * notice order nid desc limit 12"); $r_asl32 = mysql_fetch_array($q_asl32); $nid = $r_asl32['nid']; $note = $r_asl32['note']; $type = $r_asl32['type']; $private = $r_asl32['private']; $date = $r_asl32['date']; $author = $r_asl32['author']; part 2 of same php code create notes list mysql data echo ' <li> <p> <a href="viewer.php?nid='.$nid.'" id="re

csv - VBScript Error 80040E14 Syntax error in FROM clause -

i'm trying use script found on internet allow bulk creation of new user accounts in active directory using vbscript , csv file. i'm not using csvde b/c script create passwords. keep encountering error when running code cannot figure out. can help? '********************************************************************* ' script: createusersfromcsv.vbs * ' creates new user accounts in active directory csv file. * ' input: csv file layout logonname,firstname,lastname,password * ' * '********************************************************************* option explicit dim scsvfilelocation dim scsvfile dim oconnection dim orecordset dim onewuser ' variables needed ldap connection dim orootldap dim ocontainer ' holding variables information import csv file dim slogon dim sfirstname dim slastname dim sdisplayname dim spassword dim npwdlas

c# - How to add x-webkit-speech tag to ASP: TextBox -

i add x-webkit-speech attribute input boxes on asp.net site. how add attribute x-webkit-speech <input id="uxtextinput" value="" x-webkit-speech> uxtextinput.attributes.add("x-webkit-speech", "x-webkit-speech"); web-kit should recognize that

cakephp - sort on array read -

in controller have var $uses = array('user','customer'); then using read call users $loggedoutcustomer = $this->user->read(null, $this->auth->user('id')); this gives me users , cutsomers can use want sort on customers name. how can in cake? you can set default order in user model. if customer belongsto user, user hasmany customer. in user model, under hasmany variable, find customer record , add customer.name order array key. also, please remove cakephp version tag not using. you can add sorting options when you're using find() method of model. this can defined in pagination array another option use containable behavior

security - What technologies would you recommend for secure client GUI application? -

i've got big project ahead of me, it's going online, kind of hazard game, poker. problem is, i'm not sure best way approach client side. because game involve real money, security going big issue. server side, don't think make lot of difference choose, since communication encrypted, i'm more worried client. from experience working java, there quite few decompilers, , bytecode isn't hard crack (am wrong here). since game require 2d graphics, i'd work technology makes gui development @ least little bit smooth. my other thought flash, since haven't seen many online casinos use flash, might little bit more vulnerable java/.net? what i'm trying ask here is, technology recommend develop secure, client side gui application fancy 2d graphics? in opinion, there no such thing secure client. no matter do, decompile/reverse engineer it-- when there real money involved. if you, i'd concentrate on making server secure. assume every cli

mysql - Select based on numeric difference -

i have database table holds order information , saves current gold price (world price) automatically @ time of entry. if on table, , saved gold price has difference current gold price of +100, o want show in report. how write mysql query this? know how datediffs not numeric values. example: select * table saved_price < current_price - 100 is there better way this? use abs if sign of difference doesn't matter: select * table abs(saved_price - current_price) > 100 if sign interesting, suggested approach fine. i'd write this, use way think read- , understandable: select * table (current_price - saved_price) >= 100

c++ - How to SWIG in VS2010? -

Image
hey everybody, i'm trying swig multi file project made in vs2010 (c++) python. i've managed link python26.lib file, , have swig generating wrapper .cpp file main .cpp file. i've set code build .dll extension .pyd. this .i file have currently: %module hivegps %{ #include "ou_thread.h" #include "hivegps.h" %} %include ou_thread.h %include hivegps.h and i've mangaed .py , .pyc file. now, understanding in order run .py file, need link .pyd file, when try use vs2010 build project settings listed above, complains thread class i'm using: 1>------ build started: project: hivegps, configuration: release win32 ------ 1>build started 5/11/2011 1:41:30 pm. 1>initializebuildstatus: 1> touching "release\hivegps.unsuccessfulbuild". 1>clcompile: 1> hivegps_wrap.cpp 1>c:\users\*\desktop\hivegps\hivegps\ou_thread.h(57): error c2146: syntax error : missing ';' before identifier 'm_strname' 1>c:\