Posts

Showing posts from April, 2013

What encoding is this, and better yet, how do i decode it in ruby -

@string = "\x16\x03\x01\x00\x91\x01\x00\x00\x8d\x03\x01li.\e\x8f|\x06\f\xa2tu\xc8ww\xcf\x87g2o,98\xec\xadmm h\xb4\x0e-g\x00\x00h\xc0\n\xc0\x14\x00\x88\x00\x87\x009\x008\xc0\x0f\xc0\x05\x00\x84\x005\xc0\a\xc0\t\xc0\x11\xc0\x13\x00e\x00d\x00f\x003\x002\xc0\f\xc0\x0e\xc0\x02\xc0\x04\x00\x96\x00a\x00\x04\x00\x05\x00/\xc0\b\xc0\x12\x00\x16\x00\x13\xc0\r\xc0\x03\xfe\xff\x00\n\x02\x01\x00\x00\e\xff\x01\x00\x01\x00\x00\n\x00\b\x00\x06\x00\x17\x00\x18\x00\x19\x00\v\x00\x02\x01\x00\x00#\x00\x00" it turned out attempting connect server wss:// instead of ws:// trying read encrypted packet. packet in whatever format secure web sockets in. thanks every one.

OOP class design, Is this design inherently 'anti' OOP? -

i remember when ms released forum sample application, design of application this: /classes/user.cs /classes/post.cs ... /users.cs /posts.cs so classes folder had class i.e. properties , getters/setters. users.cs, post.cs, etc. have actual methods access data access layer, posts.cs might like: public class posts { public static post getpostbyid(int postid) { sqldataprovider dp = new sqldataprovider(); return dp.getpostbyid(postid); } } another more traditional route put of methods in posts.cs class definition (post.cs). splitting things 2 files makes more procedural doesn't it? isn't breaking oop rules since taking behavior out of class , putting class definition? if every method static call straight data source, "posts" class factory. put static methods in "posts" "post" class (this how csla works), still factory methods. i more modern , accurate name "posts" class "postfactor...

postgresql - Getting "Access is denied" error when executing pg_dump on Windows -

i'm trying execute pg_dump 1 of postgresql databases, having permission problems. c:\windows\system32>pg_dump -u postgres -p 1863 -o social_sense > c:\\program files\\postgresql\\8.4\\data\\social_sense.sql getting following error: access denied can enlighten? i apologise taking time. due there no write permission directory writing to.

java - How to force use of specific XML parser -

i have xerces , oracle xml parsers both in application's classpath (don't ask why). when create new javax.xml.parsers.documentbuilderfactory , classloader automatically picks oracle xml parser. however, it's not full/proper implementation, it's giving me headaches. is there way can force/tell classloader use xerces parces when constructing document builder factory? documentbuilderfactory has newinstance() method can specify class name of implementation want use.

gis - How to calculate coordinates of center of image from an aerial camera whose FOV, attitude and position are given -

i have problem involves uav flying camera mounted below it. following information provided: gps location of uav in lat/long gps height of uav in meters attitude of uav i.e. roll, pitch, , yaw in degrees field of view (fov) of camera in degrees elevation of camera w.r.t uav in degrees azimuth of camera w.r.t uav in degrees i have some images taken camera during flight , task compute locations (in lat/long) of 4 corners points , center points of image image can placed on map @ proper location. i found document while searching internet can downloaded @ following link: http://www.siaa.asn.au/get/2411853249.pdf my maths background weak not able translate document working solution. can provide me solution problem in form of simple algorithm or preferable in form of code of programming language? thanks. as see, not related image-processing, because need determine coordinates of center of image (you not need fov). have find intersection of camera principa...

Javascript: How to have value in string represented by %s and then replaced with a value -

i know stupid question. i've had few years experience javascript 1 thing seems have skipped mind, head has gone blank , can't remember it's called , how go doing it. basically i'm looking when have string variable such as: var error_message = "an account exists email: %s" and pass string somehow , replaces %s. i sound idiotic, i'd appreciate / reminding! thanks guys. you use replace method: error_message = error_message.replace('%s', email); this replace first occurance, if want replace multiple occurances, use regular expression can specify global (g) flag: error_message = error_message.replace(/%s/g, email);

hashtable - Efficient bidirectional hash table in Python? -

python dict useful datastructure: d = {'a': 1, 'b': 2} d['a'] # 1 sometimes you'd index values. d[1] # 'a' which efficient way implement datastructure? official recommend way it? thanks! here class bidirectional dict , inspired finding key value in python dictionary , modified allow following 2) , 3). note : 1) inverse directory bd.inverse auto-updates when standard dict bd modified 2) inverse directory bd.inverse[value] list of key such bd[key] == value 3) unlike bidict module https://pypi.python.org/pypi/bidict , here can have 2 keys having same value, very important . code: class bidict(dict): def __init__(self, *args, **kwargs): super(bidict, self).__init__(*args, **kwargs) self.inverse = {} key, value in self.iteritems(): self.inverse.setdefault(value,[]).append(key) def __setitem__(self, key, value): if key in self: self.inverse[self[k...

security - Hide/encrypt password in bash file to stop accidentally seeing it -

sorry if has been asked before, did check couldn't find anything... is there function in unix encrypt and decrypt password in batch file can pipe other commands in bash file? i realise doing provides no real security, more stop accidentally seeing password if looking @ script on shoulder :) i'm running on red hat 5.3. i have script similar this: servercontrol.sh -u admin -p mypassword -c shutdown and this: password = decrypt("fgsfkageaivgea", "adecryptionkey") servercontrol.sh -u admin -p $password -c shutdown this doesn't protect password in way, stop accidentally seeing on shoulder. openssl provides passwd command can encrypt doesn't decrypt hashes. download aesutil can use capable , well-known symmetric encryption routine. for example: #!/bin/sh # using aesutil salt=$(mkrand 15) # mkrand generates 15-character random passwd myencpass="i/b9pkcpqapy7bzh2jlqhvojc2mntbm=" # echo "passwd" | a...

How can you find and replace text in a file using the Windows command-line environment? -

i writing batch file script using windows command-line environment , want change each occurrence of text in file (ex. "foo") (ex. "bar"). simplest way that? built in functions? if on windows version supports .net 2.0, replace shell. powershell gives full power of .net command line. there many commandlets built in well. example below solve question. i'm using full names of commands, there shorter aliases, gives google for. (get-content test.txt) | foreach-object { $_ -replace "foo", "bar" } | set-content test2.txt

python - re.sub issue when using group with \number -

i'm trying use regexp arrange text, re.sub . let's it's csv file have clean make totally csv. i replaced \t \n doing : t = t.replace("\n", "\t") ... , works fine. after that, need \t \n, each of csv lines. use expression : t = re.sub("\t(\d*?);", "\n\1;", t, re.u) the problem works... partially. \n added properly, instead of being followed matching group, followed ^a (according vim) i tried regexp using re.findall , works juste fine... wrong according ? my csv lines supposed : number;text;text;...;...;\n thanks ! your \1 interpreted ascii character 1. try using \\1 or r"\n\1;" .

Windows Mobile development in Python -

what best way start developing windows mobile professional applications in python? there reasonable sdk including emulator? possible without doing excessive amount of underlaying windows api calls ui instance? if ironpython , .net compact framework teams work together, visual studio may 1 day support python windows mobile development out-of-the-box. unfortunately, this feature request has been sitting on issue tracker ages ...

Terminal emulation in Flex -

i need emulation of old dos or mainframe terminals in flex. image below example. alt text http://i36.tinypic.com/2encfes.png the different coloured text easy enough, ability different background colours, such yellow background beyond capabilities of standard flash text. i may need able enter text @ places , scroll text "terminal". idea how i'd attack this? or better still, existing code/components sort of thing? use textfield.getcharboundaries rectangle of first , last characters in areas want background. these rectangles can construct rectangle spans whole area. use draw background in shape placed behind text field, or in parent of text field. update asked example, here how rectangle range of characters: var firstcharbounds : rectangle = textfield.getcharboundaries(firstcharindex); var lastcharbounds : rectangle = textfield.getcharboundaries(lastcharindex); var rangebounds : rectangle = new rectangle(); rangebounds.topleft = firstcharbounds.t...

c++ - Why should the "PIMPL" idiom be used? -

this question has answer here: is pimpl idiom used in practice? 11 answers backgrounder: the pimpl idiom (pointer implementation) technique implementation hiding in public class wraps structure or class cannot seen outside library public class part of. this hides internal implementation details , data user of library. when implementing idiom why place public methods on pimpl class , not public class since public classes method implementations compiled library , user has header file? to illustrate, code puts purr() implementation on impl class , wraps well. why not implement purr directly on public class? // header file: class cat { private: class catimpl; // not defined here catimpl *cat_; // handle public: cat(); // constructor ~cat(); // destructor // other operations... p...

windows - Web based service for Using Remote Computers -

are there free web based service manage/use remote computers? i use logmein free. solves purpose. wondering other free services available. heard copilot great not free! i can't talk highly enough crossloop (www.crossloop.com). it's free, protected aes-128 encryption , uses vnc desktop viewer mechanism. ideally, i'd see rdp mechanism, being able puppy , running clients in 5 minutes worth price (free!). if open account them (again free) complete audit trail of sessions - great billing purposes. works on 12 digit random code (which presented in 3 sets of 4 numbers) valid 2 minutes. client has permit access control pc - justs works straight out of box. , did mention it's free?

html - Find / Replace a link in all pages of a site -

looking ideas / recommendations on finding , replacing link in pages of site, , using dreamweaver (ick) not option. site consist of 100s of static pages. in unix, vim has option that. vim -c "argdo %s/http:\\site.com\/pagea/http:\\site2.com\/pageb/ge | update" *.html

c# - VS 2005 Toolbox kind of control .NET -

i'm looking control visual studio "toolbox" menu uses. can docked , can retract (pin). would know can find control or com use this? i recommend dockpanel suite weifen luo.

bash - How do I use a pipe in the exec parameter for a find command? -

i'm trying construct find command process bunch of files in directory using 2 different executables. unfortunately, -exec on find doesn't allow use pipe or \| because shell interprets character first. here i'm trying (which doesn't work because pipe ends find command): find /path/to/jpgs -type f -exec jhead -v {} | grep 123 \; -print try this find /path/to/jpgs -type f -exec sh -c 'jhead -v {} | grep 123' \; -print alternatively try embed exec statement inside sh script , do: find -exec some_script {} \;

windows - How can I find the current DNS server? -

i'm using delphi , need current windows dns server ip address can lookup. function should call find it? solution have right ipconfig/all it, horrible. found nice 1 using function getnetworkparams().seems work quite good. can find here: http://www.swissdelphicenter.ch/torry/showcode.php?id=2452

arrays - Trying to convert an int[] into int[,] using C# -

i function convert single dimension array int[480000] 2d array of size int[800,600]. can please me how can done? public static t[,] convert<t>(this t[] source, int rows, int columns) { int = 0; t[,] result = new t[rows, columns]; (int row = 0; row < rows; row++) (int col = 0; col < columns; col++) result[row, col] = source[i++]; return result; }

ide - Any PHP editors supporting 5.3 syntax? -

i'm using namespaces in project , eclipse pdt, ide of choice, recognizes them syntax errors. not renders convenient error checking unusable, ruins eclipse's php explorer. 5.3 features coming pdt 2.0 scheduled release in december. there alternatives present moment? i'm looking 5.3 syntax highlighting , error checking @ least. some threads have been addressed various php ide developers regarding status of 5.3 syntax support: phpeclipse : http://www.phpeclipse.net/ticket/636 or google aptana : http://forums.aptana.com/viewtopic.php?t=6538 or google pdt : http://bugs.eclipse.org/bugs/show_bug.cgi?id=234938 or google textmate : http://www.nabble.com/php-namespace-support-td19784898.html (namespace support) or google

c++ - Remote installing of windows service -

i need remotely install windows service on number of computers, use createservice() , other service functions winapi. know admin password , user name machines need access to. in order gain access remote machine impersonate calling process of logonuser this: //all variables initialized correctly int status = 0; status = logonuser(lpwusername, lpwdomain, lpwpassword, logon32_logon_new_credentials, logon32_provider_default, &htoken); if (status == 0) { //here comes error } status = impersonateloggedonuser(htoken); if (status == 0) { //once again error } //ok, impersonated, service work there so, gain access machine in domain, of computers out of domain. on machines out of domain code doesn't work. there way access service manager on machine out of domain? ...

Zend Framework : Get bootstrap resource from anywhere in application -

i wonder how bootstrap resource anywhere in application. eg. zend_validate, zend_auth_adapter etc? $bootstrap = zend_controller_front::getinstance()->getparam('bootstrap'); $resource = $bootstrap->getresource('whatever')

.net - WCF Datacontract free serialization (3.5 SP1) -

has got work? documentation non existent on how enable feature , missing attribute exceptions despite having 3.5 sp1 project. i found doesn't work internal/private types, making type public worked fine. means no anonymous types either :( using reflector found method classdatacontract.isnonattributedtypevalidforserialization(type) seems make decision. it's last line seems killer, type must visible, no internal/private types allowed :( internal static bool isnonattributedtypevalidforserialization(type type) { if (type.isarray) { return false; } if (type.isenum) { return false; } if (type.isgenericparameter) { return false; } if (globals.typeofixmlserializable.isassignablefrom(type)) { return false; } if (type.ispointer) { return false; } if (type.isdefined(globals.typeofcollectiondatacontractattribute, false)) { return false; } foreach (typ...

.net - What is "Client-only Framework subset" in Visual Studio 2008? -

what "client-only framework subset" in visual studio 2008 do? you mean client profile ? the .net framework client profile setup contains assemblies , files in .net framework typically used client application scenarios. example: includes windows forms, wpf, , wcf. not include asp.net , libraries , components used server scenarios. expect setup package 26mb in size, , can downloaded , installed quicker full .net framework setup package.

vb.net - Getting a list of indexes from a text search in vb2005 -

i running index search on string in rich textbox, have list of keywords need different color in textbox. how run search on string in vb2005 , list of indexes text matched search? here simple solution. note find word "our" in "four". if not desirable can write eliminate overlapping matches. private sub page_load(byval sender object, byval e system.eventargs) handles me.load dim searchtext string = "one 2 3 four" dim keywords string() = {"one", "four", "our"} dim wordmatches new generic.list(of wordmatch) each keyword string in keywords dim int32 = 0 while <> -1 = searchtext.indexof(keyword, i, system.stringcomparison.ordinalignorecase) if <> -1 dim mymatch new wordmatch mymatch.charindex = mymatch.word = keyword wordmatches.add(mymatch) += keyword.length ...

jquery - How do i call javascript function from php function? -

what equivalent of scriptmanager.registerstartupscript() of asp.net in php? want call javascript function php function i.e after event fired (may adding record database) want call javascript function. event fired using ajax of jquery. thanks in advance :) if event fired using jquery, can use success parameter of ajax options specify function call. for example: var options = { url: 'urlforajaxcall.php', success: function(){ //call function here }, error: function() { alert('failure'); }}; $.ajax(options);

c++ - Linked-lists versus array in performance when dealing with sequentially accessed objects? -

i designing game in maximum of approximately 10,000 objects used per level. each frame of objects accessed in sequential order @ least once, twice or more. right using arrays curious if linked-lists better suited handle such task. i've never used linked-lists seems applicable time use them, , since project i'm working on learning-one as else, try new approach handling objects in game. linked lists seem way save space , speed game up, due inexperience curious if there noticeable performance lost switching linked-lists. (normally motto try , see, in case requires fair amount of work go implementing linked lists on arrays, , i've spent lot of time on designing how levels , objects work already, i'm bit sick of @ moment.) unless very frequently inserting , removing elements in middle of sequence, array outperform linked list (though, there a handful of scenarios in linked lists useful ). with linked list, lose benefits of prefetching @ cpu level, since...

How do I create a sql dependency on a table in sql server 2000 and asp.net 2.0? -

i need create sql dependenc y on table in sql server 2000 in asp.net 2.0 pages. what required actions , best way? thanks.. microsoft has great tutorial on this explains need enable using aspnet_regsql.exe utility or sqlcachedependencyadmin class

c++ - Exception within function returning value for constructor -

let's have class acts "smart pointer" , releases kind of system resource when destroyed. class resource{ protected: resourcehandle h; public: resource(resourcehandle handle) :h(handle){ } ~resource(){ if (h) releaseresourcehandle(h);//external function, os } }; and have function returns value used initialization of "resource": resourcehandle allocatehandle(); now, if in code: resource resource(allocatehandle()); and allocatehandle() throws exception , happen? crash occur during construction of resource() or before construction? common sense tells me because exception thrown before allocatehandle returns, execution won't enter resource() constructor, i'm not sure it. correct assumption? arguments evaluated before function call -- in case constructor --. therefore, exception thrown before constructor call

http - Is there a way to clear a user's browser of my page, or say not to use cache? -

is there command in classic asp can use tell browser not pull page it's cache, or, not cache, or clear cache of page? you can use html meta tags: <meta http-equiv="pragma" content="no-cache" /> <meta http-equiv="expires" content="fri, 01 jan 1999 1:00:00 gmt" /> <meta http-equiv="last-modified" content="0" /> <meta http-equiv="cache-control" content="no-cache, must-revalidate" /> or can use asp response headers: <% response.cachecontrol = "no-cache" response.addheader "pragma", "no-cache" response.expires = -1 %>

c# - Working with URL query Strings in ASP.NET -

i new working asp.net , want find best way work url query strings. i can current value of url query string using request.querystring["urlkey"] , can modify url code, without doing form get submission? if user landing on page first time, easiest way programmatically create ?urlkey=value through page_load method? or better of doing javascript or building redirect like: string redirect = "www.mysite.com?" + mykey + "=" + myvalue; it sounds want this: string redirect = "www.mysite.com?mykey=" + myvalue.tostring(); response.redirect(redirect);

PHP: Use Pecl/Pear, or build my own systems? -

when building of php apps, lot of functionality coded using pear/pecl modules, however, fact people using may not have access install things, poses puzzler me. should forsake users use pear/pecl functionality, these allow me have system coded quicker if wrote own functionality, eans exclude people using it. it partly depends on how time have, , purpose of project. if you're trying make works, go pear/pecl. if you're trying learn better programmer, , have time, i'd recommend taking effort write own versions. once understand innards of whatever you're trying replace, may want switch pear/pecl version you're not wasting time reimplementing has been implemented... ...but on other hand, preexisting tools don't need, , have overhead doesn't good. why unix command-line tools small , narrow of purpose; nobody needs version of 'ls' can besides 'ls' can do. version of whatever pear library will, virtue of being written you, need d...

TFS Build Server drop location error -

we're using tfs build server ensure files checked in developers going compile working source tree, cuz there's nothing worse broken build! anyway we've having problems drop location build server wants use, keep getting error: tfs209011: not create drop location \build-server\drops\project\buildnumber. no more connections can mades remote computer @ time because there many connections computer can accept since being used in pilot program @ moment have 2 projects using build server. i've checked network share , allowed number of connections 100 don't problem is. only occationally problem raise it's head, quite we'll not have 1 days, , we'll have bunch in row. i can't seem find info on either. i'm pretty tfs - dev not network guy. guess while network share allows 100 connections, possible underlying server running on doesn't have sort of limitation? have checked event logs? this problem seems specific enough enco...

design patterns - What should my Objective-C singleton look like? -

my singleton accessor method variant of: static myclass *ginstance = null; + (myclass *)instance { @synchronized(self) { if (ginstance == null) ginstance = [[self alloc] init]; } return(ginstance); } what doing improve this? another option use +(void)initialize method. documentation: the runtime sends initialize each class in program 1 time before class, or class inherits it, sent first message within program. (thus method may never invoked if class not used.) runtime sends initialize message classes in thread-safe manner. superclasses receive message before subclasses. so akin this: static mysingleton *sharedsingleton; + (void)initialize { static bool initialized = no; if(!initialized) { initialized = yes; sharedsingleton = [[mysingleton alloc] init]; } }

Differences between JDK and Java SDK -

is there substantial difference between 2 terms?. understand jdk stands java development kit subset of sdk (software development kit). specifying java sdk, should mean same jdk. from wikipedia entry : the jdk subset of loosely defined software development kit (sdk) in general sense. in descriptions accompany recent releases java se, ee, , me, sun acknowledge under terminology, jdk forms subset of sdk responsible writing , running of java programs. remainder of sdk composed of software, such application servers, debuggers, , documentation. the "extra software" seems glassfish, mysql, , netbeans. this page gives comparison of various packages can java ee sdk.

Compare SQL Server Reporting Services to Crystal Reports -

which of crystal reports , ssrs (sql server reporting services) better use? on one-hand, crystal reports steaming pile of expensive , overhyped donkey poo, , on other hand ssrs fulfils promises cr marketing makes - , it's free. my contempt cr stems many years of being obliged use horrible thing. there's no point in detailing utter odiousness of cr when can give references clubbing crystal dodo or crystal reports sucks donkey dork (not funny rather more literate , substantiated technical details). free?! yup. don't have buy ms sql server - can install sql express advanced services. available download includes sql server reporting services . while sql express limited in number of concurrent users can support, following observations salient: the licence ssrs obtained part of sql express requires deployed part of sql express. there nothing forbidding connection other data sources or requiring report obtain data sql server. the abovementioned version of ...

html - File input 'accept' attribute - is it useful? -

implementing file upload under html simple, noticed there 'accept' attribute can added <input type="file" ...> tag. is attribute useful way of limiting file uploads images, etc? best way use it? alternatively, there way limit file types, preferably in file dialog, html file input tag? the accept attribute incredibly useful. hint browsers show files allowed current input . while can typically overridden users, helps narrow down results users default, can they're looking without having sift through hundred different file types. usage note: these examples written based on current specification , may not work in (or any) browsers. specification may change in future, break these examples. h1 { font-size: 1em; margin:1em 0; } h1 ~ h1 { border-top: 1px solid #ccc; padding-top: 1em; } <h1>match image files (image/*)</h1> <p><label>image/* <input type="file" accept="image/*"></labe...

itunes - RPC_E_SERVERCALL_RETRYLATER during powershell automation -

i'm using powershell automate itunes find error handling / waiting com objects handling less optimal. example code #cause rpc error $itunes = new-object -comobject itunes.application $librarysource = $itunes.librarysource # "playlist" objects main sections foreach ($plist in $librarysource.playlists) { if($plist.name -eq "library") { $library = $plist } } { write-host -foregroundcolor green "running loop" foreach ($track in $library.tracks) { foreach ($foundtrack in $library.search("$track.name", 5)) { # nothing... don't care... write-host "." -nonewline } } } while(1) #end go itunes , makes pop message - in case go party shuffle , banner "party shuffle automatically blah blah...." "do not display" message. at point if running script repeatedly: + foreach ($foundtrack in $library.search( <<<< "$track.name", 5)) { exception call...

Flex media framework -

does know of media framework flex? i'd able create apps can play not formats flex framework provides support for, other formats (like wav, wma, ogg , other...). edit 13.10.2008.: pointed out me in answers section should perhaps rephrase question, here goes: i'm looking way play various media formats in flex/air app. onekidney posted nice answer ogg/vorbis. know of way play other media formats? never mind portability different platforms now. portability nice, if can't it, can live without :-). answers! you might need make question more specific - like, there way play ogg vorbis in flash? then answer, hell yes! it's right here .

Testing HTML/CSS/Javascript skills when hiring -

when hiring front-end developer, specific skills , practices should test for? metric evaluating skill in html, css , javascript? obviously, table-less semantic html , pure css layout key skills. specific techniques? should he/she able effortlessly mock multi-column layout? css sprites? equal height (or faux) columns? html tag choice matter (ie, relying heavily on <div> )? should able explain (in words) how floats work? and javascript skills? how important framework experience (jquery, prototype, etc). today? obviously, details of position , sites they'll working on best indication of skills needed. i'm wondering specific skills people might consider deal-breakers (or makers) when creating tests candidates. when interview people position of client-side developer try figure out: 1) understanding dom (what that, how related html etc) 2) understanding xml/namespaces 3) understanding javascript (object-oriented? otherwise) 4) knowing approaches componenti...

java - How to avoid HeadlessException in thread? -

i have tried open dialog box in servlet & opens fine. tried achieve same thing in thread's run method. gaved me following error: java.awt.headlessexception @ java.awt.graphicsenvironment.checkheadless(graphicsenvironment.java:159) @ java.awt.window.<init>(window.java:431) @ java.awt.frame.<init>(frame.java:403) below code : jframe frame = new jframe("success message"); frame.setsize(200, 50); frame.add(new jlabel("data uploaded "+inputfile.getfilename())); frame.setvisible(true); frame.setdefaultcloseoperation(jframe.exit_on_close); i tried below code, failed graphicsenvironment ge = graphicsenvironment.getlocalgraphicsenvironment(); system.out.println("headless mode: " + ge.isheadless()); if(!ge.isheadless()){ system.setproperty("java.awt.headless", "true"); } exception described : thrown when code dependent on keyboard, display, or mouse called in environment not support keyboard, display, or ...

Can I use Python as a Bash replacement? -

i textfile manipulation through bunch of badly remembered awk, sed, bash , tiny bit of perl. i've seen mentioned few places python kind of thing, know little , know more. python choice this, , there book or guide learning how use python replace shell scripting, awk, sed , friends? any shell has several sets of features. the essential linux/unix commands. of these available through subprocess library. isn't best first choice doing all external commands. @ shutil commands separate linux commands, implement directly in python scripts. huge batch of linux commands in os library; can these more in python. and -- bonus! -- more quickly. each separate linux command in shell (with few exceptions) forks subprocess. using python shutil , os modules, don't fork subprocess. the shell environment features. includes stuff sets command's environment (current directory , environment variables , what-not). can manage python directly. the shell program...

javascript - How do I set up gzip compression on a web server? -

i have embedded webserver has total of 2 megs of space on it. gzip files clients benefit, save space on server. read can gzip js file , save on server. tested on iis , didn't have luck @ all. need on every step of process make work? this imagine like: gzip foo.js change link in html point foo.js.gz instead of .js add kind of header response? thanks @ all. -frew edit : webserver can't on fly. it's not apache or iis; it's binary on zilog processor. know can compress streams; heard can compress files once , leave them compressed. as others have mentioned mod_deflate you, guess need manually since embedded environment. first of should leave name of file foo.js after gzip it. you should not change in html files. since file still foo.js in response header of (the gzipped) foo.js send header content-encoding: gzip this should trick. client asks foo.js , receives content-encoding: gzip followed gzipped file, automatically ungzips befo...

php - reCAPTCHA not working in IE8 -

recaptcha (zend_service_recaptcha) not working in ie 8 on our site. look @ this web site . know why? working elsewhere including ff,opera, etc. lot! it https page, , images , other items recaptcha delivered via http , blocked.

c++ - "case sequence" in python implemented with dictionaries -

i have implemented function: def postback(i,user,tval): """functie ce posteaza raspunsul bazei de date;stringul din mesaj tb sa fie mai mic de 140 de caractere""" result = { 1:api.postdirectmessage(user,'trebuie sa-mi spui si marca pe care o cauti'), 2:postmarket(user,tval), 3:api.postdirectmessage(user,'imi pare rau, dar nu stiu unde poti gasi aceste tipuri de smantana: %s' % tval)} return result.get(i) but not work case alternative(from c++) executes 3 cases no matter wha try...i'm begginer there might error, please help!p.s. please don't tell me if...else.. alternative cause know can work it executes 3 cases because define result dict way! call 3 functions , assign them keys 1, 2, 3. what should instead this: functions = { 1: lambda: api.postdirectmessage(user,'trebuie sa-mi spui si marca pe care o cauti'), 2: lambda: postmarket(user,tval), 3: lambda: ...

Can you recommend a good MySQL stored procedure debugger? -

can recommend mysql stored procedure debugger? extra points if open source, , works in linux :) it's neither open source ( but freeware ) nor works in linux, toad® mysql should able assist in debugging stored procedures on windows client.

c# - Optimising binary serialization for multi-dimensional generic arrays -

i have class need binary serialize. class contains 1 field below: private t[,] m_data; these multi-dimensional arrays can large (hundreds of thousands of elements) , of primitive type. when tried standard .net serialization on object file written disk large , think .net storing lot of repeated data element types , possibly not efficiently done. i have looked around custom serializers have not seen deal multi-dimensional generic arrays. have experimented built-in .net compression on byte array of memory stream following serializing success, not quick / compressed had hoped. my question is, should try , write custom serializer optimally serialize array appropriate type (this seems little daunting), or should use standard .net serialization , add compression? any advice on best approach appreciated, or links resources showing how tackle serialization of multi-dimensional generic array - mentioned existing examples have found not support such structures. here's ...

java - Can anyone explain thread monitors and wait? -

someone @ work asked reasoning behind having wrap wait inside synchronized. honestly can't see reasoning. understand javadocs say--that thread needs owner of object's monitor, why? problems prevent? (and if it's necessary, why can't wait method monitor itself?) i'm looking in-depth why or maybe reference article. couldn't find 1 in quick google. oh, also, how thread.sleep compare? edit: great set of answers--i wish select more 1 because helped me understand going on. if object not own object monitor when calls object.wait(), not able access object setup notify listener until the monitor released. instead, treated thread attempting access method on synchronized object. or put way, there no difference between: public void dostuffonthisobject() and following method: public void wait() both methods blocked until object monitor released. feature in java prevent state of object being updated more 1 thread. has unintended consequences...

asp.net - How do I make a link in a master page, which includes dynamic information from the current page? -

i have master page, link in top menu. link should contain dynamic bookmark current page, user scrolls page seeing. <a href="help.aspx#[nameofcurentpage]">help</a> how implement this? another thing reference master page through content page itself. to make easier on myself, create publicly accessible method in master page itself: public sub setnavigationpage(byval linkname string) directcast(me.findcontrol(menuname), hyperlink).navigateurl = "help.aspx#" & linkname end sub then in content page, reference master page through following... dim mymaster masterpageclass = directcast(me.master, masterpageclass) mymaster.setnavigationpage("currentpage")

In richfaces form based error message possible? -

i catch-all display of errors or exceptions. instance catch 500 responses ajax requests , display summary in text field. more single message area entire form (w/o specifying separate message tag every input or button). how can implemented using richfaces? i've read documentation located @ richfaces demo site , 500 responses still through. for displaying validation errors in form in single location use <rich:messages/> component instead of <rich:message> shown in: http://livedemo.exadel.com/richfaces-demo/richfaces/messages.jsf

assembly - x86 question about bit comparisons -

im having problem final part of assignment. in stream of bits, etc etc, in stream integer number of 1's in text portion. integer , 24 correct, loop through text data , try count 1's in there. proc returning zero. i able make sure looping , is. the text = hello 16 1's, here proc looping through text count number of ones in it. sub ax,ax sub si,si mov bx,[bp+6] ;get message offset @@mainloop: mov cx,8 mov dh,80h cmp byte ptr [bx + si],0 je @@endchecker @@innerloop: test byte ptr [bx + si],dh jz @@zerofound inc ax @@zerofound: shr bh,1 loop @@innerloop @@continue: inc si jmp @@mainloop the rest of proc push/pops. im wanting use test compare 100000000 byte, if 1 inc ax else shift right mask 1 , loop whole byte, inc next byte , again. 'shr bh,1' should 'shr dh,1', no?

path - How to determine the directory in which a running Haskell script or application lives? -

i have haskell script runs via shebang line making use of runhaskell utility. e.g... #! /usr/bin/env runhaskell module main main = { ... } now, i'd able determine directory in script resides from within script, itself . so, if script lives in /home/me/my-haskell-app/script.hs , should able run anywhere, using relative or absolute path, , should know it's located in /home/me/my-haskell-app/ directory. i thought functionality available in system.environment module might able help, fell little short. getprogname did not seem provide useful file-path information. found environment variable _ (that's underscore) sometimes contain path script, invoked; however, script invoked via other program or parent script, environment variable seems lose value (and needing invoke haskell script another, parent application). also useful-to-know whether can determine directory in pre-compiled haskell executable lives, using same technique or otherwise. there find...

Scheme procedure to compute the nth repeated application of a function? -

is familiar this? write procedure takes inputs procedure computes f , positive integer n , returns procedure computes nth repeated application of f. procedure should able used follows: ((repeated square 2) 5) 625 i know following code i've created composition of functions make solution simpler, i'm not sure go here: (define (compose f g) (lambda (x) (f (g x)))) well, want this, right? ((repeated square 3) 5) -> (square ((repeated square 2) 5)) -> (square (square ((repeated square 1) 5))) -> (square (square (square ((repeated square 0) 5)))) -> (square (square (square (identity 5)))) (i don't know whether identity predefined in scheme. if not, it's easy write.) now, not directly reproducible because can't magically enclose code outside of call repeated arbitrary stuff. however, these reduction steps when rewritten using compose ? can make out pattern in resulting list of steps , reproduce it?

php - Ordering by two fields -

the input below sorts submissions timestamp field called "datesubmitted" in reverse chronological order. field in mysql table called "submission." another mysql table "comment" has timestamp field called "datecommented." each submission has 1 "datesubmitted" have several comments, each different "datecommented." how sort submissions "datesubmitted" , each one's last "datecommented"? in other words, want top of list show either submitted entry or entry recent comment, whichever occurred most recently. thanks in advance, john $sqlstr = "select s.loginid ,s.title ,s.url ,s.displayurl ,s.datesubmitted ,l.username ,s.submissionid ,count(c.commentid) countcomments submission s inner join ...

ruby on rails - Controller tests with authlogic expecting user_sessions table -

i'm using authlogic (along authlogic rpx ) in new rails 3 application (beta4 , upgraded rc). i cannot of functional tests pass. anytime try run rudimentary test, end error: 4) error: test_the_truth(userscontrollertest): activerecord::statementinvalid: sqlite3::sqlexception: no such table: user_sessions: delete "user_sessions" 1=1 it doesn't matter controller i'm testing (even if it's not associated authlogic), seems expect usersession model requires database table, though inherits directly authlogic::session::base outside of using rpx plugin, super-base authlogic setup, , not have issue running application itself. in tests. any thoughts? it appears being hamstrung rails 3's backtrace filtering . re-ran tests provide full backtrace: backtrace=foo rake test turns out problem attempting load test fixtures users_session auto-generated classes.

c# - How to get the current user in ASP.NET MVC -

in forms model, used current logged-in user by: page.currentuser how current user inside controller class in asp.net mvc? if need user within controller, use user property of controller. if need view, populate need in viewdata , or call user think it's property of viewpage .

android - How to position a Button in a RelativeLayout through code? -

< relativelayout android:layout_width="wrap_content" android:layout_height="wrap_content"> < button android:text="previous" android:layout_height="wrap_content" android:id="@+id/measureprev" android:layout_alignparentbottom="true" android:layout_width="wrap_content"> < / button> < / relativelayout > can tell me how can using java code or in activity class? not know how set android:layout_alignparentbottom="true". want implement whole view via java code. here dynamic equivalent of code : relativelayout rl = new relativelayout(this); layoutparams params = new relativelayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content); rl.setlayoutparams(params); button button = new button(this); button.settext("previous"); layoutparams params1 =...

svn - What is the best way to see what files are locked in Subversion? -

i got group switch sourcesafe subversion. unfortunately, manager still wants use exclusive locks on every single file. set svn:needs-lock property on every file , created pre-commit hook make sure property stays set. we running subversion on linux server. of use windows machines , few use macs. using various svn clients (tortoisesvn, smartsvn, subclipse, etc.). what need good/easy method see files locked in entire repository (and has them locked). have poked around little in tortoise , subclipse, haven't found looking for. our projects have many subdirectories multiple levels deep, time consuming @ each individual directory. what single report can run lists locked , has locked. best way type of information? what you're looking svnadmin lslocks command. i have set @ work because keep word documents in our subversion repository (with svn:needs-lock ). have cron job set every day, checks list of locks , emails report of locks older 7 days whole team....

what is jquery CSS frame work and how to use the frame work for giving look and feel to the website? -

what jquery css frame work , how use frame work giving , feel website? , how give skins? give me how implement jqueyui css class , id maintain consistent , feel entire site? demos ? the way learned using firebug , reading styles on this page . by reading classes applied elements, got familiar framework , started applying project. class names obvious , it's easy learn. you can combine of javascript methods framework provides, such button() , buttonset() automatically styled you. radio buttons , checkboxes amazing, administration/management interface, they're perfect! good luck , have no doubt you'll enjoy framework.

java - NoClassDefFoundError when running from the comand line -

i use external library (e.g. google's guava) java program. use eclipse, downloaded guava's jar (and source) , followed adding java library project classpath add eclipse , buildpath of project. this works fine: can run program eclipse , runnable jar export eclipse, error when try run directly bin/ dir, used before: exception in thread "main" java.lang.noclassdeffounderror: com/google/common/base/joiner what should do? if you're running class file directly project bin directory may have specify classpath manually: c:> java -classpath c:\java\myclasses;c:\java\otherclasses myclasshere

greatest n per group - Array slicing / group_concat limiting in MySQL -

let's have table: j --- 1 2 3 4 b 5 b 6 b 7 b 8 b 9 obvoiusly select a, group_concat(b separator ',') group a give me 1,2,3,4 b 5,6,7,8,9 but if want limited number of results, 2, example: 1,2 b 5,6 any ideas? best way use substring_index() , group_concat() . select i, substring_index( group_concat(j), ',', 2) mytable group i; you don't have know length of j field here.

ruby on rails - embeding PPT in the webpage -

i working on application require documents embeded inside webpage . want embed powerpoint slides inside page, pointer helping the application working on built on ruby on rails i have checked google doc viewer reason not rendering pdf/ppt application code used <iframe src="https://docs.google.com/viewer?url=<%= uri.escape('http://myapp.com/doc_name.pdf') -%>&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe> the problem was behind firewall / proxy server blocked request site.... worked smoothly answering pending questions :)

ruby on rails - :id in URLs -

i'm still new ror, pardon simplicity of question... so http://www.example.com/controller/:id displays record in table, :id being number (1,2,3 etc.). is there way can have :id in url value of field in displayed record? such can have http://www.example.com/controller/record_field ?? want have human-friendly reference specific records in table...i'm sure must possible. change in routes.rb? thanks help! the cleanest way add new find method in model (or use find_by_fieldname rails gives in control). you'll have controller use method instead of regular find(params[:id]) pull model record. check out ryan b's screencast on here . it's pretty easy, , he's teacher, shouldn't have problems.

php - Type hint for '$this' and other variables in phpFramework::view files? -

possible duplicate: variable type hinting in netbeans (php) /edit in php frameworks, in views, $this refers controller object. netbeans doesn't know (i guessing neither other ides), when hit ctrl + space, code completion doesnt work (says no sugestions). is there trick, or phpdoc directive can tell ide types of variable isn't declared in current file (and there no "include" or require_once either, because php framework takes care of convention, no explicit include made). also in php frameworks there other variables besides $this in view.php files, putting on top of file php doc them doesn't seem either. eclipse has method discovery, should php specialised versions of - aptana, or zend studio.

java - Where is groovy.swing.factory.BindProxyFactory? -

when trying use graphicsbuilder, java.lang.noclassdeffounderror groovy.swing.factory.bindproxyfactory . this environment: % java -version java version "1.6.0_10" java(tm) se runtime environment (build 1.6.0_10-b33) java hotspot(tm) server vm (build 11.0-b15, mixed mode) % groovy --version groovy version: 1.5.7 jvm: 1.6.0_10 % ls ~/.groovy/lib/graphicsbuilder* graphicsbuilder-0.6.1.jar ... and try do: % groovysh groovy shell (1.5.7, jvm: 1.6.0_10) type 'help' or '\h' help. ------------------------------------------------------------------------------- groovy:000> import groovy.swing.swingbuilder groovy:000> import groovy.swing.j2d.graphicsbuilder groovy:000> import groovy.swing.j2d.graphicspanel groovy:000> def gb = new graphicsbuilder() error java.lang.noclassdeffounderror: groovy.swing.factory.bindproxyfactory @ groovysh_evaluate.run (groovysh_evaluate:5) ... where bindproxyfactorybean? it's in groo...

Logging every data change with Entity Framework -

there need customer log every data change logging table actual user made modification. application using 1 sql user access database, need log "real" user id. we can in t-sql writing triggers every table insert , update, , using context_info store user id. passed user id stored procedure, stored user id in contextinfo, , trigger use info write log rows log table. i can not find place or way or how can similar using ef. main goal is: if make change in data via ef, log exact data change table in semi-automatic way (so don't want check every field change before saving object). using entitysql. unfortunately have stick on sql 2000 data change capture introduced in sql2008 not option (but maybe that's not right way us). any ideas, links or starting points? [edit] notes: using objectcontext.savingchanges eventhandler, can point can inject sql statement initialize contextinfo. cannot mix ef , standard sql. can entityconnection cannot execute t-sql statemen...

Busy indicator for WCF async calls in Silverlight 4? -

i have sl4 app consuming wcf services. client make async call services, during time show sort information or busy indicator on screen tells users app doing something. now pretty sure sl4 has this, drawing blank.... can please point me right direction? maybe looking busyindicator control part of silverlight toolkit experimental quality band. can try control on following link: http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html

Freeing variable-sized struct in C -

i using variable-sized c struct, follows: typedef struct { int num_elems; int elem1; } mystruct; // have 5 elements hold. mystruct * ms = malloc(sizeof(mystruct) + (5-1) * sizeof(int)); ms->num_elems = 5; // ... assign 5 elems , use struct free(ms); will last free() free malloc'd, or sizeof(mystruct)? yes. free whole block allocated using malloc . if allocate single block of memory using malloc (like in example), need call free once free entire block.

cloud - Restoring an image, in a VM, without booting it -

i'm using uec cloud (with kvm) can restore image, in vm, without booting it? (like freezing image , restarting image on exact tick while skipping whole booting) is 'snapshot' is? if it's possible, general steps it? i think virsh save , virsh restore commands looking for. virsh part of libvirt, abstraction layer can talk different virtualization solutions kvm , xen. i don't know how these 2 commands implemented.

c# - Duck Typing DynamicObject derivate -

i wrote class allows derivate specify of properties can lazy loaded. code is: public abstract class selfhydratingentity<t> : dynamicobject t : class { private readonly dictionary<string, loadablebackingfield> fields; public selfhydratingentity(t original) { this.original = original; this.fields = this.getbackingfields().todictionary(f => f.name); } public t original { get; private set; } protected virtual ienumerable<loadablebackingfield> getbackingfields() { yield break; } public override bool trygetmember(getmemberbinder binder, out object result) { loadablebackingfield field; if (this.fields.trygetvalue(binder.name, out field)) { result = field.getvalue(); return true; } else { var getter = propertyaccessor.getgetter(this.original.gettype(), binder.name); result = getter(this.original); return true; } } ...

osx - how to change symlink target while preserving inode -

normally change symlink target 1 first unlink file , re-creating symlink new target path. assigned new inode number. maybe there private mac api update_target_for_symlink() function, inode can stay same? in case wonder need for.. file manager. doubt possible @ all. anyways thats makes interesting. it looks lot isn't possible @ all.

ruby - Rails: Check has_many in View -

if have... class bunny < activerecord::base has_many :carrots end ...how can check in view if @bunny has carrots? want this: <% if @bunny.carrots? %> <strong>yay! carrots!</strong> <% carrot in @bunny.carrots %> got <%=h carrot.color %> carrot!<br /> <% end %> <% end %> i know @bunny.carrots? doesn't work -- would? <% if @bunny.carrots.any? %> <strong>yay! carrots!</strong> <% carrot in @bunny.carrots %> got <%=h carrot.color %> carrot!<br /> <% end %> <% end %>