Posts

Showing posts from January, 2013

Why is Node.js named Node.js? -

i'm curious why node.js named that. searched site , faq , there nothing helped me understand why named node.js. the official name node . designed use web application, author realized used more general purposes , renamed node. here a quote author may explain name: node single-threaded, single-process system enforces shared-nothing design os process boundaries. has rather libraries networking. believe basis designing large distributed programs. “nodes” need organized: given communication protocol, told how connect each other. in next couple months working on libraries node allow these networks.

html - Image as link in IE9 -

i have link " <a ... ></a> " , within image "" something like: " <a...><img src.../></a> " my problem in ie9 (do not know if occurs in versions prior ie9) putting edge in image. in other images on page, has no links, problem not occur. how can take edge off these images have associated links try css: img{ border: 0 }

c# - Visual Studio won't update properties of my Data Source -

i using class "invoice" data source. after adding more properties it, visual studio refuses refresh data source , can't find new properties in data source. tried restarting project, deleting , adding object datasource again. did not work. problem intellisense going out of date due changes in data source. solution rebuild project.

java - SCJP: Program not terminating after uncaught exception -

public class threads2 implements runnable { public void run() { system.out.println("run."); throw new runtimeexception("problem"); } public static void main(string[] args) { thread t = new thread(new threads2()); t.start(); system.out.println("end of method."); } } i predicted output run. //exception but showing output as, run exception end of method (or) run end of method exception i wonder, once exception has occurred program terminate, right? no, program not terminate, thread does. when thread throws uncaught exception terminates. main thread continues running.

java - Apache Tomcat Request Threads -

we have application leaks bit of memory, bit being understatement. i using jvisualvm try , find causing problem. i see thread count grow quite bit on threads starting name: http-8080- example: http:8080-42 my first guess each of threads request hit client, each client request handled in own thread. my problem threads have been running long periods of time (thus far 10mins). my question this: is assumption correct? if so, why threads run such long time? surely can't still busy serving clients request? tomcat has number of waiting http threads, example if @ default connector setting: <connector port="80" maxhttpheadersize="8192" maxthreads="150" minsparethreads="25" maxsparethreads="75" enablelookups="false" redirectport="8443" acceptcount="100" connectiontimeout="20000" disableuploadtimeout="true" /> we can ...

smiley to image - optimized PHP code -

is code or can optimized ? $tempmsg = str_replace("[:)]","<img src='img/smiley0.png' title='smile' height='100' width='100'>",$tempmsg); 1/ can optimized? it pretty good, you're not using regular expressions (preg_replace) no worries here. 2/ code to me not readable. how if need replace other smileys? not reusable. here first step towards better readability, increased reusability, ... might bit slower, tend favor reusability on performance until need optimize. function replace_smiley($text) { $replacements = array( ":)" => "image1.jpg", ":(" => "image2.jpg" ); $out = $text; foreach ($replacements $code => $image) { $html = '<img src="img/' . $image . ' alt="' . $code . '" height="100" width="100" />'; $out = str_replace($code, $html, $out); } return $out; ...

visual studio 2010 - Getting an Unhandled Exception in VS2010 debugger even though the exception IS handled -

i have issue vs2010 debugger stops unhandled exception. however, exception handled. in fact, if put code in catch block, i'll hit when press f5. in debug -> exceptions, not have "thrown" checkbox checked, imo there absolutely no reason unhandled exception dialog pop up... i can't post exact code, work on sample soon. basic idea behind offending code section have thread talks hardware, , if have error talking it, throw hardwareexception . thread launched begininvoke , , exception caught in callback handler when call endinvoke . when exception thrown in debugger, messagebox says 'hardwareexception not handled user code". is!!! edit -- well, driving me crazy. i've got sample code representative of code have in application, , looks this: using system; using system.collections.generic; using system.linq; using system.text; using system.runtime.remoting.messaging; using system.threading; namespace consoleapplication1 { public class h...

Is there a way to let Eclipse CDT have a default or shared linker flag entry for all projects? -

basically, want able add "-static-libgcc -static-libstdc++" linker flag projects making. can manually each project start with, shouldn't there easier , more efficient way share linker flag new projects (they need not existing ones)? dev-c++ has linker flag settings shared projects far know (same settings linker). can forego if eclipse had way show output of running program in "console" pane (but accept separate problem). linker flags above make possible, yeah. thanks in advance.

php - How to extract session ID from URL? -

hi possible embedded session id url using php? from root url, http://www.sbstransit.com.sg/mobileiris/ , website generate session id between url , become that. i.e http://www.sbstransit.com.sg/mobileiris/(ts2k1e55xaah50iwodsvjy35)/index.aspx . isit possible use php/any other ways retrieve "ts2k1e55xaah50iwodsvjy35" out querying root url without physically going url? if use wget page, you'll see: ... http request sent, awaiting response... 302 found location: http://www.sbstransit.com.sg/mobileiris/(xidluk550vzs5045l1cxkh55)/index.aspx [following] which indicates doing 302 redirect url containing id. you can write perl (or other) code find redirected url: #!/usr/bin/perl use warnings; use strict; use lwp::useragent; $ua = lwp::useragent->new; $ua->requests_redirectable([]); # don't follow redirects $response = $ua->get('http://www.sbstransit.com.sg/mobileiris/'); $loc = $response->header('location'); print ...

iphone - Reuse cells of a scroll view -

i using scrollview display various items in horizontal fashion. how can "reuse cells" conserve memory: edit: apologies not being clear. plan place few labels , and imageview inside each imageview keen reuse each time instead of instantiating new items each time. e.g. change image's , update labels instead of re-create it. // implement viewdidload additional setup after loading view, typically nib. - (void)viewdidload { [super viewdidload]; // load images our bundle , add them scroll view // nsuinteger i; (int = 0; <= 150; i++) { nsstring *imagename = @"tempimage.jpg"; uiimage *image = [uiimage imagenamed:imagename]; uiimageview *imageview = [[uiimageview alloc] initwithimage:image]; // setup each frame default height , width, placed when call "updatescrolllist" cgrect rect = imageview.frame; rect.size.height = kscrollobjheight; rect.size.width = kscrollobjwidth; ...

sql - Uniqueidentifier Philosophy in my scneario -

i have 3 column table none of columns unique. added id column table uniqueidentifier , made primary. 1 quesion: if 2 rows same values in columns added table, happens second one? added or not? how can avoid such things in scenario? if 3 non-id columns not have unique constraint, , not part of primary key, can add multiple rows exact same values. if want avoid duplicate rows, best bet apply unique constraint on @ least 1 or more of 3 columns. if can't reason, should post schema , think problem more it. if can't use unique constraint, 1 way avoid duplicates be: when you're going insert record, first check see if record exists, , if exists, decide how want handle it.

concurrency - How start identical jobs with different parameters in parallel execution? -

i have build job , test job parameters. i want after build job, simultaneously run test job 1 parameter , same test job different parameters in parallel execution. build job | / \ test job test job 1 params other params | | how accomplish , whether possible perform without having write own plugin? thanks! when create test job, create "build multi-configuration project" while configuring job select "configuration matrix" "user-defined axis" you can use name of axis parameter in job. given parameters started simultaneous in different jobs. (if enough executors available)

visual studio - More line in console output of VS2010 -

when run program in vs2010, because output quite lot,the console discards previous output. for example, consider output of 400 lines, lines 1 80 not displayed, lines 81 400 displayed. any idea of how can see entire output? you can change buffering settings of console: right click title bar of console window , select "properties." on "layout" tab, change "height" of screen buffer large number (9999, example). run program again. of course, if have large amount of output need inspect on regular basis, it's best write file instead.

r - Writing a function to analyze a subset within a dataframe -

i trying write function aggregate or subset data frame particular column, , count proportion of values in column within dataframe values. specifically, relevant parts of data frame, allmutations, this: gennumber sel 1 -0.00351647088810292 1 0.000728499401888683 1 0.0354633950503043 1 0.000209700229276244 2 6.42307549736376e-05 2 -0.0497259605114181 2 -0.000371856995145525 within each generation (gennumber), count proportion of values in “sel” greater 0.001, between -0.001 , 0.001, , less -0.001. on entire data set, i've been doing this: ben <- allmutations$sel > 0.001 #this generations bencount <- length(which(ben==true)) totalmu <- length(ben) # #length(ben) = total # of mutants tot.pben <- bencount/totalmu #proportion what best way operation each value in gennumber? also, there easy way proportion of values in range -0.001 ...

solaris - How to Use posix_spawn() in Java -

i've inherited legacy application uses processbuilder.start() execute script on solaris 10 server. unfortunately, script call fails due memory issue, documented here oracle's recommendation use posix_spawn() since, under covers, processbuilder.start() using fork/exec . i have been unable find examples (e.g., how call "myscript.sh" ) using posix_spawn() in java, or packages required. could please, point me simple example on how use posix_spawn() in java? you need familiarize jni first. learn how call out native routine java code. once - can @ this example , see if helps issue. of particular interest is: if( (rc=posix_spawn(&pid, spawnedargs[0], null, null, spawnedargs, null)) !=0 ){ printf("error while executing posix_spawn(), return code posix_spawn()=%d",rc); }

c# - Problem with Encoding in FileOpen and StringBuilder in i18n -

when @ file have saved i18n, ok example there "fïll Âll ülle~" in want..but way in code trying read contects of file , return string thing that: string sline = string.empty; stringbuilder shtmltext = new stringbuilder(); int nfilehandle = filesystem.freefile(); shtmltext.append(string.empty); filesystem.fileopen(nfilehandle, sfilename, openmode.input, openaccess.default, openshare.default, -1); while (!filesystem.eof(nfilehandle)) { sline = filesystem.lineinput(nfilehandle); shtmltext.append(sline); }; filesystem.fileclose(nfilehandle); return shtmltext.tostring(); but when debugging it, corrupting correct translated stuff "fïll Âll ülle~" , manipulating them, think method not doing in way honors encoding have set computer regional/language settings french .... how can correct existing code or write similar cares encoding , lang set on computer? thsan...

c# - Unable to implicitly convert value from enum even though the underlying type is specified -

in following code sample define enum , specify underlying type byte. attempt assign byte value , switch on enum's values error: cannot implicitly convert type 'cmdlnflags' 'byte'. explicit conversion exists (are missing cast?) the code: using system; public enum cmdlnflags: byte { vala = (byte)'a', valb = (byte)'b', } public class sample { public static void main() { byte switchbyte = cmdlnflags.valb; switch (switchbyte) { case cmdlnflags.vala: console.writeline('a'); break; case cmdlnflags.valb: console.writeline('b'); break; } console.readkey(); } } it's easy enough fix, cast byte, why have cast if underlying type specified enum? what's point of specifying underlying type if have cast anyway? if cast, works. example: byte switchbyte = (byte)cmdlnflags.valb; switch (switchbyte) { case (byte)cmdlnflags.vala: cons...

.net - Delete a lot of files and sub folders with c# and threads -

does have sample or no how delete lot of files , sub directories in folder threads , c# .net. thanks the best way call directory.delete(directory, true); delete directory, of subdirectories, , files. no threading required. if want asynchronously (i.e. have program other things while directory deletion happening), take @ calling synchronous methods asynchronously .

java - Drawing something in front of any other object/drawing -

i making small game, , need more it. want make if player1 , player2 finished, white screen pop on whole screen in front of object or drawing made. i'm using code @ moment: if( isfinishedp1 == true && isfinishedp2 == true ){ graphics2d b = buffer.creategraphics(); system.out.println("both finished, drawing whitescreen!"); b.setcolor( color.white ); b.fillrect(0, 0, 800, 600); b.dispose(); } my console says both finished, won't draw white screen. don't see anything, , have suspicions it's drawing behind background , objects. place white screen, rectangle, @ (0,0) (x , y coordinates respectively), , window 800x600 (width x height). how draw rectangles in front of object, or there better way this? purpose of white screen act "endgame screen" can select if want again, or go next level. there no errors when execute code. in code showing draw buffer whithout specifying comes , goes to. in...

c# - Function to look through list and determine trend -

so have list of items. each item on list has property called notional . now, list sorted. need is, develop function sets type of list 1 of following: bullet - notional same every item amortizing - notional decreases on course of schedule (might stay same element element should never go up, , should end lower) accreting - notional increases on course of schedule (might stay same element element should never go down, , should end higher) rollercoaster - notional goes , down (could end same, higher, or lower, shouldn't same each element , shouldn't classfied other types) what method , efficient way go through list , figure out? thanks! this straightforward way it: bool hasgoneup = false; bool hasgonedown = false; t previous = null; // t type of objects in list; assuming ref type foreach(var item in list) { if (previous == null) { previous = item; continue; } hasgoneup = hasgoneup || item.notional > previous.notional; ...

How would I use regex to check for a value that has two fixed uppercase letters followed by numeric values in PHP or jQuery? -

an example "su1203" or "up1234" or 2 letters followed numeric values. thanks this can solved quite simple expression ^[a-z]{2}\d+$ in javascript can use test() method: if(/^[a-z]{2}\d+$/.test(str)) and in php, preg_match : if(preg_match('/^[a-z]{2}\d+$/', $str) === 1) i suggest learn regular expressions . see also: regular expressions in javascript regular expressions in php

java - buttons ontop of everything in android -

i working on calculator application android. finding difficult conveniently take screen shot of app. have put calculator on pause can write simple screen shot app. runs in notification bar , when click notification notification bar slides away , few seconds later snapshot taken. works perfectly. add functionality take snapshots full screen apps. have seen apps put sliding drawer on screen onto of whatever app running. there button on screen no matter doing when click/drag sliding drawer came out. how did that? should simple process use button instead of drawer , when it's clicked hide it, snapshot , unhide it. so question bsically is how can put usable button on screen stays above whatever app running, homescreen i realize i'm not answering question directly, if want screen capture of application running, use ddms in android tools directory. has menu option getting screen grab. use frequently. just go device > screen capture more details here : http://d...

.net - Batch data processing in real time -

i tasked optimizing performance of linear data processing routine. here's overview of what's in place: data comes in on udp ports, have multiple listeners listening on different port , writing raw data sql server database (lets call table rawdata). have multiple instances of single threaded linear application grabbing raw data rawdata table , processing individual datarows. processing means raw data compared received data given entity, calculations done calculate number of different readings, couple of web services called each individual data row , new record added each data row in processeddata table. corresponding entity record updated in other table. the way see problem, can broken down smaller parts , utilize producer/consumer pattern data processing: 1 thread of producer populates shared (blocking) queue, multiple consumers grab data rows queue , parallel processing of them. after consumers done put processed data shared queue, accessed yet consumer thread (single)...

jquery - DoEvents in JavaScript -

i have following: $('body, a').addclass('cursor-wait'); (var i=0, l = myarray.length; < l; i++) { // tight loop here } $('body, a').removeclass('cursor-wait'); but i'm not sure cursor:wait icon showing immediately. q: there way tell "doevents" in javascript, such know dom being updated before goes loop? maybe using settimeout method. here's happening: the browser instance handling page single threaded. change dom happens right away. however, while script running, browser blocked , not able run layout manager updates page according css classes have changed. correct settimeout best way cede control layout manager , see changes on screen. don't need set delay, simple act of calling settimeout allows layout manager chance redraw page. $('body, a').addclass('cursor-wait'); settimeout(function () { (var i=0, l = myarray.length; < l; i++) { // tight loop here } $('bod...

python - return outside function, or unexpected indent -

i have this: if colorkey not none: if colorkey -1: colorkey = image.get_at((0,0)) image.set_colorkey(colorkey, rleaccel) return image, image.get_rect() it tells me "return" outside function. when change this: if colorkey not none: if colorkey -1: colorkey = image.get_at((0,0)) image.set_colorkey(colorkey, rleaccel) return image, image.get_rect() it tells me there unexpected indent. how around this? in python, scopes defined same level of indentation instead of braces (i.e. {} ) in other languages. if write function, need ensure function body @ same level of indentation - same amount of spaces or same amount of tabs (mixing spaces , tabs can result in real mess). in case, correct indentation similar (i not know exactly, because didn't post code whole function): def function(): <indent>if colorkey not none: <indent><indent>if colorkey -1: <indent><indent><indent>colorkey ...

i want to fetch that from mysql database using codeigniter framework php? -

i want fetch through model select `id`, `name`, `visits`, `shortdes`, `photo` `products` `name` '$word' or `shortdes` '$word' , `valid` = 1 order `id` desc i used that, returned false $this->db->order_by('id', 'desc'); $this->db->like('name', $word); $this->db->or_like('shortdes', $word); $this->db->where('valid', 1); $this->db->select('id, name, visits, shortdes, photo'); $query = $this->db->get('products'); what can use? for debugging codeigniter's query builder query's, reccommend doing debug them , see query statements producing. $this->db->order_by('id', 'desc'); $this->db->like('name', $word); $this->db->or_like('shortdes', $word); $this->db->where('valid', 1); $this->db->select('id, name, visits, shortdes, photo'); $query = $this->db->get(...

objective c - Putting an ADBannerView on top of a UINavigationController -

i'm trying put iad banner in app based on uinavigationcontroller (it's not standard nav-base app proposed xcode, cause don't need table view). i'd place adbanner on bottom, visible, no matter how user pops , pushes views. i studied iadsuite example in apple sample code, but, though it's reported among "best practices", don't think it's best practice need. declares adbannerview in app delegate class , implements adbannerviewdelegate methods every single view app needs. means implementing adbannerviewdelegate methods on , on again on every view controller class need! doesn't seem smart... :( i'd rather prefer have approach more similar apple in tab bar based app, have part of window occupied tab controller , views switching above without affecting tab bar view below. can't directly put adbannerview along nav controller in app delegate, because adbanner needs placed in view controller (you runtime error otherwise). i tried subcla...

mod rewrite - Pulling my hair out with mod_rewrite and MAMP -

i'm using mamp , can't mod_rewrites work. after lots of playing numerous http.conf files , looked @ php_info, there no mod_rewrite exstension installed. i opened php.ini files in applications > mamp > conf > php5.2 & php5.3 , looked @ exstensions , there no mod_rewrite.so. can see is: extension=imap.so extension=yaz.so extension=mcrypt.so extension=gettext.so extension=pgsql.so extension=pdo_pgsql.so extension=pdo_mysql.so i added expecting stroke of luck - no joy! i had same problem , solve you. i added site in host file instead of going through locahost/..... had own url redirected 127.0.0.1. i.e. host file looked this 127.0.0.1 mysite.local i set virtual host in mamp. find vhosts.conf file in /applications/mamp/conf/apache my host file looks this namevirtualhost * <virtualhost *> documentroot "/applications/mamp/htdocs" servername localhost </virtualhost> <virtualhost *> documentroot ...

signal processing - kissfft scaling -

i looking compute fast correlation using ffts , kissfft library, , scaling needs precise. scaling necessary (forward , backwards) , value use scale data? the 3 common fft scaling factors are: 1.0 forward fft, 1.0/n inverse fft 1.0/n forward fft, 1.0 inverse fft 1.0/sqrt(n) in both directions, fft & ifft given possible ambiguity in documentation, , whatever scaling user expects "correct" purposes, best feed pure sine wave of known (1.0 float or 255 integer) amplitude , periodic in fft length fft (and/or ifft) in question, , see if scaling matches 1 of above, maybe different 1 of above 2x or sqrt(2), or desired scaling different. e.g. write unit test kissfft in environment data types.

asp.net - Best way to handle WCF message authentication in the cloud (C#) -

i've looked many sources, , found many examples, none fit situation hope take project to. writing bunch of wcf services, publicly accessible, others not (server server), allow flexible cloud app ensures ability scale out service needed through azure. unsure way go message authentication, want make sure particular user logged in, can perform different tasks, , prevent others running tasks. most of have seen uses roles or asp.net membership. have own custom membership users use login with, , don't rely on standard membership providers, or active directory. recommendation? thought creating token created on successful login, stored within cookie, added parameter passed each method, research, think might able handled without modifying methods. what thoughts? you can implement authentication without needing manually pass token functions using usernameauthentication , writing custom validator - there straightforward tutorial here if use usernameauthentication, need ...

Fastest running scripting language for use with Java -

i know best (fastest) scripting language use in java. don't care if takes long load (as long 1 time load), opposed how fast runs. using jython (python) faster. there's lot of benchmarks , discussions on this. while don't give lot of credit (none) benchmarking. top 2 contenders (listed in order of performance speed): scala groovy++ i've tried both , not same in use cases. scala came out faster groovy++ (again.. use cases not , may show differently in use cases). scala native java speeds. groovy (not groovy++), closure, jruby slow. groovy , jruby run approximately 8 times slower on simple algorithms compared java versions after decent amount of warmup. i can't guarantee same numbers did decent order try them in.

sql - How to select the latest rows where each contains one value of all possible values found in a domain table? -

id username city registeryear 1 user1 new york 1990 2 user2 san diego 2008 3 user3 chicago 2009 4 user4 los angeles 1994 5 user5 san diego 2004 domain table id city 1 new york 2 san diego 3 los angeles 4 chicago in example query return: user1 user2 user3 user4 well, first need replace "city" in first table id column of domain table. "city" not primary key. after that: select u.username users u, domain d d.id = u.cityid , u.registeryear = (select max(u2.registeryear) users u2 u2.cityid = u.cityid);

casting - implementing a custom cast for two types in c# -

this question has answer here: c# adding implict conversions existing types 2 answers i have 2 custom classes want implement casts between each other. have dlls of 2 projects , not code. can use extension methods implement cast or need else? i don't think there way it. anyway, need code cast? when implement operators or casts custom types code may become harder understand. suggest create separate utility convert types more obvious sees code first time.

google app engine - Python not interpreting changed files, using obsolete .pyc -

using google app engine develop in python yesterday stopped running current version of script. instead of executing recent version seems run pre-compiled .pyc if .py source changed. error messages quotes correct line current source. except if position of line changed, quotes line in place error occurred previously. deleting .pyc files causes them recreated current version. deleting .pycs poor workaround now. how can root cause of problem? did check system clock? believe python determine whether use .pyc or .py based on timestamps. if system clock got pushed back, see .pyc files newer until system clock caught last time built.

ruby - Using Watir to check for bad links -

i have unordered list of links save off side, , want click each link , make sure goes real page , doesnt 404, 500, etc. the issue not know how it. there object can inspect give me http status code or anything? mylinks = browser.ul(:id, 'my_ul_id').links mylinks.each |link| link.click # need check 200 status or here! how? browser.back end my answer similar idea tin man's. require 'net/http' require 'uri' mylinks = browser.ul(:id, 'my_ul_id').links mylinks.each |link| u = uri.parse link.href status_code = net::http.start(u.host,u.port){|http| http.head(u.request_uri).code } # testing rspec status_code.should == '200' end if use test::unit testing framework, can test following, think assert_equal '200',status_code another sample (including chuck van der linden's idea): check status code , log out urls if status not good. require 'net/http' require 'uri' mylinks = b...

Detecting FR/FF button event in MPMoviePlayerController UI? -

basically long pressing of fr(fast rewind)/ff(fast forward) causes directional scrubbing. ipod, youtube app detects short tapping of these buttons , uses navigating previous/next tracks. how can archive feature? possible? or should go view-hierarchy hack? i have solved view hierarchy hack. not recommended , should avoided as possible. note here further reference. mark there no accessible way currently . hack applied specific version (4.3) of ios sdk. iterate view hierarchy of -[mpmovieplayercontroller view] . find subclass of uibutton . , add target-action handler of them. (you can check subclass of mptransportbutton ) in handler, can filter tags. navigation buttons tagged. each tag means 1 = play/pause, 2 = previous, 4 = next button. take care hack. not guaranteed work or pass on appstore. if have experience of rejection method, please comment me. it'll appreciated.

unix - Simulate key presses in C -

for example, want run: ssh root@127.0.0.1 -p 2222 in c (via system ) command. right after run that, asks input: root@127.0.0.1's password: then i'm expected type in password. how can in c code? please code on how simulate key presses? or there better way this? there beautiful command expect this common used tool. if need ssh, you'd better @ other posts generating key

How to write regex to match only one digit at end of pattern? -

my field supposed in format of a111-1a1, regex allows last number more 1 digit (eg. a111-1a1212341). how fix this? below regex using. var validchar = /^[a-z](([0-9]{3})+\-)[0-9][a-z][0-9]+$/; remove + @ end of pattern. allows more 1 numeric @ end. var validchar = /^a-z[0-9][a-z][0-9]$/; however, pattern otherwise doesn't right want. exact pattern using?

iphone - UIImageView doesn't animate -

i have following code inside app, doesn't animate uiimageview, can tell me why? uitableviewcell* cell = [selectedtable cellforrowatindexpath:selectedpath]; nsarray* myimagearray = [nsarray arraywithobjects: [uiimage imagenamed:[[nsbundle mainbundle] pathforresource:@"boxbeingchecked117x11" oftype:@"png"]], [uiimage imagenamed:[[nsbundle mainbundle] pathforresource:@"boxbeingchecked217x11" oftype:@"png"]], [uiimage imagenamed:[[nsbundle mainbundle] pathforresource:@"boxbeingchecked317x11" oftype:@"png"]], [uiimage imagenamed:[[nsbundle mainbundle] pathforresource:@"boxbeingchecked417x11" oftype:@"png"]], [uiimage imagenamed:[[nsbundle mainbundle] pathforresource:@"boxbeingchecked517x11" oftype:@"png"]], ...

html - Is there any way to read a text file in javascript beside using ActiveX? -

given files (html file, text files, etc) on web, there way read text file , print them in textarea beside using activex? i've tried this, didn't reach goal: function getselecteditem(){ var client = new xmlhttprequest(); if(document.codeform.droplist.value == "foo") client.open('get', 'foo.txt'); else if(document.codeform.droplist.value == "bar") client.open('get', 'bar.txt'); client.onreadystatechange = function() { //this displays message in file alert(client.responsetext); //but doesn't. displays "undefined" // document.codeform.source.value = client.reponsetext; } client.send(); } since display alert message file context, believe there way this. (actually contents of files seem come "client.reponsetext", it's data type domstring, not string.) any advice appreciated. thanks. use jquery. http://api.jquery.com/jquery.get/ ...

c# - create a custom membership and profile provider in asp.net -

i have custom database schema want use custom membership provider. can give step step procedure because when tried create class library project , extended customprovider there no membershipprovider , sqlmembershipprovider , activedirectorymembershipprovider , references attached. please me guys it. the custom membership provider creation explained in video chris pels. hope helps.

interface - Android -- Visible and Invisible Tabs: Button Handling -

i trying create application login screen appears , has effects among various other tabs. i have tabbed implementation working fine: can hide tabs , view layouts of other tabs -- however, cannot make them reappear. program runs fine when not attempt button handling, whenever start listener, force-close. attached problem code: can't find i'm getting force close from, know in button listener area. essentially, want tabs appear if user's name , password correct. what seeing 1 of 4 tabs. specifically, looking @ login screen tab. code: public class loginactivity extends activity { tabhost tabhost = (tabhost) findviewbyid(android.r.id.tabhost); public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.login); final button btn = (button) findviewbyid(r.id.login_button); btn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { edit...

c - system function flaws -

we using c in linux. there possibility system() function can behave in unexpected manner, when handle signals? we found sometimes, system() function blocks execution or throws sigsegv . e.g: system ( "/bin/mv b" ); are there known flaws in using system() explain this? the system() function supposed well. behaviour pretty reliable long invoked correctly. has 2 modes of operation: check whether there command interpreter available - when argument null pointer. run command given, waiting command complete before returning. so, system() statement blocks until shell runs command completes. on unix-like systems, command invoked effectively: "sh", "-c", "...argument system...", null this means string passed interpreted shell. how long takes depends on command executed. can consider using shell notations run command in background if need to: system("( /bin/mv b & )"); there few circumstances syste...

java - Prevent users from login to same system using different browsers (IE and FF) -

we have web application users can login. now want same user should not able login using different browsers. basically user using 2 different browsers (ie , ff) can log in same account @ same time. when hit login button, possible invalidate other logins account. what best possible approach this? ps: using struts, spring , hibernate in our web application. thanks ! doing on server-side best bet. can keep tract of logged-in users in application context. well, little hint. make use of servlet filter, authfilter , , make validation, may isalreadyloggedin() , on there beside other validations username/password etc.. after having check in place, either -- depends want user trying log in, show message "user logged-in", or can let user log-in , invalidate previous session. discussed here .

c# - How can I prevent my System.Timers.Timer from raising the Elapsed event after it got stopped? -

i have followig code: using (filestream sourcestream = sourcefile.open()) { using (filestream targetstream = file.create(targetfilepath)) { using (timer timer = new timer(250)) { timer.elapsed += (sender, e) => { if (this.filecopyprogresschanged != null) { //here objectdisposedexception appears this.filecopyprogresschanged(this, new copyprogresseventargs( sourcestream.length, targetstream.length)); } }; timer.start(); sourcestream.copyto(targetstream); timer.stop(); } } } my timer elapses every 250 milliseconds , raises event information stream copy progress. problem is, in timer event, objectdisposedexception gets thrown, because streams not opened anymore. how can prevent timer raising elapsed eve...

How Recursion works in C -

i new c , i'm reading recursion, totally confused. the main part i'm getting confused how things unwind when exit condition reached. know how during recursion values got pushed , popped stack. also can please give me diagramatic view of recursion? thanks... lets assume function: int myfunc(int counter) { // check functions counter value stack (most recent push) // if counter 0, we've reached terminating condition, return if(counter == 0) { return counter; } else { // terminating condition not reached, push (counter-1) onto stack , recurse int valuetoprint = myfunc(counter - 1); // print out value returned recursive call printf("%d", valuetoprint); // return value supplied use // (usually done via register think) return counter; } } int main() { // push 9 onto stack, don't care return value... myfunc(9); } the output is: 0123456789 the...

how can display image from this query in php throw json -

"newsml": [ { "identification": {"newsidentifier": { "providerid": "timesofindia.com", "newsitemid": "7954765" }}, "newslines": { "headline": "i want kkr win ganguly: shah rukh", "dateline": "ians, apr 12, 2011, 04.41am ist" }, "newscomponent": [ { "role": {"@formalname": "weburl"}, "contentitem": { "mediatype": {"@formalname": "link"}, "datacontent": {"media-caption": "http://timesofindia.indiatimes.com/sports/cricket/ipl-2011/news/i-want-kkr-to-win-for-ganguly-shah-rukh/articleshow/7954765.cms"} } }, { "role": {"@formalname": "capt...

objective c - How to find the car speed on iPhone? -

i want find car speed on iphone when driving should use , how? core motion or core location? there documentation or sample code? hey - you'll want core location this. there tutorial here - http://www.vellios.com/2010/08/16/core-location-gps-tutorial/ followed once. there whole series 1 shows how calculate position , speed of device. there sample project download too. hope helps!

javascript - stop automatical convert to htmlentities? -

i have div id="ultimativegodemperorofalldivs" contains text "such cool & sexy div" when extract innerhtml js converts & &amp; don't want this. don't need url's should simple & . how archive this? thx in advance, iceteea like name says, innerhtml retrieves element’s inner html. without html entities, wouldn’t valid html. if want retrieve element’s text content, you’ll have use element’s textcontent or innertext properties. ( innertext supported in ie; textcontent not supported older versions of ie).

Java Hashtable .containsKey(String key) is returning true even when the strings and hashcodes are different... How? -

i'm having issues hashtable in java, feightpuzzle class i've created. inside class have string storing key each instance. during program when check inside hashtable duplicate instances "find" when found ones different. take example when call bol.containskey(current.key) bol ht , current feightpuzzle. when true check values of keys , are current.key = "8 14 11 0 6 12 13 1 10 4 5 9 15 2 3 7" bol.get(current.key).key = "12 8 4 0 13 9 5 1 14 10 6 2 15 11 7 3" with values current.key.hashcode() = -950607924 bol.get(current.key).key.hashcode() = -1856769042 i'm sorry bother problem getting me, , last thing expected tonight honest (don't love that)... hints or answers appreciated! i've reread question, , understand have following problem: you bol.containskey(current.key) to check if current in bol . when returns true, expect value mapped current.key should indeed current , hash-codes indicate, it's no...

Saving timestamp in mysql table using php -

i have field in mysql table has timestamp data type. saving data table. when pass timestamp ( 1299762201428 ) record, automatically saves value 0000-00-00 00:00:00 table. how can store timestamp in mysql table? here insert statement: insert table_name (id,d_id,l_id,connection,s_time,upload_items_count,download_items_count,t_time,status) values (1,5,9,'2',1299762201428,5,10,20,'1'), (2,5,9,'2',1299762201428,5,10,20,'1') pass this date('y-m-d h:i:s','1299762201428')

How to set a background for whole application in Android? -

in application have lot of layers , instead of setting background image each of them, want set background once , all. how can that? take @ apply theme activity or application apply background image across whole application.

java - how to create class that adds, deletes and find words in a dictionary? -

this have , i'm new java: import java.util.*; public class wordpairs { // arraylist<string> names = new arraylist<string>(); // arraylist<string> meanings = new arraylist<string>(); //names.add("empty"); //meanings.add("empty"); string searchname; string searchmeaning; string names[] = new string[25]; string meanings[] = new string[25]; int q = 1; public void setwordadd(string name,string meaning) { names[q] = name; meanings[q] = meaning; q = q++; } public void setworddelete(string name) { for(int i=0;i<names.length;i++) { string check = names[i]; if(check == name) { string meanings = meanings.remove(i); } } } public void setwordsearch(string name) { int = 1; for(i=0;i<names.size();i++) { string check = names.get(i); if(check == name) ...

wpf - How to get rid of display corruption during horizontal scroll in WPF4 DataGrid with grouping? -

Image
i'm trying create datagrid grouping , i'm getting display corruption (blank areas) during horizontal scrolling. issue appears only when there groupstyle.containerstyle defined. datagrid should contain 200 rows or more reproduce problem. update2: related microsoft connect feedback . update: microsoft guy @ social.msdn.com pointed out adding grouping turns off datagrid virtualization. possibly that's root of problem. removed grouping sample , set virtualizingstackpanel.isvirtualizing false , got same kind of corruption. code reproduce problem: <datagrid itemssource="{binding source={staticresource resourcekey=cvsgoods}}" canuseraddrows="false" canuserreordercolumns="false" canuserdeleterows="false" canuserresizerows="false" canusersortcolumns="false" autogeneratecolumns="true"> <datagrid.groupstyle> <groupstyle> <gr...

java - required country combobox -

in project hava 1 field country name.till inserting country name on textfield. want combobox contain country name. there combobox in java? if using swing have jcombobox . or in webproject in html have select tag.

barcode - How to read Bar Coded Boarding Pass -

i have project in mind, , requires read barcode on boarding pass, , figure out passenger heading. (destination) is such thing possible? there library (c++, java, language doesn't matter @ all) or maybe webservices can use read bar code? from know, can following information barcoded boarding pass: name, booking ref., flying , to, flight #, date, etc. so, figure out passenger heading. about library perhaps take link , multi-format 1d/2d barcode image processing library clients android, java. if want decode barcode online, perhaps following links help: 1. http://zxing.org/w/decode.jspx 2. search datasymbol , barcode recognition sdk, there should online barcode decoder. sorry, system prevented me posting link.

mongoDB: unique index on a repeated value -

so i'm pretty new mongodb figure misunderstanding on general usage. bear me. have document schema i'm working such { name: "bob", email: "bob@gmail.com", logins: [ { u: 'a', p: 'b', public_id: '123' }, { u: 'x', p: 'y', public_id: 'abc' } ] } my problem need ensure public ids unique within document , collection, furthermore there existing records being migrated mysql db dont have records, , therefore replaced null values in mongo. i figure either index db.users.ensureindex({logins.public_id: 1}, {unique: true}); which isn't working because of missing keys , throwing e11000 duplicate key error index: or more fundamental schema problem in shouldn't nesting objects in array structure that. in case, what? seperate collection user_logins??? seems go against idea of embedded document. if expect u , p have same values on each insert (as in exa...

whitespace - Lua and the white spaces in an OS -

after reading post , used [[ ]] put commands system. problem following: same structure: local program = [["c:\archivos de programa\automated qa\testcomplete 8\bin\testcomplete.exe" ]]; local testcase = [["c:\svn_test\trunk\automation\xmm\xmm.pjs" ]]; local options = [[/r /exit /p:xmmgeneraltest /t:"script|main|main" ]]; local cmd = program..testcase..options; print(cmd); os.execute(cmd); local tclog = [[ c:\svn_test\trunk\automation\xtyle\xtylegeneraltest\log\11_04_2011_12_40_06_264\*]]; local zippedfile = "11_04_2011_12_40_06_264.7z "; local sevenzip = [["c:\archivos de programa\7-zip\7z.exe" -t7z ]]; local cmd = sevenzip..zippedfile..tclog; print(cmd); os.execute(cmd); the same code produce different results. first 1 doesn't run: "c:\archivos" not recognized internal command or external, program... the second 1 runs perfectly. how can resolve this? i don't have windows system test with, gue...

Regarding to save previous record in asp.net -

hi have 1 label question, radiobuttonlist answers, next button move next question & previous button. displaying 1 question per page after clicking next button next question appears, when click previous button previous question appears. want previous question earlier selected answer when click previous button. asp.net c# thank you. either store , load question , answer values in session. or have 1 page multiview , swich views when navigating between 'pages' way viewstate information preserved.

c++ - Compiler Warning C4251: Problem exporting a class in a *.dll -

edit: forgive noobish-ness, haven't ever implemented wrapper .dll before! :s i've been tinkering bit of released kinect sensor hacks (namely openkinect , openni ) , i'm trying wrap functionality in *.dll use in various "test" programs hope write. so far i've set *.dll project , have got lot of library functionality in, i'm getting c4251 compiler warnings on place. in project settings i've got openni.lib file statically linked, far library header looks this: #ifdef libkinect_exports #define libkinect_api __declspec(dllexport) #else #define libkinect_api __declspec(dllimport) #endif // class exported libkinect.dll class libkinect_api clibkinect { public: clibkinect(void); ~clibkinect(void); bool init(void); protected: private: xn::context m_xcontext; xn::depthgenerator m_xdepthgen; }; and stdafx.h file contains: #pragma once #define win32_lean_and_mean // exclude r...

Best way to design soundex based search -

i have table of forum posts, , want improve basic search functionality lot of users on world not native english speakers , have trouble finding results when spell incorrectly. current forum search exact. which of these designs perform best? assume database has 500,000 records , search used frequently. ideally search every record. design one along side each forum post, store soundex_post, contains soundex data. when search run, soundexes search terms, , operation on soundex fields. design two i normalise it. every soundex code stored in new table, tblsoundexcodes. there table tblforumpostsoundexcodes: id | post_id | soundexcode_id | count then when soundex searched for, pull out post_ids soundexcode_id = n am correct method 2 considerably faster, lot harder maintain (ie, when people edit posts). design 2 better. design 2 won't faster. data storage more compact, , have update or insert row tblforumpostsoundexcodes, insert row tblsoundexcodes, whe...

VB.NET 2005, Serial port, dispose problem, Windows CE -

i write program windows ce should work serial ports. use object system.io.ports.serialport . works when close program , open again, receive error: port in use! @ end write: port.close() port.dispose() and if add this: system.gc.collect() .. begins work but problem computer gets stuck when garbage collector called each port. if tried use collector somewhere else, doesnt "collect" ports , used if program starts again. can please? it object owns port object not disposed or still maintains reference. explain why after system.gc.collect() works.

bitmap - Bit alignment, 8-bools-in-1 -

i'm trying compile following code: union bool { bool b[8] : 8; // (1) bool b0,b1,b2,b3,b4,b5,b6,b7 : 1; }; however line (1) doesn't compile, whats syntax bit aligning array? you can't declare array of bits in c. the concept of array based on pointer, , can have pointers bytes, not individual bits within byte. c bit fields allow pack integer components less memory compiler default. array isn't integer, can't pack array bit field. if want read on standard, can find @ iso/iec 9899 - programming languages - c (look §6.7.2.1). if need speed, use union of array of bools, , if need compact memory footprint, define macros provide more convenient access bit fields.

scope - extern declaration and definition in C -

a global variable may 1 2 different storage classes in c, best knowledge, , declaration may given 2 different keywords, correspodingly extern int foo; //default static int bar; static variables visible within module of declaration, , cannot exported. in case of extern declaration, variable in common namespace of modules linked, unless shadowed static variable. whereas static variables have defined in module, extern variable may defined somewhere else. has defined if ever used. my compiler (gcc) accepts static int bar = 5; but casts complain at extern int foo = 4; it seems expected extern variables never defined keyword 'extern'. leads following question : what kind of storage class object 'foo' in example above have in module defined? iirc, extern more of hint compiler not have allocate storage value. linker expected find value in compilation unit. extern used in header files indicate has defined storage associated name. definition of...

multithreading - c# Thread in 100% CPU -

i have complex system several threads. see application in 100% cpu , force restart system. have no idea thread caused , code caused it. need give me state of each thread in system (i.e. in line thread now) can find code causes 100% cpu (in java have thread dump kill -3 gives state of each thread) can please? tess's blog has great debugging tutorials, including: .net hang debugging walkthrough

c++ file descriptor (sockets) isopen()? -

in c++, there way check if file descriptor still open, long after opened? you can use fcntl f_getfl if fd valid or not.

Which version on OpenGL should i study next? And GLSL? -

i learned basics of opengl @ university, tried develop simple car racing game using opengl 1.x. i'm getting quite confused on next steps should be. should study next? thought opengl 2.0 because of opengl es 2.x, outdated? and syntax of glsl should work on? arb or opengl 2.0? which books/articles/tutorials should read? i study current version of opengl. if study else, you'll learning things or deprecated. opengl 3.0 start of lot of these deprecations. (note of deprecated functionality still available through extensions.) it's worth being familiar of older versions of opengl understand older programs might come across. however, imagine deprecations removed newer versions of opengl. shader language syntax should learn, stick syntax that's compatible chosen version of opengl. if you're looking step mobile world, opengl es want at. that's still relatively new , there major differences between es 1.x , 2.x. it's different world in way ...

A help in concept and a database query question (Django/Python) -

i trying build kind of news website learning purposes. class newscategory(models.model): category = models.charfield(max_length=50) note: category can soccer, tennis, business ... user can register different news category. choice saved in preferences. class profile(models.model): user = models.foreignkey(user, unique=true) gender = models.charfield(max_length=1,blank=true) preference = models.manytomanyfield(newscategory) i stuck on how update preference list of each user (the list specifies in categories interested in.) view: category = [(item.category) item in newscategory.objects.all()] and sending category template below template: <div id="c_b"> {% c in category %} <input type="checkbox" name="category[]" value="{{c}}"> <label for="{{c}}">{{c}}</label> {% endfor %} </div> questions: what best way add checked tag next checkboxes saved in...