Posts

Showing posts from July, 2014

wcf - "Best" way to communicate between .NET 1.1 and .NET 3.5 -

by best mean: cheapest development cost (1.1 project unlikely live > 6 months) easiest migration wcf or similar by communicate between mean: remote communication between computers most no firewall restrictions with .net 1.1 options appear be: sockets, remoting, , various flavours of web service. the option of using binary serialized datatables on sockets has been proposed solution wary of this. update: "server" in case windows embedded standard .net 1.1. @ stage unable add new components image such iis, asp, or msmq etc. take consideration since migrating wcf, may want consider building wcf service immediately, using basichttpbinding, supports old asmx style web-services, i.e. ws-basicprofile 1.1. able consume service .net 1.1 application. you can consider using msmqintegrationbinding in wcf, .net 1.1 application post/receive messages msmq. you may want check out following related articles: asmx client wcf service consume wcf basichtt...

Android - How to regenerate R class? -

possible duplicate: developing android in eclipse: r.java not generating i have imported project eclipse ide, it's giving me error since r file not generated automatically. how can edit r file matches project requirements? in another stackoverflow question , answered : must rid of warnings , errors (syntax , links) in xml files. plus doing clean / build project. project -> clean, , choose option build project.

.net - Entity Framework 4.0: is it worthy now? -

i've read lot complains entity framework in .net 3.5 sp1, ineffectively generated sql. complains had prevented me studying entity framework. now entity framework 4.0 has come out, provide lot of promises. wonder if it's orm now, or still not yet? worth learn , use in .net projects, instead of traditional sql queries? have planned switch ef 4.0 yet? thanks in advance. one word: yes!! entity framework 4.0 contains huge number of additions , improvements, , additional templates poco's , self-tracking entities, it's ready prime time now. if want to, can go far define entire ef "model" in code - no *.edmx file @ - looks , feels lot fluent nhibernate. have lots of options ef4 - , that's thing, , sign ado.net team did listen community (and work hard make things lot better now). in addition julie lerman's book , blog, should check out ado.net ef4 team blog - contains useful , helpful hints , tips. this blog post in particular might ...

zend framework - Zend_Controller_Router_Route_Hostname with additional variable -

i'm having problem chaining routes using variable @ end. i'm using wild card sub domains. this: http://eric.mysite.dev/mypage1 mypage1 going variable. want http://mysite.dev/donate/now/index/id/eric/pagename/mypage1 i have working fine without pagename this: $router=$fc->getrouter(); // host routes $accounthostroute = new zend_controller_router_route_hostname(':urlname.mysite.dev', array('module' => 'donate', 'controller' => 'now', 'action' => 'index'), array('urlname'=>'(?!www$).*') ); // account routes $router->addroute('donatewithhostnamelocal', $accounthostroute->chain( new zend_controller_router_route_hostname( ':urlname.mysite.dev', array( 'module' => 'donate', 'controller' => 'now', 'act...

distribution - Distributing my Windows Mobile app outside of marketplace? -

hello friendly windows mobile developers! i have simple question: can distribute windows mobile app outside of marketplace? if so, how done? can phone send app, have developed self, person in same room? i aiming windows mobile version 6.5, though if 1 has input on grateful. thanks in advance! yes. you can make cab file (which how mobile applications deployed) creating mobile app deployment project in visual studio. link describes that: http://msdn.microsoft.com/en-us/library/zcebx8f8.aspx then, can deploy output of project. 1 popular way create desktop installation project installs cab file device. link describes how custom action installer project again using visual studio: http://msdn.microsoft.com/en-us/library/bb158529.aspx

javascript - Select-box control with jquery -

i using selectbox: <select name="priority" id="priority"> <option value="4">low</option> <option value="3" selected="selected">normal</option> <option value="2">high</option> <option value="1">emergency</option> </select> when user select "emergency", confirmation box opens , if user confirm, "emergency" selected. otherwise "normal" should selected. this, using jquery: $(document).ready(function() { $('#priority').change(function(){ if($(this).val()=='1'){ if(confirm("are sure emergency?")){ return true; } else{ //here code needed select "normal". } } }); }); now, how can that? since you're returning in confirmation case, can shorten logic down this: ...

c - Determining CPU utilization -

is there command or other way current or average cpu utilization (for multi-processor environment) in linux? i using embedded linux in small system. basically, need determine cpu utilization, if high, can instead divert new process controller in system, rather executing on main processor, busy doing more important process. this question not merely prioritizing processes, other controller can sufficiently handle new process, when main processor not busy, prefer execution. you need sample values in /proc/stat @ 2 times, , calculate average utilisation on time. (instantaneous utilisation doesn't make whole lot of sense - it'll 100% on single core machine, since utilsation-measuring code running whenever looks).

Web colors in an Android color xml resource file -

what of x11/w3c color codes in format of android xml resource file? i know looks tad ridiculous question, given votes apparently it's useful , since does not require off-site resource i'm reformatting keep around. --editor. you have surely made own now, benefit of others, please find w3c , x11 below. <?xml version="1.0" encoding="utf-8"?> <resources> <color name="white">#ffffff</color> <color name="yellow">#ffff00</color> <color name="fuchsia">#ff00ff</color> <color name="red">#ff0000</color> <color name="silver">#c0c0c0</color> <color name="gray">#808080</color> <color name="olive">#808000</color> <color name="purple">#800080</color> <color name="maroon">#800000</color> <color name="aqua">#00ffff</col...

sql - Catching Error Message from XP_CMDSHELL -

i running following command: exec @returncode = master.dbo.xp_cmdshell @cmdline on results tab 2 lines not find part of path '\server\directory\filename'. null how capture first line in error message? tried using try catch block "select @errormessage = error_message()" , doesn't grab it. the message not coming sys.messages. error message coming then? the error comes command shell itself, not sql server error one way grab error is declare @cmdline varchar(500),@returncode int select @cmdline = 'dir f:' create table #temp (somecol varchar(500)) insert #temp exec @returncode = master.dbo.xp_cmdshell @cmdline if @returncode <> 0 select * #temp somecol not null but of course if dir c: table filled files , folders command

WPF Application - add dock behavior when drag to end of screen -

i'm working on wpf application, able have user drag main window, , dock when approaches end of screen. is there way this? here's similar thing implemented attachedbehaviors: http://codeblitz.wordpress.com/2009/07/07/wpf-window-dock-behavior/ i'm not sure how production-ready though.

tomcat - How to send servlet response to web.xml configured error page -

i using tomcat. defined <error-page> in web.xml , mapped 404 error page /error/error.jsp . need detect if resource exist , set response status 404 if resource not available. response.setstatus(404); but tomcat not redirect 404 page defined, question is, there api page location defined in web.xml ? don't want parse web.xml myself. just use httpservletresponse#senderror() status code . e.g. file resource = new file(path, name); if (!resource.exists()) { response.senderror(httpservletresponse.sc_not_found); // sends 404. return; } the servletcontainer display suitable errorpage. note: return statement isn't there decoration. avoid remant of code in same method block continue run , might produce illegalstateexception s in appserver logs! starters namely think methods sendredirect() , forward() , senderror() , etc somehow automagically exits method block when invoked. not true ;)

Getting Errors and Warning to show In Eclipse via Maven -

i'm using m2eclipse plugin eclipse build project, miss having errors , warning of build show in problems tab. use maven project builder build project , don't use default java builder in eclipse. love way errors , warnings can see when editing file show in problems tab, , tab show problems whole project. is there way this? you doing wrong. per default, m2eclipse activates java builder , shows errors / warnings. did chance check out multi-module maven project , convert single eclipse project? if yes, need import -> existing maven projects , select projects underneath root. otherwise, may have right-click project , select maven -> update project configuration . if neither of these help, please provide more info.

c# - Alligning Text Boxes in Silverlight -

can 1 tell me how allign text boxes in silverlight using c# .in application 2 textboxes getting overlapped . using grid place them in stackpanel . <stackpanel> <textbox width="120"> <textbox width="120"> </stackpanel> produces 2 text boxes 1 above other. another option use second grid 2 rows or 2 columns , place text box in each, allows share out available space of cell in provided outer grid.

javascript - Is there a way to Show/Hide elements without CSS? -

i making 1 web ui 508 compliant , 1 requirement states "working web ui when css disabled". have several places show/hide elements using style=display:inline , style=display:none , calling them accordingly using js function calls. when disable css (using wat2.0), hidden elements being shown not make ui good. have these kind of things in several places collapsed/expanded descriptions, popups on mousemove etc., is there other way show/hide elements other using style tags? please advice! this sounds cumbersome, could build simple library removes nodes dom , inject them when they're needed. still have object saves removed nodes variables, don't have recreate them when inserting. i must say, though, when requirements specify site should work css disabled, means it's supposed function exactly same way in respects css disabled. if you've got expand-/collapsible list, instance, i'd assume acceptable compromise css disabled show content of items...

nntp - L&H_Reader news reader? What's this? -

a message source shows user-agent: l&h_reader what news reader this? lernout & hauspie producer of speech synthesis software. can't find product named "reader" on website, guessing screen reader of sort reads contents of web pages aloud.

After insert trigger - SQL Server 2008 -

i have data coming in datastage being put in our sql server 2008 database in table: stg_table_outside_data . ourside source putting data table every morning. want move data stg_table_outside_data table_outside_data keep multiple days worth of data. i created stored procedure inserts data stg_table_outside_data table_outside_data , truncates stg_table_outside_data . outside datastage process outside of control, have within sql server 2008. had planned on using simple after insert statement, datastage doing commit after every 100,000 rows. trigger run after first commit , cause deadlock error come datastage process. is there way set after insert wait 30 minutes make sure there wasn't new commit within time frame? there better solution problem? goal data out of staging table , working table without duplications , truncate staging table next morning's load. i appreciate time , help. one way take advantage of new merge statement in sql server 2008 (see...

internet explorer - IE wrong paragraph using CSS float layout -

i learning xhtml , css , got trouble. on learning page using css float layout. have floted:left side menu, , render text content section have set margin exact same size left menu. problem is, text in paragraph wrongly shifted place side munu ends. happens in ie 8, ok in chrome. please help. this site.... either increase padding-left of content, or increase margin-left. either of make work better in ie. the reason happens ie6 , ie7 poor job in defining widths of block level elements. they're 20px off.

events - Creating a click handler for the View in Android -

i'm writing simple android application showing various shapes on main view: public class figures extends activity { demoview demoview; int figure_type = 1; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); demoview = new demoview(this); setcontentview(demoview); } @override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.firstmenu, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { switch(item.getitemid()) { case r.id.color_menu_item: break; case r.id.circle_menu_item: figure_type = 0; break; case r.id.square_menu_item: figure_type = 1; break; case r.id.triangle_menu_item: figure_type...

import all data variables from a php file without rendering it -

i want import data variables php file. if write: include 'user.php'; it loads php file instead of current file. solutions? ob_start(); include 'user.php'; ob_end_clean(); // use variable defined in user.php

c++ - Bitwise Manipulation or Bitwise Programming -

i know concepts of bit-wise operators, bit manipulation, 2's complement etc. when comes solving using bit manipulation not strike me. takes me time wrap head around them. i thought if looked @ questions regarding bit operators/bit manipulation left me more confused how approach topic. not looking answer specific problem generalized approach / mindset while tackling bit manipulation. thanks. answers given far near useful. link given naveen helped me bit. quite lot of examples given here. trying learn them. maybe it'll others. bit hacks update: have been going through examples given in link above. good. stumbled on - resource bitwise programming link in so. excellent resource. after going through resources feel bitwise programming easy! never thought use in sentence :)

How do I programatically stop java.util.logging? -

i'd know how programatically turn off java logging - no property files, no command line arguments etc. i've tried: final properties logproperties = new properties(); logproperties.put("handlers", "java.util.logging.memoryhandler"); logproperties.put(".level", "severe"); logproperties.put("java.util.logging.consolehandler.level", "severe"); final bytearrayoutputstream bytes = new bytearrayoutputstream(); logproperties.store(bytes, applicationname); new string(bytes.tobytearray()); logmanager.getlogmanager().readconfiguration(new bytearrayinputstream(bytes.tobytearray())); but third party library (flying saucer) continues log messages regardless of do. it doesn't matter in production, annoying in ide these console messages on show. (at future point, shall redirect logging framework...) system.setproperty("show-config", "off"); system.setproperty("xr.util-logging.plumbin...

c++ - Linking error: Undefined Symbols, lots of them (cpp cross compiling) -

i last linking command (the actual executable being linked) bunch of undefined symbols (and they're in cpp , scary me, simple c programmer) --its simple cant im supposed put linker (its using gcc here...? appropriate? g++ told me many input files lol) (ld returns of same) anyway ridiculous, stuck thankyou help! make making in docs making in en make[2]: nothing done `all'. make[2]: nothing done `all-am'. /developer/platforms/iphoneos.platform/developer/usr/bin/gcc-4.0 -arch armv6 -pipe -std=c99 -wno-trigraphs -fpascal-strings -fasm-blocks -wreturn-type -wunused-variable -fmessage-length=0 -fvisibility=hidden -miphoneos-version-min=2.0 -gdwarf-2 -mthumb -miphoneos-version-min=2.0 -i../include -isysroot /developer/platforms/iphoneos.platform/developer/sdks/iphoneos2.2.sdk -o0 -arch armv6 -pipe -std=c99 -gdwarf-2 -mthumb -i../include -l../libs -l../../libs -isysroot /developer/platforms/iphoneos.platform/developer/sdks/iphoneos2.0.sdk -l/developer/platforms/iphon...

javascript - Create a notification popup animated in a specific way? -

Image
how go making following animation form submissions? (i figured instead of typing it, create visual.) here's andy's idea refined horizontal centering. html: <form><div id="message"></div> <input> label 1<br/><br/> <input> label 2<br/><br> <textarea>larger text area</textarea><br/><br/> <textarea>and another</textarea><br/><br/> <button type="button">submit</button> ​ css: form { position:relative; width:500px;} #message { position:absolute; display:none; height:100px; width:200px; border: 1px gray solid; background-color:lime; font-size: 1.4em; line-height:100px; text-align:center; border-radius: 5px; bottom: 100px;} ​ centering function: (function($) { $.fn.extend({ center: function() { return this.each(function() { var left = ($(window)...

Attach event to results of a JQuery $.get call -

i getting list of checkboxes $.get call in jquery. there anyway can attach onclick function each of these checkboxes within parent page. e.g. parent page contain following code (maybe errors have wrote off top of head , not tested it) $(document).ready(function(){ $(":checkbox").click(function(){ //do stuff } $.get('some-url.html', function(data){ $('checkbox-holder').html(data); }); } therefore results returned 'some-url.html' automatically have onclick event thanks using $.live() set information cause dynamically-loaded elements act in same manner. set once @ top of script, , rest of work. don't need reference when ajax requests or anything. $(":checkbox").live("click", function(){ // want them do? });

c# - Dynamically crop a BitmapImage object -

i have bitmapimage object contains image of 600 x 400 dimensions. c# code behind, need create 2 new bitmapimage objects, obja , objb of dimensions 600 x 200 each such obja contains upper half cropped image , objb contains lower half cropped image of original image. bitmapsource tophalf = new croppedbitmap(sourcebitmap, toprect); bitmapsource bottomhalf = new croppedbitmap(sourcebitmap, bottomrect); the result not bitmapimage , it's still valid imagesource , should ok if want display it. edit: there way it, it's pretty ugly... need create image control original image, , use writeablebitmap.render method render it. image imagecontrol = new image(); imagecontrol.source = originalimage; // required because image control not part of visual tree (see doc) size size = new size(originalimage.pixelwidth, originalimage.pixelheight); imagecontrol.measure(size); rect rect = new rect(new point(0, 0), size); imagecontrol.arrange(ref rect); writeablebitmap tophalf = n...

javascript - How to rewrite the code using jQuery -

how rewrite code using jquery? <script type="text/javascript"> window.onload = function(){ var array = document.getelementsbytagname('div'); (var i=0; i<array.length; i++) { (function(i) { array[i].onclick = function() { alert(i); } })(i); } }; </script> <div>0</div> <div>1</div> thanks... if want alert index: example: http://jsfiddle.net/ksyr6/ // wrapping code in anonymous function passed parameter // jquery ensure not run until dom ready. // shortcut jquery's .ready() method $(function() { $('div').each(function( ) { $(this).click(function() { alert( ); }); }); }); this finds elements tag name 'div' , , iterates on them, individually assigning click event alerts index. or if index not important, becomes simpler: ...

c# - Problem in ComAutomationFactory.CreateObject -

i tried create object using comautomationfactory.createobject . giving following exception "failed create object instance specified progid" my application running on oob , has elevated permission. if (comautomationfactory.isavailable && app.current.haselevatedpermissions) { dynamic sample = comautomationfactory.createobject("samplecom.comclass"); } where samplecom com application created in c# i use silverlight 4 only if dll signed can create object using comautomationfactory.createobject

lambda - C# Extension methods on "members" -

i have extension methods used this: mytype myobject; string displayname = myobject.getdisplayname(x => x.property); the problem here needs instance, if extension method needs type mytype . if there no instance, needs called this: string displayname = blahblahutility.getdisplayname((mytpe x) => x.property); which not nice anymore. is there way write better syntax such cases? what want (pseudo language): string displayname = mytype.property.getdisplayname() which of course not work c#. but this: string displayname = ((mytype x) => x.property).getdisplayname(); this not possible (after lambda, dot not accepted). any ideas? edit : my "favorite syntax" mytype.property.getdisplayname() seems misleading. don't talk static properties here. know syntax won't possible. tried show in pseudo language, information necessary. ideal, every additional stuff syntactical overhead. working syntax close great. i don't want write extensio...

Website for C debugging puzzles -

could recommend website c debugging puzzles? thanks take subversion, git or other repo on net, contains project written in c compile, run, break debug .... give community. never run out of challenges here some: http://git.gnome.org/browse/ http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=summary http://git.savannah.gnu.org/cgit/qemu.git http://directory.fsf.org/gnu/ and millions more!

osx - How do I find the display size using Carbon -

how adjust height , width returned cgdisplaybounds menu bar height , dock height (or width if attached side)? i need using carbon calls. leaving aside ought moving away carbon already… use the hiwindowgetavailablepositioningbounds function . if need work in 64-bit, you're going have use cocoa .

xcode - iPhone: How do I add a 'next 25' like at the bottom of the screen in the app store app? -

i've got uitableview , want have 'next 25' feature in app store app. however, i've no idea control use , how develop it. can shed light on , give me info possible ? the first half of answer above correct. second half (using reloaddata) isn't best way it. once have new data, should call insertrowsatindexpaths:withrowanimation: on table view. tells table view you've added bunch of new rows , lets animate addition of new rows. example, might pass uitableviewrowanimationfade or uitableviewrowanimationtop. it's more efficient, because table view doesn't have reload , redraw rows in table. also, take @ of videos on table views 2010 wwdc (you can find them @ http://developer.apple.com/iphone , scroll bottom). they've got lots of great stuff.

java - where does a "static final" directly allocated into? young gen or old gen or perm gen? -

is "static final" directly allocated young gen or old gen or perm gen? (i guess land old gen on time suppose.) if allocated in perm gen then, garbage collected when class unloading takes place in perm gen ? is "static final" directly allocated young gen or old gen or perm gen? an object referenced static final variable allocated according same rules other object. allocated in young generation, or in old generation (if large , other conditions apply). the object allocated new executing in arbitrary code. jvm not in position know object (eventually) assigned static final variable. the space frame containing static variables allocated in permgen. of course, not regular java object. if allocated in perm gen then, garbage collected when class unloading takes place in perm gen? that depends on whether permgen garbage collected. in modern jvms is, , expect objects referenced unloaded classes statics garbage collected in same gc cycle,...

c - Implementing LRU algorithm -

i trying implement lru algorithm, not sure how change fifo lru , manipulate page table in //the declared parameters follows: pt_entry pte[max_page]; /* page table */ int mem_size; /* physical memory size in page frames */ list free_list_head; /* free list */ list res_set_head; /* resident set */ int total_fault = 0; /* total number of page faults */ int total_ref = 0; /* total number of memory references */ unsigned short find_victim() { unsigned short frame; list current; frame = res_set_head->next->frame; invalidate(frame); current = res_set_head->next; res_set_head->next = current->next; res_set_head->next->prev = res_set_head; to_resident_set(current); return frame; } //----------------------------------------------------------------- void resolve(int address) { unsigned short frame_alloc; int virt_page; static int disp_counter = 0; virt_page = address >> 8; if (pte[virt_page].vali...

c# - Is it possible to write a Skype client? -

is there libraries this? i put on server , windows service. and skype will not installed on server. skype api not mean guess. edit: i sorry not being clear. here need: i need skype client act small bot. person uses skype ask like: print totalcreditsloadedtoday and answer: 567867867 credits. i need write windows service accept text messages skype , send responses text message (a simple skype client). don't need voip support skype a, errr customer requirement lets say. (and yes suggested google talk not accepted) but need achieve without installing skype server. skype communication encrypted , no documentation publicly available on protocol. means luck reverse-engineering it.

javascript - How to make Movable forms in JS? -

ok on meebo.com there instant messages when click @ top can move around wanna make that? how make movable forms in js? i recommend jquery ui plugin called draggable .

vbscript - how do I execute several programs consecutively in vbs -

i have couple of applications execute 1 following other. how do this? tried second task never executed. on error resume next set wshshell = createobject("wscript.shell") wshshell.run """c:\program files\my folder\do task1.exe.vbs""" wshshell.run """c:\program files\my folder\do task2.exe.vbs""" msgbox "finished tasks" update: notes found on wshshell.run click here what missing (per isdi's answer) third parameter of run, tells not wait program quit (false), before continuing code exection. try (if want put code in subroutine, if coding practice repeat activities): 'place of following in .vbs file sub runapplication(byval sfile) dim wshell : set wshell = createobject("wscript.shell") wshell.run chr(34) & sfile & chr(34), 8, false end sub 'executing apps. runapplication "c:\program files\my folder\task1.exe" runapplication "c...

php - Adding to a class' variables with elements in an object -

$class = new class; $foo = json_decode($_post['array']); in highly contrived example, have class own functions , variables, blah blah. i decoded json string, values in $foo . how move elements in $foo on $class , that: $foo->name becomes $class->name ? would trivial if knew elements were, yes... except sake of being dynamic, let's want them transferred over, , don't know names. you use get_object_vars : $vars = get_object_vars($foo); foreach ($vars $key => $value) { $class->$key = $value; } you implement in class: public function bindarray(array $data) { foreach ($data $key => $value) { $this->$key = $value; } } and cast object array: $obj->bindarray( (array) $foo ); or add method too: public function bindobject($data) { $this->bindarray( (array) $data ); }

c# - What is the philosophy of literals in programming? -

how can literals explained? why should use in language such c# , ...? literals common in c#. want know philosophy , history of literals. literals common in c#. want know philosophy , history of literals. funnily enough on bus right writing blog entry exact topic. blog in next couple of weeks whole article (assuming finish it.) now, here's sneak peak. the principal philosophical impact of string literals in programming languages allow developer make distinction between mention , use of programming language structure. example: string alphabet = "abcdefghijklmnopqrstuvwxyz"; console.writeline(alphabet.length); // 26 console.writeline("alphabet".length); // 8 the quotation marks make big difference. mean "do not treat thing inside quotation marks part of program rather mere text has no impact on program qua program ". to describe full philosophical impact of use-mention distinction take many hundreds of pages; recommend rea...

c++ - Name resolution and Point of instantiation in Templates -

this statement iso c++ standard 14.6.4.1 point of instantiation 4.if virtual function implicitly instantiated, point of instantiation following point of instantiation of enclosing class template specialization. 5.an explicit instantiation directive instantiation point specialization or specializations specified explicit instantiation directive. 6.the instantiation context of expression depends on template arguments set of declarations external linkage declared prior point of instantiation of template specialization in same translation unit. i unable write programs whole section. trying write programs section yesterday. please, try ask 1 or more points. in section. here unable understand single point in section. so, kindly can 1 provide me code sections understand. the first 2 statements explain instantiation point of template constructs are; doesn't introduce new template constructs. can reuse previous examples. the third statemen...

c# - Threading Question -

possible duplicate: creating blocking queue<t> in .net? i have typical producer , consumer threading issue. difference producer allowed build buffer of 5 items after has wait until items consumed. what best solutions implement in c#. have implemented using semaphore producer seems build buffer of on 100 items rapidly. have no syntax handle limiting buffer 5 items. thinking of using static integer - have producer increment - when reaches 5 producer goes sleep. have consumer decrement , wake producer. why don't use bounded queue (size 5) , have producer block if queue full?

optimization - Optimizing a MySQL query with a large IN() clause or join on derived table -

let's need query associates of corporation. have table, "transactions", contains data on every transaction made. create table `transactions` ( `transactionid` int(11) unsigned not null, `orderid` int(11) unsigned not null, `customerid` int(11) unsigned not null, `employeeid` int(11) unsigned not null, `corporationid` int(11) unsigned not null, primary key (`transactionid`), key `orderid` (`orderid`), key `customerid` (`customerid`), key `employeeid` (`employeeid`), key `corporationid` (`corporationid`) ) engine=myisam default charset=utf8; it's straightforward query table associates, there's twist: transaction record registered once per employee, , there may multiple records 1 corporation per order. for example, if employees , b corporation 1 both involved in selling vacuum cleaner corporation 2, there 2 records in "transactions" table; 1 each employee, , both corporation 1. must not affect results, though. trade corporatio...

c# - Deny Switching to Tabpage in a tabcontrol -

i have form(c#) tab control , has around 5 tab pages. each of tab have few textboxes. 1) if user in tab , edits fields need validate text enetered if found invalid should not allow tab switch ? possible? 2) case ... user edits values , clicks on tab, on doing need check if values enetered tab correct or not ? can this? i novice c#... may these questions sound basic appreciated. also want know these events of tab page leave, validated or validating ? i had similar problem, thankfully came across msdn page. set tab selecting event , add logic cancel/continue there. http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.selecting.aspx

c# - Catch Exception with Condition -

note: happy tell exception filters in c# 6.0 language. this thought experiment, i'm interested in opinion: make sense you? know whether similar has been proposed c# programming language? wouldn't know send such proposal... the idea introducing syntax elements catch exception if fulfills condition. one use case example when working com interop: throws comexception . actual distinguishing error code contained in message. so (proposal 1): try { ... } catch (comexception ex ex.message.contains("0x800706ba")) { // rpc server unavailable } catch (comexception ex ex.message.contains("0x80010001")) { // call rejected callee } which translates to: try { ... } catch (comexception ex) { if (ex.message.contains("0x800706ba")) { // rpc server unavailable } else if (ex.message.contains("0x80010001")) { // call rejected callee } else { throw; } } similar case...

user interface - On which occasions exactly is WM_ACTIVATE sent? -

i'm trying debug huge win32 gui application (i have full sources) divided several processes. problem following: in 1 process have dialog listbox, when double-click item in listbox process started creates own window brought front , covers initial dialog. if manipulations (that can't explain yet since don't understand them yet) forces initial dialog start flashing in taskbar. i tried microsoft spy++ , see whenever manipulation wm_activate sent dialog, of times has these parameters: factive: wa_inactive fminimized:false hwndprevious:(null) and in cases dialog doesn't starts flashing. once in while parameters are factive: wa_active fminimized:false hwndprevious:(null) and precisely corresponds dialog flashing. msdn says wm_activate sent wa_active when window activated method other mouse click (for example, call setactivewindow function or use of keyboard interface select window) . now in application code setactivewindow() never called , don't keyboard...

javascript - JQuery set cookies -

how save div title cookies? , how saved data, back? <script type="text/javascript"> function setcookie(title, value, exp) { var expdate = new date(); expdate.setdate(expdate.getdate() + exp); document.cookie = title+'='+value+';expires='+expdate.togmtstring()+';path=/'; } </script> <div title="1" onclick="setcookie();"></div> see this question jquery , cookies. easier use plug-in, http://plugins.jquery.com/project/cookie . use following code title of div: title = $("div").attr("title");

python - paramiko combine stdout and stderr -

i trying combine output of stdout , stderr. belief can done set_combine_stderr() of channel object. this doing: ssh = paramiko.sshclient() #i connect , ok, then: chan = ssh.invoke_shell() chan.set_combine_stderr(true) chan.exec_command('python2.6 subir.py') resultado = chan.makefile('rb', -1.) however, following error when try store result (last line above, chan.makefile() ): error: channel closed. any appreciated while true set_combine_stderr diverts stderr stdout stream, in chaotic order, not result want, namely, lines combined in order written, if running command in local terminal window. instead, use get_pty . cause server run lines through pseudo-terminal, keeping them in chronological sequence. here's test program, outerr.py , writes alternating lines on stdout , stdin . assume it's sitting in home directory of llmps@meerkat2. #!/usr/bin/env python import sys x in xrange(1, 101): (sys.stdout, sys.stderr)[x%2].write(...

c++ - Mapping a string to a unique number? -

is there nice bash 1 liner map strings inside file unique number? for instance, a b b c c should converted into 1 1 2 2 3 3 i implementing in c++ bash one-liner great. awk '{if (!($0 in ids)) ids[$0] = ++i; print ids[$0]}' this maintains associative array called ids . each time finds new string assigns monotically increasing id ++i . example: jkugelman$ echo $'a\nb\nc\na\nb\nc' | awk '{if (!($0 in ids)) ids[$0] = ++i; print ids[$0]}' 1 2 3 1 2 3

html - Adding tables in jHtmlArea -

anyone know of way of making jhtmlarea support table content, , allow user add tables/cells/rows editor box? doesn't appear standard feature plugin. i user able create tables in wysiwyg editor. try code just change #editor "id" set textarea. , insert styles if u have.hope helps. jhtmlarea wysiwyg editor - adding table

android - How to parse the AndroidManifest.xml file inside an .apk package -

this file appears in binary xml format. format , how can parsed programmatically (as opposed using aapt dump tool in sdk)? this binary format not discussed in documentation here . note : want access information outside android environment, preferably java. use android-apktool there application reads apk files , decodes xmls original form. usage: apktool d gmail.apk && cat gmail/androidmanifest.xml check android-apktool more information

c++ - does order of members of objects of a class have any impact on performance? -

may order of members in binary architecture of objects of class somehow have impact on performance of applications use class? , i'm wondering how decide order of members of pods in case answer yes since programmer defines order of members via order of declaraions absolutely. c++ guarantees order of objects in memory same order of declaration, unless access qualifier intervenes. objects directly adjacent more on same cacheline, 1 memory access fetch them both (or flush both cache). cache effectiveness may improved proportion of useful data inside may higher. put, spatial locality in code translates spatial locality performance. also, jerry notes in comments, order may affect amount of padding. sort members decreasing size, decreasing alignment (usually treat array 1 element of type, , member struct most-aligned member). unnecessary padding may increase total size of structure, leading higher memory traffic. c++03 §9/12: nonstatic data members of (non-union)...

Making an Oracle Apex report table element read-only -

greetings: is there anyway make apex report table cell (or entire report itself) conditionally read-only in apex 3.2? don't see "read-only" box anywhere in options; tried searching everywhere. thanks in advance! since whole tabform made read-only particular users, can @ rendering time rather using javascript. however, need 2 copies of each column: column displayed authorised user, not readonly identical column displayed non-authorised user, element attributes set readonly=readonly authorisation schemes can used control columns displayed user. i hoping find way single column , dynamic value element attributes, couldn't work.

asp.net mvc - XMLHttpRequest different in IE8 vs. FireFox/Chrome -

Image
i'm having problem similar jquery $.ajax not working in ie8 works on firefox & chrome , different use case. i'm using jquery form plug-in handle file upload asp.net mvc controller, sends file off parsing , processing. if exception thrown, should alert user issue. //client side code //make ajax call, sending contents of file $("#ajaxuploadform").ajaxsubmit({ datatype: 'json', url: '/plan/something/excelimport', iframe: true, beforesend: function () { $(".ui-dialog-buttonpane").find("#my_progress").fadein(); }, success: function (data, textstatus) { output = "<center><span class='flash'>" + data.message + "</span></center>"; $(...

SQL Server 2005 SUM -

hey all, query string here: select sum(total) total, administratorcode, sum(wod.quantity) thepass tblwo wo, tblwod wod wod.orderid = wo.id , wo.orderdate between '2010-01-01' , '2010-08-31' , approved = '1' order wo.administratorcode but keep getting error: the multi-part identifier "tblwod.quantity" not bound. any great! thanks, david solved!!! you need use sum(wod.quantiy) (or maybe quanti t y unless column name missing t ) you have aliased table here tblwod wod have no table exposed correlation name tblwod

memory - Is there any way of preventing application from crashing when heap is corrupted? - C programing language -

sometimes in execution error message in vs2010 when trying free memory: windows has triggered breakpoint in [appname].exe. this may due corruption of heap, indicates bug in [appname].exe or of dlls has loaded. this may due user pressing f12 while [appname].exe has focus. the output window may have more diagnostic information. wich means wrong heap or pointer. my issue error crashes app when built release. also module of bigger application , when crashes everithing goes down. i able handle error. from msdn on "free": if error occurs in freeing memory, errno set information operating system on nature of failure. more information, see errno, _doserrno, _sys_errlist, , _sys_nerr. there errno_t _get_errno( int * pvalue ); function returns error code. if press continue on error msg shown above function returns error code. using code can detect error, create call stack , exit function softly. is there compiler switch or prevent apli...

asp.net mvc - Why should I test my HTMLHelpers? -

is there tangible value in unit testing own htmlhelpers? many of these things spit out bunch of html markup - there's little if no logic. so, compare 1 big html string another? mean, of these thing require @ generated markup in browser verify it's output want. seems little pointless. yes. while there may little no logic now, doesn't mean there isn't going more logic added down road. when logic added, want sure doesn't break existing functionality. that's 1 of reasons unit tests written. if you're following test driven development, write test first , write code satisfy test. that's reason. you want make sure identify , test possible edge cases helper (like un-escaped html literals, un-encoded special characters, etc).

mysql - Selecting count of zero while grouping by column -

i have jobs table, , trying count of jobs different time frames. current query looks this: select count(*) 'count', week(j.created_at) 'week', month(j.created_at) 'month', year(j.created_at) 'year', date_format(j.created_at, '%y') 'short_year' jobs j j.state <> 'draft' , created_at > '2010-06-21' , created_at < '2010-08-01' group week(j.created_at) order week(j.created_at) to change timeframe, change group by week month , , counts month instead of week. the problem not getting empty rows weeks 0 jobs. result set query above is: count week month year short_year 3 25 6 2010 10 2 26 6 2010 10 2 27 7 2010 10 1 28 7 2010 10 3 30 7 2010 10 you'll notice there no data week 29, should row count(0). there way 0 count row, while maint...

c# - Why can't I reference a class in another namespace in another project within the same solution? -

i have created namespace in project within same solution. when type using other namespace shows up. cannot see public class within namespace. what's wrong ? since type public, sounds simple missing project reference between two. right click references , add new reference, watch references shouldn't become circular (i.e. <===> b, or ===> b ===> c ===> a). actually, vs ide doesn't let this, can done (accidentally or purposefully) via command-line tools.

How do I conditionally add a clause to my query in PHP? -

in search form have, value male, value female, , value both. if select both, not wish have @ "sex = '$sex'" should this: if(empty($sex)){ // value empty if chose "both" $query = "select firstname, lastname, id, user_name, sex, last_access, bostadsort users (firstname '%$firstname%' or lastname '%$lastname%')"; }else{ $query = "select firstname, lastname, id, user_name, sex, last_access, bostadsort users (firstname '%$firstname%' or lastname '%$lastname%') , sex = '$sex'"; } or there smart way write this? do never build sql string user input. that's prepared statements for. secure, perform faster when re-executed , they're easy use, use them: $sql = " select firstname, lastname, id, user_name, sex, last_access, bostadsort users (firstname '%'|| ? || '%' or lastname '%'|| ? || '%') , sex = case ? when 'both...

graphics - drawing part of a bitmap on an Android canvas -

how can blit non-rectangular (e.g. oval) part of bitmap canvas on android? consider how you'd blit rectangular part of bitmap: canvas.drawbitmap(src,src_rect,dest_rect,paint) . sadly there no corresponding methods non-rectangular regions. four approaches present (maybe know fifth?): copy rectangular bounds want blit intermediate bitmap, , go setting pixels don't want blit transparent, draw bitmap make mask bitmap - there ways blit separate mask? use bitmapshader drawarc()/drawcircle() ; however, can't work out how matrix aligned; how initialize matrix operation? use very complicated clipping region of these, option 3 1 work; however, cannot work out how so; can you? you can use option number #3, it's easiest. way draw shape want clip in intermediate bitmap ( argb8888 ), draw original bitmap using dstin or dstout xfermode.

core - Is Math.max(a,b) or (a>b)?a:b faster in Java? -

which 1 faster in java , why? math.max(a,b) (a>b)?a:b (this asked in interview.) math.max(a, b) static function (meaning no virtual call overhead) , inlined jvm same instructions (a > b) ? : b .

scripting - Python datetime TypeError, integer expected -

i'm pretty new python, problem i'm having has simple solution. at work either shell (ksh) or perl of our scripting work. since python has been shipped solaris time now, has (finally) been given green light scripting platform. i've started prototyping improvements our scripts using python. what i'm trying accomplish taking time stamp , string representing time stamp , creating datetime object date arithmetic. my example code follows: #!/bin/python import datetime filetime="201009211100" format = "yyyymmdd" yidxs = format.find('y') yidxe = format.rfind('y') if not filetime[yidxs:yidxe+1].isdigit(): print "error: year in wrong format" exit else: print "year [" + filetime[yidxs:yidxe+1] + "]" midxs = format.find('m') midxe = format.rfind('m') if not filetime[midxs:midxe+1].isdigit(): print "error: month in wrong format" exit else: print ...

orm - nHibernate Save One-To-Many -

i have parent class contains list of children. have parent , child mapped bidirectional has-many , inverse on parent cascade.all turned on. if modify object in child list, no property on parent, nhibernate not save child. if modify property on parent saves fine. design or there special property need set? this might have way adding children collection. in bidirectional, have manage both sides of relationship in code. consider example fluent nhibernate getting started guide . check store entity. a store has many employees. staff property of store collection of employees. relationship setup bidirectional. store has following method public virtual void addemployee(employee employee) { employee.store = this; staff.add(employee); } as can see, childs parent property needs set parent object. if not done, nhibernate not able understand parent of child , cannot automatically save child if child modified , saveorupdate(parent) called. you need both.

java - Lazy Instantiation of the Spring MVC DispatcherServlet? -

is there way me instantiate spring mvc dispatcherservlet in code rather put in web.xml , have instantiated web server? the reason want check memcache see if have rendered page being requested , if return memcache, rather going through spring mvc , controllers. the ~2 second instantiation of dispatcherservlet significant because using google app engine , might end being additional 2 seconds user has wait page. i have tried dispatcherservlet = new dispatcherservlet(); dispatcherservlet.init(); dispatcherservlet.service(request, response); but exception on init call: [java] java.lang.nullpointerexception [java] @ org.springframework.web.servlet.httpservletbean$servletconfigpropertyvalues.<init>(httpservletbean.java:196) [java] @ org.springframework.web.servlet.httpservletbean.init(httpservletbean.java:114) basically, i'm looking way instantiate servlet in code without having specify in web.xml , not have call getservletconfig().getservletconte...

CakePHP view variable scope issue -

i have these lines in view file //////////////////////////// $a = 5; showme() showme() { global $a; echo $a; } //////////////////////////////// problem: $a not accessible in showme() function. i have no choice pass $a argument , no choice move function view. , should accessible in function through global keyword only. i can change way of declaration $a . you missing semi-colon end later statement: $a = 5; showme() change to: $a = 5; showme(); your code seems ok, should work, not sure may try if inside class: $a = 5; $this->showme();

How accurate is the reading for GPS in iPhone's SDK? -

using iphone's sdk gps api, how accurate can get? within few meters or kilometers? i'm interested in accuracy when indoor. my software used in door. the best possible accuracy seems 9 meters. common values (outdoor, coverage) 17 m, 23 m , 49 meters. trees covering sky you'll stay under hundred meters, hardly accurate enough gis or that.