Posts

Showing posts from January, 2014

asp.net - dynamic columns disappears after postback -

i have gridview boundfields , 2 templatefields . in these 2 templatefields , dynamically create usercontrols containing dropdownlist , textbox , users can modify. when try values of controls after postback , values in boundfields still there dynamic controls disappears. can create them again won't user's values... how can these values before they're lost? here's of code: in rowdatabound event: select case type case "booleanbis" e.row.cells(2).controls.clear() dim list1 booleanbislist = new booleanbislist(avant, false) e.row.cells(2).controls.add(list1) e.row.cells(4).controls.clear() dim list2 booleanbislist = new booleanbislist(apres, true) e.row.cells(4).controls.add(list2) case "boolean" e.row.cells(2).controls.clear() dim list3 booleanlist = new booleanlist(avant, false) e.row.cells(2).controls.add(list3) e.row.cells(4).controls.clear() ...

Python - Xlwt more than 256 columns -

i importing text files excel using xlwt module. allows 256 columns stored. there ways solve problem? xlwt supports creation of xls files of kind created excel 97-2003 , read excel 97 onwards. file format limited 256 columns , 65536 rows. no amount of changing 256 other number in xlwt source code change that. you have 3 options, in increasing order of complexity: (1) suggested another, write csv file. (2) openpyxl ... excel 2007+ xlsx/xlsm format (3) win32 com (windows only)

Calling a Javascript/JQuery function on postback for ASP.NET/C# page -

i working jquery plugin called 'tab slide out' link here: http://wpaoli.building58.com/2009/09/jquery-tab-slide-out-plugin/ i trying use feedback technique. on slide out there form, , submit button. when hit submit, of course causes postback, , page loads, feedback window set closed state. want window automatically open on postback. here example of website uses plugin , has working how want work: http://thedemo.ca/ now noticed in there script have on initial page load: jquery('.slide-out-div').tabslideout({ tabhandle: '.handle', pathtotabimage: 'typo3conf/ext/stw_jquery_feedback/images/feedback-btn-right.png', imagewidth: '32px', imageheight: '167px', tablocation: 'right', speed: 300, action: 'click', toppos: '200px', fixedposition: true, onloadslideout: false }); and on postback submit button: jquery('.slide-out-div').tabslideout({ tabhandle: '.handle', pa...

image - WPF Error: Cannot find governing FrameworkElement for target element -

i've got datagrid row has image. image bound trigger state. when state changes want change image. the template set on headerstyle of datagridtemplatecolumn. template has bindings. first binding day shows day , state changes image trigger. these properties set in viewmodel. properties: public class headeritem { public string day { get; set; } public validationstatus state { get; set; } } this.headeritems = new observablecollection<headeritem>(); (int = 1; < 15; i++) { this.headeritems.add(new headeritem() { day = i.tostring(), state = validationstatus.nieuw, }); } datagrid: <datagrid x:name="personeelsprestatiesdatagrid" horizontalalignment="stretch" verticalalignment="stretch" autogeneratecolumns="false" selectionmode="single" itemssource="{binding caregiverperformances}" frozencolu...

flex - Why does Flexmojos produce a different size swf to mxmlc? -

i compiling simple app, main.mxml: <?xml version="1.0" encoding="utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"> <s:label text="flex"/> </s:application> with mxmlc (sdk 4.0.0.14159): mxmlc -context-root=a -services=.\src\main\webapp\web-inf\flex\services-config.xml src\main\flex\main.mxml -output src\main\webapp\main.swf and flexmojos 3.9 & 4.0-rc2, using sdk 4.0.0.14159: <configuration> <output>src/main/webapp/main.swf</output> <services>src/main/webapp/web-inf/flex/services-config.xml</services> <contextroot>a</contextroot> </configuration> the output both builds creates valid swf file works expected, yet swf file mxmlc smaller flexmojos version: mxmlc main.swf 43k flexmojos main.swf 367k this quite worrying because developing in ec...

html - How to make another tag behave exactly like the pre tag using CSS? -

i want <code> tags behave <pre> tags. problem line break @ beginning of block. how rid of line break? this shows mean ... http://jsfiddle.net/6nmpn/ this appears browser bug. see e.g. this page . sgml (and html) says browser needs remove newline following opening tag, or preceding closing tag. appears browsers (note: not all) adhere requirement on <pre> tag , not on other tags such <code> tag. so, appears there's not can it. possible fix can think of using xhtml strict. that's xml, not sgml. perhaps browsers treat elements equally then. i'm not sure, it's idea.

Why do browsers use so much memory? -

firefox 18 tabs open = 1.34gb of memory (~75mb/tab). got reply on twitter local developer mentioning chrome instance using ~82mb/tab. what causes web browsers consume memory? to make more crash-resistant, chrome spawn many copies of full-fledged processes instead of using multi-threading. eats more memory (less things can shared). chrome puts plugins in separate processes (so crash of flash won't bring down whole browser)... other memory consumed... , on.

wpf - How to validate a Password given by a PasswordBox-Binding -

i sit here , have big problem...i hope 1 me. binding of password passwordbox mentioned in this thread i think variant, because password isn´t saved in variable , didnt have access after method of button password. want validate password interface idataerrorinfo. normaly looks this public override string this[string propertyname] { { if (propertyname=="password" && password.length < 6) { return "password short."; } } } is possible here password binding passwordbox directly? thanks nobody have idea me? or not possible? another idea write own custom control bindable passwordbox. founded example here. how can standart style of passwordbox in generic.xaml?

floating point - Precision in Erlang -

next code gives me 5.999999999999998 in result, right answer 6. alpha = math:acos((4*4 + 5*5 - 3*3) / (2*4*5)) area = 1/2 * 4 * 5 * math:sin(alpha) is possible 6? you have run problem common has own web site, what every programmer should know floating-point arithmetic . problem due way floating-point arithmetic works in pretty every cpu on market supports fp arithmetic; not specific erlang. if regular floating point arithmetic not give precision or accuracy need, can use arbitrary precision arithmetic library instead of built-in arithmetic. perhaps well-known such library gmp , you'd have wrap in nifs use erlang. there at least 1 pure-erlang alternative , have no experience it, cannot endorse it.

jquery - jCarousel resetting scroll position -

i have question resetting scroll position when load new data in jcarousel. link here: http://rjwcollective.com/equinox/rishi_gallery/eqgall.php new data comes in when click on filters in sidebar on left. however, if start scrolling in carousel on right sidebar , reselect filters, newly loaded data doesn't reset top position. i emptying out data in div using .empty() the scenario this: first load: //first load $.ajax({ type:"post", url:"sortbystate.php", data:"city=&gender=&category=", success:function(data){ //carousel $('#thumbs').html(data); } });//end ajax filter selection: $(".statelist :input").click(function(){ $('#thumbs').empty(); var state = $('.statelist input:checked').attr('value'); var gender = $('.gender input:checked').attr('value'); var category =$('.category input:checked').attr(...

mysql - Stored procedures and unit testing -

does know of framework (or methodology) unit test stored procedures using sql , able produce reasonable report has passed , has failed (something similar cppunit)? mytap looking for, see: http://theory.github.com/mytap/ also see similar question: best tool unit testing in mysql

How would you design this MySQL database? -

i building blog/forum type website scratch , i'm wondering how best design database. website going have posts, comments , comment threading (reply reply). posts , comments share lot of same attributes i'm leaning towards storing content in single table called 'posts'. basic gist of table is: id body author timestamp now, i'd love ideas on optimal relationship tables and/or additional columns flag posts threads , comments, , comments @ root level of thread vs in response comment. if relational database experts can chime in, thanks! the basic structure this: post 1----* comment *--- 1 | ------- where post may have many comments, comments can have parent comments , comments can have multiple child comments. hope helps.

multithreading - iPhone - is ASIHTTPRequest threadsafe? -

i have method: -(void)updatesomething { nsautoreleasepool *pool = [[nsautoreleasepool alloc] init]; nsurl *url = [nsurl urlwithstring:@"some url"]; asiformdatarequest *httprequest = [asiformdatarequest requestwithurl:url]; [httprequest startsynchronous]; //some other stuff [pool drain]; } i call method on applicationdidfinishlaunching if call on main thread works fine [self getmyitems]; but when call on separate thread "program received signal: "exc_bad_access" [self performselectorinbackground:@selector(getmyitems) withobject:nil]; any idea how resolve issue? why perform individual requests on separate threads when can use asinetworkqueue? asinetworkqueue *aqueue = [[asinetworkqueue alloc] init]; [aqueue addoperation:requesttoadd]; [aqueue setdelegate:self]; [aqueue setrequestdidfinishselector:@selector(requestfinished:)]; [aqueue setrequestdidfailselector:@selector(requestfailed:)]; [aqueue setqueuedidfinishselec...

map - Java : Iteration through a HashMap, which is more efficient? -

given following code, 2 alternative ways iterate through it, is there performance difference between these 2 methods? map<string, integer> map = new hashmap<string, integer>(); //populate map //alt. #1 (string key : map.keyset()) { integer value = map.get(key); //use key , value } //alt. #2 (map.entry<string, integer> entry : map.entryset()) { string key = entry.getkey(); integer value = entry.getvalue(); //use key , value } i inclined think alt. #2 more efficient means of iterating through entire map (but wrong) your second options more efficient since doing lookup once compared n number of times in first option. but, nothing sticks better trying out when can. here goes - (not perfect enough verify assumptions , on machine anyway) public static void main(string args[]) { map<string, integer>...

grails - Write operations are not allowed in read-only mode (FlushMode.MANUAL): -

grails 1.3.7 we have service method merges 2 users. there quite few pieces because of amount of data quite bit of reading, updating, , writing. have transactional=true in service. understand default flushmode grails auto. , understand error message means. however, doesn't happen locally , doesn't happen in our staging environment. of running identical version of mysql identical privileges (password exception). i know can change default flushmode behavior i'm hesitant since can't duplicate behavior on environment production. right i'm wondering if there cause wouldn't related flushmode? the verbatim error message is: org.springframework.dao.invaliddataaccessapiusageexception: write operations not allowed in read-only mode (flushmode.manual): turn session flushmode.commit/auto or remove 'readonly' marker transaction definition. i'm seeing errors similar these in grails 1.3.7 application well. in case, back-end db...

How to use NSZombie? -

Image
so finished app , wanted final few steps run diagnostics on it. in terms of memory usage, allocations, leaks, etc are. i have few questions: 1) there standard list of instruments/checks should run on app fore submitted make sure robust? if point me links and/or tell me names can google stuff. 2) 1 of tools know run nszombieenabled. followed steps found online on sites set nszombie test doesn't seem working. looked @ site: nszombieenabled this xcode looks after tried steps listed there: but why zombies choice not highlighted? once work how use nszombies? so far know, nszombies available debugging mac apps or ios apps running on simulator. cannot used apps running on devices. follow this thread , this .

bitmap - Strengthen RGB colors using c# -

i need strengthen rgb channel/colors number user can choose. i've got following code , i'm not sure it's correct. can tell me can change or can better. int value = int.parse(textboxconstante.text); (int y = 0; y < mypic.height; y++) { (int x = 0; x < mypic.width; x++) { color c = mypic.getpixel(x, y); mypic.setpixel(x, y, color.fromargb(c.r * value /10, c.g * value/10, c.b * value/10)); } } i've not run code, suspect you're having problems c# lack of implicit double casting... try rewriting way: .fromargb((int)(c.r * ((double)value /10)), [the rest wrapped same way]

actionscript 3 - Security: Achievement and score API in AS3 -

over years i've become uber-nerd when comes flash game development. i'm thinking looking using skills helping other game-developers out there. i want develop api in as3 allow developer (as start) following: display dialogue lets user log "account" (hosted on site). send score/value website , attribute logged in user. unlock achievement (achievements set developer in web interface - key of type use api. display high scores, other players profiles in-game, etc (show stats in-game). all easy enough develop straight off bat. however; becomes frustrating security. i'm not expecting indestructible solution i'm aware isn't possible, most defensive way approach this? here issues can think on spot: the big 1 - people stealing api key via man-in-the-middle attack. highscore injection, false achievement unlocks. decompiling swf , stealing api key. using api key create dummy flash application , send random data highscores. altering api don...

javascript - resize jqgrid when parent div changes with an event -

i have dashboard several jqgrids. dashboard windows can individually expand fill page while other windows disapear. there toggle shrink back if have jqgrid, in window, when expands grid width expand , shrink well. is there way bind grid parent div can expand , shrink? sample far not work. $('.portlet-content').bind('resize', function() { jquery("#gridconfirm").setgridwidth($('.portlet-content').width()-5, true); }).trigger('resize'); you should bind jquery.resize window object. try one $(window).resize(function() { $("#gridconfirm").jqgrid('setgridwidth', $('.portlet-content').width()-5, true); }).trigger('resize');

c# - populating an Entity DataModel from XML using Linq -

i have c# .net 3.5 application using ado.net entity data model. loading contents given database entry xml file. what's best method convert list<string> xml entitycollection<> ? the xml looks this: <task> <name>test task</name> <serialnumbers> <serial>12345678901</serial> <serial>98765432101</serial> </serialnumbers> </task> the database looks this: task { [int, pk]taskid } criteria_serialnumber { [int, pk]serialnumberid, [string]serialnumber } task_serialnumber { [int, pk]serialnumberid, [int, pk]taskid } the c# code looks this: using (xmltextreader xml = new xmltextreader(task_file)) { xelement x = xelement.load(xml); // works great. task.name = x.element("name").value; // how convert list<string> entitycollection<criteria_serialnumber> ? task.serialnumbers = (from in x.element("serialnumbers").elements("se...

Android Intents and Scala -

i attempting convert following tutorial, http://savagelook.com/blog/android/swipes-or-flings-for-navigation-in-android , scala code android. have working well, except mygesturedetector class have not yet completed have errors in. code follow class mygesturedetector extends simpleongesturelistener { override def onfling(e1:motionevent, e2:motionevent, velocityx:float, velocityy:float):boolean ={ var intent:intent = new intent (mainactivity.this.getbasecontext(), mainactivity.class) true } override def ondown(e:motionevent):boolean = { true } } my code giving me red underline on mainactivity.this.getbasecontext() , mainactivity.class. red x next line says mainactivity not enclosing class, identifier expected .class found, , mainactivity not value. importing following packages import android.app.activity import android.os.bundle import android.content.intent import android.view.gesturedetector import android.view.gesturedetector.simpleongesturelistener import an...

iphone - How to enforce time based license in an iPad app -

we're in process of completing application based on licensing system. users manage through web interface , can sync devices require. once device sync'd app self sufficient point user needs update device latest set of data. now have implemented sync-process verify if user's license has expired or not before sync'ing. downside updates aren't required , more or less static on period of our licenses. as such, we're trying figure out if possible on device itself, force user either sync our server @ regular intervals or when license supposed expire. nsdate obvious no since values dependent on user can changed easily. mach_absolute_time() option considered timer changes when ipad restarted. need way track absolute time since license begun, regardless of whether application or device running or not , notify user of when app starts. any appreciated. interesting problem. keep nsuserdefaults value represents highest date app run detect if user has ch...

Error install ldap for php 5.3 on CentOS 5.5 -

error install ldap php 5.3 on centos 5.5 error message below : [root@localhost ~]# yum install php-ldap loaded plugins: fastestmirror loading mirror speeds cached hostfile setting install process resolving dependencies --> running transaction check ---> package php-ldap.i386 0:5.1.6-27.el5_5.3 set updated --> processing dependency: php-common = 5.1.6-27.el5_5.3 package: php-ldap --> finished dependency resolution php-ldap-5.1.6-27.el5_5.3.i386 updates has depsolving problems --> missing dependency: php-common = 5.1.6-27.el5_5.3 needed package php-ldap-5.1.6-27.el5_5.3.i386 (updates) error: missing dependency: php-common = 5.1.6-27.el5_5.3 needed package php-ldap-5.1.6-27.el5_5.3.i386 (updates) try using --skip-broken work around problem try running: package-cleanup --problems package-cleanup --dupes rpm -va --nofiles --nodigest program package-cleanup found in yum-utils package. you need install yum i...

java - Exception on excuteUpdate -

i getting exception com.microsoft.sqlserver.jdbc.sqlserverexception: string or binary data truncated. the exception thrown @ following line: preparestmt.setbinarystream(1, new bytearrayinputstream(data), data.length); updatepreparestmt.executeupdate(); i using ms-sql db. can me solve problem? the datatype of column in trying insert data varbinary , length of data not large. inserting "test". update have increased size of datatype varbinary. made 1024, new exception :- com.microsoft.sqlserver.jdbc.sqlserverexception:the conversion varbinary blob unsupported can comment on exception? as exception message sais, data seems larger database field should written to. maximum of data.length , what's maximum length of column?

Silverlight Button Click -

i'm having problems getting silverlight button click event update control's ui element , continue doing other process. example, update text of control , process. i've tried calling updatelayout() method doesn't help. here sample code: private void button1_click(object sender, routedeventargs e) { textblock1.text = "testing"; textblock1.updatelayout(); updatelayout(); thread.sleep(2000); textblock1.text = "done"; } in sample, textblock1 control never display text "testing". it's because you've blocked ui thread sleep statement means text block won't update until after it's completed, time you've set text "done".

java - how to remove header information from mp3 file? -

is there anyway remove header information mp3 file such mp3 file can't played? regards, hitendrasinh gohil you have more remove header make mp3 unplayable. if take other answer question , apply whole file there should no way can played: randomaccessfile raf = new randomaccessfile("input.mp3", "rw"); byte[] buf = new byte[65536]; long pos = 0; int len; random random = new random(34); while ((len = raf.read(buf)) != -1) { (int = 0; < len; i++) { buf[i] ^= random.nextint(); } raf.seek(pos); raf.write(buf); pos = raf.getfilepointer(); } raf.close(); this xor every byte in file. reason suggested in other answer first 64k performance since you're on android device. me made unplayable on desktop. if doing whole file doesn't work suspect you're doing else wrong. there no way it'll play original music if every byte changed this. can run again undo , make mp3 playable again.

objective c - How to detect touches on UIImageView of UITableViewCell object in the UITableViewCellStyleSubtitle style -

i using uitableviewcell object in uitableviewcellstylesubtitle style (i.e image view on left, text label in bold , under detail text label) create table. need detect touches on uiimageview , know indexpath/cell in image view clicked. tried using cell.textlabel.text = @"sometext"; nsstring *path = [[nsbundle mainbundle] pathforresource:@"emptystar1" oftype:@"png"]; uiimage *theimage = [uiimage imagewithcontentsoffile:path]; cell.imageview.image = theimage; cell.imageview.userinteractionenabled = yes; but it's not working. whenever image clicked, didselectrowatindexpath: called. don't want create separate uitableviewcell , add custom button it. there way detect touches on uiimageview itself? in cellforrowatindexpath method add code cell.imageview.userinteractionenabled = yes; cell.imageview.tag = indexpath.row; uitapgesturerecognizer *tapped = [[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(myfunction...

XCode 4.2 + iOS 5 Storyboard : Can't distinguish between segmented control sections as segue initiators? -

using xcode 4.2 storyboard, i've created segmented control in view 2 segments. ctrl-drag each segment separate view create 2 segues. seems developers forgot distinguish between segments though, since 1 segue can created; attempting create second 'other' control segment cause first segue replaced second. have storyboard workaround this, or must write code manually? thank you. 4.2 has been publicly release now. the problem can solved storyboard using custom segue. in custom segue segmented control can tested determine controller call. have tested following custom segue: #import "fliptoppop.h" @interface uiviewcontroller (extension) @property (strong, nonatomic) iboutlet uisegmentedcontrol *tabcontrol; @end @implementation fliptoppop - (void) perform { uiviewcontroller *src = (uiviewcontroller *) self.sourceviewcontroller; switch (src.tabcontrol.selectedsegmentindex) { case 0: // go settings src.tabcontrol.selectedsegment...

iphone - Center an UIImageView on the screen when zoom out -

i have uiimageview inside uiscrollview. want user can zoom , navigate image. this work code: //img uiimageview //scroller uiscrollview - (uiview *)viewforzoominginscrollview:(uiscrollview *)scrollview { return img; } - (void)viewdidload { [super viewdidload]; uiimage *image = [uiimage imagenamed:@"map_screen.png"]; img = [[uiimageview alloc] initwithimage:image]; scroller.delegate = self; scroller.autoresizessubviews = yes; scroller.autoresizingmask = uiviewautoresizingflexibleheight | uiviewautoresizingflexiblewidth; scroller.contentsize = img.frame.size; scroller.scrollenabled = yes; scroller.directionallockenabled = no; scroller.userinteractionenabled = yes; cgsize ivsize = img.frame.size; cgsize ssize = scroller.frame.size; float scalex = ssize.width / ivsize.width; float scaley = ssize.height / ivsize.height; scroller.minimumzoomscale = fmin(1.0, fmax(scaley, scalex)); scroller.zoomscale = fmin(1.0, fmax(scalex,...

iphone - Drawing in Custom ScrollView -

i'm trying draw in scrollview on top of image using multi-touch. circles drawn, under image. in code create custom scrollview: @interface appscrollview : uiscrollview { //objects draw circles nsmutabledictionary *circlesinprocess; nsmutablearray *completecircles; } @end in appscrollview.m override touches commands store touches , add (void)drawrect:(cgrect) rect method draw circles in scrollview. include [self setneedsdisplay] to display circles. in app controller, declare new custom scrollview object: iboutlet appscrollview *scrollview; later add image scrollview using: [scrollview addsubview:myimage]; the image visible, when try draw circles on top of it, drawn under image. let me know if have suggestions? suggestion: draw image onto scrollview (instead of adding image view subview) , draw circles on top of that.

How can I disable Javascript syntax checking in NetBeans 7.0 (Linux version for PHP)? -

Image
maybe i'm blind, can't find option , google doesn't want me. sometimes netbeans tries check syntax in file when detects js, many templating frameworks/libraries put js php or special tags, causing netbeans throws syntax error in file. i using netbeans 8.1 , can manage type of options these steps. think available netbeans 7 . click tools option in header menu , select options menu. select editor popup. now see submenu below . select hint select language javascript , uncheck options don't need , save. this way can enable or disable syntax checking option languages. , can manage formatting, code folding, spelling checker etc

r - Calculating the median -

i have following (exponential) values , want calculate median using r: 1.0584e+00 1.1618e+01 4.9097e+00 1.3595e+01 4.2209e+01 4.6901e-01 2.4911e+00 1.2441e+01 6.8128e+00 1.3581e+01 1.4373e+01 1.2828e+00 7.7811e+00 here doing: data <- read.table("path") median(data[ ,1]) due values being in exponential, not getting correct median. alternatively, may suggest how can change these values normal floating point values. what getting median. seems work me. maybe have these "factor"s , need convert as.numeric(as.character()) > median(vec) [1] 7.7811 > vec [1] 1.05840 11.61800 4.90970 13.59500 42.20900 0.46901 2.49110 12.44100 6.81280 13.58100 [11] 14.37300 1.28280 7.78110

C# Accessing EXCEL, formatting cell as General -

c#, visual studio 2010 when manipulating excel cells in c# (via com object), should use .value or .value2 ? is sheet.cells[row + n, col].value = "hello world" or sheet.cells[row + n, col].value2 = "hello world" what difference between them ? also, how set cell format "general" ? sheet.cells[row + n, col].numberformat = "xyz"; // not sure should here right when assign cell number "0,34" , if sheet.cells[row + n, col].numberformat = "@"; i "little error" sign in left corner in each cell to answer first question should read article: http://blogs.msdn.com/b/eric_carter/archive/2004/09/06/225989.aspx the optional parameters part doesn't apply anymore since c# 4.0 has optional parameters. but there difference (stated in article) the difference between property [value2] , value property value2 property doesn’t use currency , date data types. can return values formatted t...

events - jquery - enter key behaves differently depending on focus? -

is there way (using jquery) have enter behave differently depending upon textfield active? so, if have: <input type="text" name="different" value="something" /> <button id="somebutton">go</button> <textarea name="something">some stuff</textarea> <input type="submit" name="sendit" value="send it" /> i'm trying figure out how run function if user in , either hits enter or clicks , whereas if user in textarea , hits enter, it'll submit form... sorry, i'm not entirely of call kind of behavior, has made googling difficult... $("input[name=different]").keyup(function(e){ if(e.keycode == '13') { e.preventdefault(); } }); $("textarea[name=something]").keyup(function(e){ if(e.keycode == '13') { $("form").submit(); } }); jsfiddle

Any javascript event occurring when user clicks Stop load button? -

i want run javascript when user clicks stop load-button (red x in browsers) or hit esc on keyboard, same. i've seen questions here covering esc button hooking onto document.body.onkeyup , couldn't find covering mouse click on stop button. internet explorer has document.onstop event fired, other browsers don't seem support that. note it's fired when user clicks stop or hits esc, or if user navigates page during page load, has same effect. i don't believe there reliable way trigger event on clicking stop in other browsers. perhaps possible like: keeping connection server open (as in comet approach), streaming sort of keep-alive down connection, , detecting if stream ends (as assume if stop button clicked).

java - Kill a task in threadexecutor if it takes more time -

here scenario: i have java main process, uses jms publish activemq broker. each time message supposed sent broker, thread used fixed sized thread pool (using threadexecutor) , inside publish calls made. now , publish call blocking call , if broker down , thread keeps waiting. i want create threadpool such if specific thread not on task in x amount of time, returns i.e if broker down , publish not go through, thread not keep waiting , instead return pool. there no way of make publish call asynchronous, way handle situation 1 mentioned above guess. are there threadexecutors out there allow me terminate thread immidiately, if thread not able complete task in given timeframe?? would love more elegant solution someone. the executorservice interface offers methods invokeall() , invokeany() timeout parameter. example: executorservice executor = executors..newfixedthreadpool(2); executor.invokeall(arrays.aslist(new callable<void>(){ @override p...

java - Traversing a Huffman Tree -

so have program creates huffman tree. tree made of "hnodes" these fields: right (points right child) left (points left child) code (string of integers, ideally 0's , 1's huffman code of node) character (the character contained in node). i have created huffman tree adding nodes linked list - know tree created correctly. created tree, told node when gave parent node, if parent's "right", code string 1, if left 0. after entire tree created, each node going have either 0 or 1, not yet string 00100101. question is, have tree, can can traverse it? understand thought give each child parent's code + child's own code, not understand how loop through tree accomplish this. thank in advance. maybe this? expandbinarypaths(node, prefix) 1. if node null return 2. else 3. node.binary = prefix concat node.binary 4. expandbinarypaths(node.left, node.binary) 5. expandbinarypaths(node.right, node.binary) 6. return...

symbian - Unescaped backslashes are Deprecated at mobility.prf:1 -

i new qt symbian development , stuck @ 1 problem when tried build qt project 3 warnings occurred there stops build process: warning: d:\qtsdk\simulator\qt\msvc2008\mkspecs\features\mobility.prf:1: unescaped backslashes deprecated. warning: c:\qtsdk\simulator\qt\msvc2008\mkspecs\features\mobility.prf:1: unescaped backslashes deprecated. warning: c:\qtsdk\simulator\qt\msvc2008\mkspecs\features\mobility.prf:1: unescaped backslashes deprecated. please me rectify issue why these warnings occurring. thanks i have resolved it.... uninstalling qt , re-install it...

winforms - how to get RGB numerical equivalent of color in vb.net -

net there many standard colors available . how know there numerical value. want numerical values changing can obtain required shades not available standard colors. e.g black know numerical rgb equivalent 0, 0, 0 rgb values olive color? how color name numeric rgb value conversion since of colors of color object, need instantiate color , call color methods want to. you want this: console.write(color.olive.r & " " & color.olive.g & " " & color.olive.b)

python - IO within the Program Files Directory -

i made program both gathers data .txt file reading it, , writes data different .txt file. however, there problem. when run program in normal directory runs fine. problem arises when place in c:\program files directory. when run ioerror: [errno 13] permission denied: 'my subdirectory' . believe due directory having protocols when comes editing files within it. this in windows 7, if wasn't apparent. also if makes difference program written in python converted .exe py2exe. all directories under \program files , \windows , root of c:\ , require administrator privileges in windows vista , 7 (and xp, when running non-administrative user, not default). shouldn't trying write there in first place. security measure prevent malware getting places shouldn't. since vista has been out several years, there plenty of articles available on uac . can start here .

MySQL Grouping SubQuery Optimization -

i have table of categories, , table of products. products have category_id, , maker_id. i attempting return table of category names, along binary of whether or not category contains products belong given $maker_id (as defined in php code). my current method counts how many matching products in each category, i'm assuming there faster way since need yes/no. current code: select c.name, sum(case when p.maker_id = '{$maker_id}' 1 else 0 end) already_used categories c left join products p on p.category_id = c.id group c.id i'm reading on using exists, examples i've found using in clause. thanks! you can try this: select c.name,count(1) already_used, sum(if(p.status = 'ready', 1, 0)) ready_count categories c left join products p on (p.category_id = c.id) p.maker_id = '{$maker_id}' group c.id;

How to properly escape a string via PHP and mysql -

can explain difference between using mysql_real_escape_string on string or wrapping `` around column. for example "insert table (``column``) values ('$string')" or $escapestring = mysql_real_escape_string($string); "insert table (column) values ('$escapedstring')" what difference between these 2 , should use? thanks. there's difference between backtick ` , single quote ' . the backtick intended escape table , field names may conflict mysql reserved words. if had field named date , query select date mytable i'd need escape use of date when mysql parses query, interpret use of date field rather datatype date . the single quote ' intended literal values, in select * mytable somefield='somevalue' . if somevalue contains single quotes, need escaped prevent premature closing of quote literal.

linq - Iterate data in anonymous variable -

i have datatable containing data, , going fetch data using linq datatable. the query looks this: var requireddata=dt.asenumerable() .where(row => row.field<byte>("id") == 1) .select(x=> { id = x.field<int>("id"), yyyyy = x.field<string>("columnname2"), zzzzz = x.field<string>("columnname3") } ); now, please how iterate-through "requireddata"? you use foreach loop: foreach (var item in requireddata) { // todo: use item.id, item.yyyyy , item.zzzzz here }

php - How to highlight rows if they contain duplicate data? -

i have following data: +------+-------------------+--------------------+ | id | number | colour | +------+-------------------+--------------------+ | 1766 | 53 | red | | 1767 | 3 | green | | 1768 | 202 | green | | 1769 | 52 | blue | | 1770 | 56 | orange | | 1771 | 90 | yellow | | 1772 | 28 | teal | | 1773 | 276 | purple | | 1774 | 23 | black | | 1775 | 23 | orange | +------+-------------------+--------------------+ the important column here in colour column. want display above rows (in html table) want highlight rows have duplicate colours. i.e. 2 green rows , 2 orange rows. ideally end column contain boolean (or really) check when displaying table. well, don't ne...

import - Haskell deriving additional instances for imported datatypes -

i'm relatively new haskell. write clone of card game uno , want pretty coloured output of card. do import system.console.ansi which provides data color = black | red | green | yellow | blue | magenta | cyan | white deriving (bounded, enum, show) now want add deriving (ord, eq) well, write in source file of imported package, there should easier way this. don't have clue keywords google or in book. no need edit library. in source file, state: instance eq color x == y = fromenum x == fromenum y instance ord color compare x y = compare (fromenum x) (fromenum y) explanation: fromenum function on enum returns int ( black -> 0 , red -> 1 , etc.). integers equality-comparable , ordered. edit : @rampion's version, in comments, prettier: instance eq color (==) = (==) `on` fromenum instance ord color compare = compare `on` fromenum

c# - concatinating int[] to same size string[] -

i have: int[] numbers = { 1, 2, 3}; string[] words = { "one", "two", "three" }; and need output 1=one 2=two 3=three thanks if same size can use int[] numbers = { 1, 2, 3}; string[] words = { "one", "two", "three" }; var list = numbers.zip (words, (n, w) => n + "=" + w); but note if differ in size non match items ignored

c++ - SHGetFolderPath': identifier not found -

i doing sample using directx 9 on vs 2008/windows7. getting error. 1>------ build started: project: videocapture, configuration: debug unicode win32 ------ 1>compiling... 1>videocapturedlg.cpp 1>.\videocapturedlg.cpp(169) : error c2065: 'shgfp_type_current' : undeclared identifier 1>.\videocapturedlg.cpp(169) : error c3861: 'shgetfolderpath': identifier not found 1>.\videocapturedlg.cpp(173) : error c2065: 'shgfp_type_current' : undeclared identifier 1>.\videocapturedlg.cpp(173) : error c3861: 'shgetfolderpath': identifier not found 1>.\videocapturedlg.cpp(1025) : warning c4244: 'argument' : conversion 'int' 'word', possible loss of data 1>.\videocapturedlg.cpp(1180) : error c2065: 'shgfp_type_current' : undeclared identifier 1>.\videocapturedlg.cpp(1180) : error c3861: 'shgetfolderpath': identifier not found 1>.\videocapturedlg.cpp(1184) : error c2065: 'shgfp_ty...

urlencode - C - URL encoding -

is there simple way url encode in c? i'm using libcurl haven't found method. specifically, need percent escapes. curl_escape which apparently has been superseded curl_easy_escape

How to print hidden files/folders list using NAnt script? -

current try below skip hidden files/folders. want see them. please if know trick! thank you. <foreach item="folder" property="foldername"> <in> <items> <include name=".\**" /> </items> </in> <do> <echo message="${foldername}" /> </do> </foreach> are sure skipped because they're hidden? i'm more inclined files not listed in default excludes . should try disabling these excludes , see if helps: <foreach item="folder" property="foldername"> <in> <items defaultexcludes="false"> <include name=".\**" /> </items> </in> <do> <echo message="${foldername}" /> </do> </foreach>

Castle optional(property) dependency problem, in realtion with Typed Factory facility -

i'm facing following problem given pseudo code, public interface ia { ... } public interface ib { ia someoptionaldependency; } public interface irepositorya { ... ia getdefault(); ia get(object id); } public interface ifactoryb { ib create(); ib create(ia a); } public class b : ib { public b(irepositorya repoa) { _repoa=repoa; } public ia someoptionaldependency { get{ if (_someoptionaldependency==null) _someoptionaldependency=_repoa.getdefault(); return _someoptionaldependency; } set{ if (_someoptionaldependency!=null) throw(new exception("this read only"); _someoptionaldependency=value; } } private ia _someoptionaldependency; private irepositorya _repoa; } [testfixture] public class test { [test] ...

ws addressing - Apache CXF and WS-A properties -

can please tell me how resolve warning message receiving? warn 13 oct 2011 15:23:46,024 contextutils - ws-addressing - failed retrieve message addressing properties context it doesn't seem have negative side effects although clutters logs , don't software complain. this link has information on how adjust cxf logging levels: http://cxf.apache.org/docs/debugging-and-logging.html the code looks logging message @ 'fine' , 'warn' levels: if (maps != null) { log.log(level.fine, "current maps {0}", maps); } else if (!isprovidercontext) { logutils.log(log, warnifmissing ? level.warning : level.fine, "maps_retrieval_failure_msg"); } you can adjust logger accordingly. thanks.

mysql - SQL query for words (not the sentence) -

i query single column (varchar): sample datarows: 1) fox jumps foo on bar 2) jumpers not cool 3) apple introduced ijump when enter search criteria like... jump i expect resultset of: jumps, jumpers, ijump (so dont want complete row) currently i'm using mysql (i'm open suggestions long it's open source) since you're using mysql, might suggest looking lib_mysqludf_preg . this open source library provide additional regex functionality, including preg_capture function, extracts regex match string. using function, build regex return match you're looking for... like: \b\w*jump\w*\b

javascript - use alt + shift + a as a hotkey in IE 7/8 -

i trying attach keyup listener on document object. wanna know when user presses alt + shift + a or alt + shift + w . both work in chrome , firefox. in ie, alt + shift + w works, alt + shift + a doesn't. know ie has few hot keys reserved, why taking on alt + shift combination, too? there way prevent or flow in ie? demo: http://jsfiddle.net/hnd5e/ thanks you can around behavior keydown event. $(document).keydown(function (e) { if (e.keycode == 65 && e.altkey) { e.preventdefault(); } }).keyup(...); http://jsfiddle.net/hnd5e/4/

multitasking - Resuming application after switching to other application in WP7 -

i wrote application windows phone 7 search database online , opens link in internet explorer webbrowsertask . when internet explorer opens application minimizes usual thing happen. and when application running in background shows message " resuming " , application started beginning. changes made gone.(the search results) how preserve these changes when application running in background, when multitasking. i believe answered question on @ question: i have windows phone 7 application how make sure supports fast task switching? . check out , let me know if meets needs.

converting pixel data to image in java -

hi have data of image of size 640 * 480 pixels, data in format of 0s , 1s, in txt file. therefore there 640*480=307200 characters (0s , 1s) in text file. catch 0 means there nothing in original image (say black background) , 1 means there (say user standing , pertaining user blob) , hence not mistaken rgb or byte data. i need read , convert image of size 640*480 pixels in java,where pixels indicated 0 may set 1 color (say black) , 1 other (say white). how do it??? help. first, need read in. if know it's width, can this: bufferedreader in = new bufferedreader(new filereader("myfile.txt")); boolean[][] mask = new boolean[640][480]; int = -1; int count = 0; while((i = in.read()) !- -1) { int x = count % 640; int y = count / 640; mask[x][y] = (i == '1'); count++; } then can paint this paint(graphics g) { g.setcolor(color.black); g.drawrect(0,0,640,480); // draw black background // mask white g.setcolor(color.w...

tsql - Database Design SQL -

Image
my question is: notice putting mvrid in many tables. opinion of following desing below. how can improve it? if point me book hope page of book. can execute script on database called medicalvariance if want see whole thing. use medicalvariance; --this quick install script --i guess execute front end overkill --because of audience install software dba's if exists ( --the query below will evaluate true if finds foreign key constraint. select 1 information_schema.table_constraints constraint_type 'foreign key' ) begin declare @tablename nvarchar(100) declare @constraintname nvarchar(100) declare @dynamicsqlexec nvarchar(300) --declare , feed cursor data declare constraintcursor cursor fast_forward -- dont worry wont drop precious foreign keys since catalog must medicalvariance select table_name,constraint_name information_schema.table_constraints constraint_type 'foreign key' , ...

css - How to make a div disappear on hover without it flickering when the mouse moves? -

i've seen answers suggesting display:none on :hover css. makes div flicker when mouse moving. edit: added jsfiddle display:none take element out of render tree, loses :hover state immediately, reappears , gets :hover again, disappears, reappears, etc... what you need is: #elem { opacity:0; filter:alpha(opacity=0); } it leave place empty, no flickering appear. ( demo or yours updated )

security - is it possible to change the set of permissions for an Android app dynamically? -

is possible @ application level? or have inside os? people might want reduce attack surface. ideally, application, @ virtually point of time, should have permission if needed, following `principle of least privilege'. to clarify : "change", mean give permissions temporarily, , regain them sometime later when needed. it against clarity android policys . application has or not has permisions doing . can security problem if can think of it.

cannot urllib.urlencode a URL in python -

why getting error when trying urlencode string >>> callback = "http://localhost/application/authtwitter?twittercallback" >>> urllib.urlencode(callback) traceback (most recent call last): file "<stdin>", line 1, in <module> file "/usr/lib/python2.7/urllib.py", line 1261, in urlencode raise typeerror typeerror: not valid non-string sequence or mapping object that's not function does: urlencode(query, doseq=0) encode sequence of two-element tuples or dictionary url query string. are looking urllib.quote(callback) ?

Differential Equations in Python -

i'm working de system, , wanted know commonly used python library solve differential equations if any. my equations non linear first order equations. if need solve large nonlinear systems (especially stiff ones), scipy tools slow , awkward. pydstool package quite commonly used in situation. lets equations automatically converted c code , integrates them solvers. it's if want define state-defined events such threshold crossings, add external input signals arrays, or have other analyses done (such bifurcation analysis, package includes interface auto).

ruby on rails - How would I parse this url to get the id? -

i want parse url using ruby id 33: http://www.domain.com/?id=33 how this? with regular expression /\d+\z/ . can build such 1 using rubular example. given expression extracts id under condition, no other characters follow post id , id contains digits.

node.js - node-o3-canvas vs. node-canvas? -

does have experience either or both of these node.js libraries? curious hear success or difficulties each one. learnboost 1 of prolific node module developers in community , reason went node-canvas on node-o3-canvas. i used node-canvas slice image tiles on server , send them client. works expect. here sample of kind of code might write: helper = function(x, y, canvas) { return function(err, str) { if (!tiles[x]) { tiles[x] = []; } tiles[x][y] = { data: str , buffer: canvas.tobuffer() , covered: true }; }; }; (y = 0; y < tilespercolumn; y += 1) { (x = 0; x < tilesperrow; x += 1) { //create new tile canvas each time don't run on each other tcanvas = new canvas(chunksize, chunksize); tctx = tcanvas.getcontext('2d'); xoffset = chunksize * x; yoffset = chunksize * y; //save set of uncovered tiles store in memo...

java - Composite primary key with not primitive attributes -

i new java , hibernate. i've got problem composite key. trying that: @entity class { @id int id; } @entity class b { @id int id; } @entity class c { @embeddedid c_pk c_pk; } @embeddable class c_pk { a; b b; } when perform ... session.save(c); ... then exception thrown type of , b cannot inserted database. possible somehow tell hibernate don't save object id? approach absolutely wrong , should use primitive data types @ c_pk class? you should put @manytoone (or onetoone ) join columns on , b references in c_pk. @embeddable class c_pk { @manytoone a; @manytoone b b; }

regex - JavaScript match ( followed by a digit -

in string n+n(n+n) , n stands number or digit, i'd match ( , replace *( , if followed number or digit. examples: i'd change 2+22(2+2) 2+22*(2+2) , i'd change -1(3) -1*(3) , 4+(5/6) should stay is. this have: var str = '2+2(2+2)'.replace(/^[0-9]\(/g, '*('); but doesn't work. in advance. remove ^ , , group digits: '2+2(2+2)'.replace(/([0-9])\(/g, '$1*(') '2+2(2+2)'.replace(/(\d)\(/g, '$1*(') //another option: [0-9] = \d suggestion : 2. valid number (= 2 ). following regexp removes dot between number , parenthesis. '2+2(2+2)'.replace(/(\d\).?\(/g, '$1*(') //2.(2+2) = 2*(2+2) parentheses create group, can referenced using $n , n index of group: $1 . you started regexp ^... , means: match part of string starts ... . behaviour not intended.

Getting input values from tables with jQuery -

right now, html code looks so: <div id="register"> <table class="tab2"> <tr> <td>email:</td> <td><input type="text" id="email" /></td> </tr> <tr> <td>confirm email:</td> <td><input type="text" id="confirmemail" /></td> </tr> </table> </div> and values inputs via jquery, have this: $("#email").live('focusout', function() { email = $(this).val(); }); $("#confirmemail").live('focusout', function() { confirmemail = $(this).val(); }); i know there better solutions perform (as solution works , messy since there's way more 2 inputs), won't work me. i'd use like $("#email").val(); and retrieve value it's needed, rather storing variable. issue whenever run code, retu...

php - Show delete link on comments -

i have page shows comments posted users. here need show delete link on side of comments posted current logged in user , should able delete comment (like in facebook, orkut or blogging site). sample code have tried is: <?php $user_id = 1; $con = mysql_connect("localhost","root","root"); if (!$con) { die('could not connect: ' . mysql_error()); } mysql_select_db("blog", $con); $result = mysql_query("select * replies"); while($row = mysql_fetch_array($result)) { $replies = $row; if($replies['poster_id' == $user_id]){ $delete = '<a href="#">delete</a>'; } echo $replies['poster_id']?></a>&nbsp;¦&nbsp;<?php echo $replies['reply_text']?>&nbsp;¦&nbsp; <?php echo $delete?></div> <?php echo "<br />"; } mysql_close($con); ?> here have given user_id hardcoded here. got is, delete ...