Posts

Showing posts from April, 2011

ruby - Serving large static files with Sinatra -

sinatra can serve files static directory set :public, 'your_directory' command, how can replicate in new route? importantly, new route needs respect byte ranges too! ideas? feel should able leverage present code in static serve part of sinatra. i think can use send_file ( see here ) - if has other suggestions have open ears!

string - In Python, can you have variables within triple quotes? If so, how? -

this simple question some, has me stumped. can use variables within python's triple-quotes? in following example, how use variables in text: wash_clothes = 'tuesdays' clean_dishes = 'never' mystring =""" wash clothes on %wash_clothes clean dishes %clean_dishes """ print(mystring) i result in: wash clothes on tuesdays clean dishes never if not best way handle large chunks of text need couple variables, , there ton of text , special characters? one of ways : >>> mystring =""" wash clothes on %s ... clean dishes %s ... """ >>> wash_clothes = 'tuesdays' >>> clean_dishes = 'never' >>> >>> print mystring % (wash_clothes, clean_dishes) wash clothes on tuesdays clean dishes never also @ string formatting http://docs.python.org/library/string.html#string-formatting

iPhone openID authentication and embed HTML -

question 1 i want make iphone application uses openid authentication. have found janrain described here : http://techcrunch.com/2010/04/05/janrain-openid-iphone-apps/ want! commercial licenced there open source/free alternatives? question 2 i want later make android , windows mobile , etc versions of applicaion. save making multiple application thought can make 80% of application in html other 20% needs gps need iphone app. possible make iphone application of screens web pages? not want open safari want embed html directly application user still think in application still? i found can use html/css/javascript solution develop app. and still have access gps etc. using http://www.phonegap.com/ , http://jqtouch.com/ etc this should mean can use regular openid or yahoos mobile phone optimised version here http://developer.yahoo.com/blogs/ydn/posts/2009/10/yahoo_openid_an/ can keep solution 100% web based.

sql server - IIS 7 PHP Unable to load dynamic library -

i installed php , php manager on iis machine through web installer thing. can run web page php in fine, wont load libraries correctly. want connect ms sql database, got dll , put in ext folder wont load: php warning: php startup: unable load dynamic library 'c:\php\ext\php_sqlsrv_52_ts_vc6.dll' - specified module not found. in php.ini extention_dir set c:/php/ext, , file there. in fact spits out error every single external dll referenced 10 of them, there. suggestions? edit: i fixed issue manually downloading version 5.3.3 of php off of php windows website. pointed iis new exe , had load 53 vc9 version of sqlserv dll. ended working. try this: http://www.somacon.com/p541.php

java - Tomcat internationalization maintenance -

i trying implement internationalization in tomcat. there going different resource text files. idea load resources in memory while tomcat loads. below sample code load multiple resource in memory. public class resourcebundleloader { private static resourcebundle enresourcebundle; private static resourcebundle frresourcebundle; public static void loadbundle(){ locale enlocale = new locale("en", "us"); enresourcebundle = resourcebundle.getbundle("messagesbundle",enlocale); enlocale = new locale("fr", "fr"); frresourcebundle = resourcebundle.getbundle("messagesbundle",enlocale); } public static resourcebundle getenresourcebundle(){ return enresourcebundle; } public static resourcebundle getfrresourcebundle(){ return frresourcebundle; } } the method loadbundle called once thru startup servlet. , getenresourcebundle() , getfrresourcebundle()...

ruby on rails - How do I find all the records regardless of case -

what can find case insensitive search >> band.find_by_name("metallica") => nil >> band.find_by_name("metallica") => #<band id: 3, name: "metallica", created_at: "2010-10-03 01:17:24", updated_at: "2010-10-03 01:17:24", user_id: "4"> i need find record in both cases...any suggestions? band.find(:all, :conditions => ['name = lower(?)', band_name.downcase])

browser - C# Webbrowser navigation question -

hello im trying log site using webbrowser control working @ logging in, when go different page of site programmaticly using navigate or making webbrowser click on link im not logged in more? im guessing has cookies or haven't been able find on google of how work. htmlelement content = this.wb.document.getelementbyid("content"); htmlelement username = content.document.all["username"]; username.setattribute("value", "username"); htmlelement pass = content.document.all["password"]; pass.setattribute("value", "password"); htmlelement gobutton = content.document.all["submit"]; gobutton.focus(); sendkeys.send("{enter}"); is have. ah hell tried use didn't work correctly anyway button text has in , not style also? as comparison, work if record sequence imacros internet explorer ?

c# - How do I hide/show items in a CheckedListBox? -

i have instance of system.windows.forms.checkedlistbox displays list of tick boxes , have other system.windows.forms objects in application. to, depending on user selects using other system.windows.forms items, show or hide different items in system.windows.form.checkedlistbox . how achieve this? note: windows desktop application, not webpage. there no easy way hide item in checkedlistbox , have remove it, brendan vogt showed you. an alternative take advantage of data binding. not supposed work checkedlistbox , documentation of datasource property says: this api supports .net framework infrastructure , not intended used directly code. gets or sets data source control. property not relevant class. however, used in past, , works fine. if assign dataview datasource list, can filter items using rowfilter property dataview view = new dataview(productsdatatable); checkedlistbox.datasource = view; checkedlistbox.displaymember = "name"; ... // ...

c++ - Windows service won't stop and restart -

i wrote windows service in c++ needs restart every night @ midnight, call exit(1) on can restarted scm. problem seems every other night starts partially , hangs. in event log, this: application popup -application error: instruction @ "0x0043c145" referenced memory @ "0x00000035". memory not "read". it seems fail right before opening odbc connection sql server 2008 database. can confirm service exits before restarts; nevertheless error every once in while when stops , restarts itself, if stop , restart service manually on , on can never fail, , if control process terminal port , exit manually there never fails either. if try attach debugger process quits, can't glean useful information way either. i'm tearing hair out trying figure out what's going on, don't know start. have ideas? not direct answer if on vista(and afters think) there chance can try: "a service notifies scm queue failure action entering...

visual studio 2008 - Windows Mobile Emulator connection timeout accessing local web service -

i have windows mobile 6 application trying make web service call service hosted on local machine can debug logon process vs2008 connecting both emulated device , web service. i have configured device emulator connect internet , confirmed doing bing search ie on device. have checked web service running , working using local test form on machine , having installed vxutil emulated device , checked can ping machine , make request web service url http://mymachinename>/service/myservice.asmx , both successful. the application checks network connectivity checking web request response www.google.com , successful when try , call login method web service i'm getting .net socketexception 10060 - a connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond . note: network connectivity check replaced along lines of article: establish network connectivity windows mobile connecti...

java - How to react to stack unwinding when destructors are not supported by a language? -

suppose have created instance of window class. window shown user. then, exception thrown, , reference instance lost, window still seen user because instance still exists (it's not referenced anymore). what in these circumstances? i'm talking squirrel scripting language (http://www.squirrel-lang.org/). contrary java, doesn't seem have finally blocks or finalizer methods, exception handling broken in language? i don't know squirrel, in absence of block simulate behaviour extent within java: exception error = null; try { // } catch (exception e) { error = e; } // code goes here // ... if (error != null) { // oh dear clean resources - files, windows, sockets etc. throw error; } so catch block stores exception in variable can test later if want rethrow it, , still allows chance other cleanup. there nuances have aware of (e.g. explicit kinds of exception need special handling, more exceptions being thrown outside try / catch) careful consideratio...

actionscript 3 - Fullscreen mode loaded when opening Flash Player -

is possible make flash player go full screen (not in browser)? there bug / error on different version of flash player? hi! stage.displaymode = stagedisplaystate.full_screen_interactive; available only in adobe air. allows listen keyboard events (meaning can type inside text boxes etc..) stage.displaymode = stagedisplaystate.full_screen; available in as3 based flash file (starting flash 9) there no issue using it, except cannot use keybard .

How to handle NULL values in mysql/php? -

in mssql server, make queries null values below: select name, isnull(about, ''), contact `user_profile` userid=1 but when trying same mysql gives error. what logical , easy way handle null values in php/mysql scenario. thanks it's ifnull() mysql ^^ in case seems can return null value, use condition test it. if(!$result['valuemaybenull']) -> true if 0, false or null

sharepoint object modelling -

protected void btncreatelist_click(object sender, eventargs e) { spweb currentweb = spcontext.current.web; guid webid = currentweb.id; guid siteid = currentweb.site.id; response.write(siteid); spsecurity.runwithelevatedprivileges(delegate() { using (spsite site = new spsite(siteid)) { using (spweb web = site.openweb(webid)) { site.allowunsafeupdates = true; response.write("configured successfully"); } } }); } you running code outside sharepoint, or before spcontext initialized (http handler, example).

git - What's the easiest way to maintain a patched set of rails gems, with bundler? -

we're transitioning 'frozen' rails gems using bundler , maintain rails gems patches, merges etc. external git source. what's easiest way set up, adding gemspecs patch branches etc.? i store them on place accessible bundler (like public repo on github), in gemfile use :git=> option like gem "nokogiri", :git => "git://github.com/tenderlove/nokogiri.git"

objective c - Class in ObjectiveC doesn't seem to recognize inherited messages -

i'm learning objectivec "programming in objective c" stephen g kochan , i'm having difficulties example. creates simple fraction class inherits object. that's trouble, when try send messages understood object instead of fraction, such init, alloc or free (see code below): // fraction #import <stdio.h> #import <objc/object.h> // base object // @interface section @interface fraction: object { int numerator; int denominator; } - (void) print; - (void) setnumerator: (int) n; - (void) setdenominator: (int) d; @end // @implementation section @implementation fraction; -(void) print { printf(" %i/%i ", numerator, denominator); } -(void) setnumerator: (int) n { numerator = n; } -(void) setdenominator: (int) d { denominator = d; } @end // program section int main( int argc, char *argv[]) { fraction *myfraction; // create instance of fraction myfraction = [fraction alloc]; myfraction = [fraction i...

google play - Company Registration in Android Market -

sorry, question not programming related have else ask, asked in android center , support without responses. what need open company account in android market? want company seen seller. how authenticate company, documents need supply market? thanks you have create google checkout account

html - setting width of div jquery -

i'm trying set width of div using jquery. this how i'm trying set size of div $('#page').css("width",data[0]['imagewidth']); and div i'm trying set <div id="page"> </div> any appreciated in css lengths require unit, in case pixel ( px ): $('#page').css("width",data[0]['imagewidth'] + "px");

iphone - Best way to maintain column data when importing multiple formats -

i have app imports .csv file , turns each line core data object stored in database. csv files importing have 40-something columns , each column maps attribute of core data object. when started project, there 1 csv format working with, wrote 40-something lines of un-elegant static code import file, such as: ... newentity.yearofconstruction = [nsnumber numberwithint:[[currentrow objectatindex:35] integervalue]]; newentity.assessedvalue = [nsnumber numberwithint:[[currentrow objectatindex:36] integervalue]]; newentity.squarefootageofproperty = [nsnumber numberwithint:[[currentrow objectatindex:37] integervalue]]; ... now problem i've run import other csv file formats ordered differently in original use case. rather write switch(csvformattype) , add additional 40-line sets of code, elegant way store csv column-to-core data mapping arbitrary number csv file types , 1 set of code create core data objects? thanks! i'm working on similar right n...

Zend: Quick and succinct way of inserting custom HTML into a Zend_Form? -

is there method accepts inserting custom html without having add form controls, if they're hidden , making html decorator? i'm looking like: $this->addcustomelement( array( 'div', 'body' => '<p>inner text</p>' ) ); i need short , quick, don't want create new class or overkill. well it's simple this: $note = new zend_form_element('note'); $note->helper = 'formnote'; $note->setvalue('<b>hi</b>'); $form->addelement($note); but problem when submit form, form calls $note->isvalid() , overrides value, if there errors form, next time display it, custom html won't shown. there 2 easy ways fix this, first override isvalid() in form class this: public function isvalid($data) { $note = $this->note->getvalue(); $valid = parent::isvalid($data); $this->note->setvalue($note); return $valid; } but find kinda hackish way, , prefer second ...

ASP.NET security error -

iam trying work set property value in iis 6.0 api , getting security error: access denied. (exception hresult: 0x80070005 (e_accessdenied)) on line: path.commitchanges(); this code: function test() '-- dim metabasepath string dim propertyname string dim newvalue string '-- dim path directoryentry dim propvalues propertyvaluecollection '-- 'set iis path metabasepath = "iis://localhost/w3svc/1/root/image" ' propertyname = "path" newvalue = "d:\royshoa" path = new directoryentry(metabasepath) propvalues = path.properties(propertyname) propvalues.clear() propvalues.add(newvalue) path.commitchanges() response.write(propvalues.value) end function thanks, roy shoa.

iphone - How can I use a nonstandard color for the UIScrollView indicator? -

Image
the ui gives 3 options uiscrollviewindicatorstyle , want make uiscrollview indicator red, not 1 of standard styles. can this? if so, how? yes!! can both uiscrollview indicator sub view of uiscrollview. so, can access subview of uiscrollview , change property of subview. 1 .add uiscrollviewdelegate @interface viewcontroller : uiviewcontroller<uiscrollviewdelegate> @end 2. add scrollviewdidscroll in implementation section -(void)scrollviewdidscroll:(uiscrollview *)scrollview1 { //get refrence of vertical indicator uiimageview *verticalindicator = ((uiimageview *)[scrollview.subviews objectatindex:(scrollview.subviews.count-1)]); //set color vertical indicator [verticalindicator setbackgroundcolor:[uicolor redcolor]]; //get refrence of horizontal indicator uiimageview *horizontalindicator = ((uiimageview *)[scrollview.subviews objectatindex:(scrollview.subviews.count-2)]); //set color horizontal indicator [horizontal...

c++ - Defining operator< for a struct -

i use small structs keys in maps, , have define operator< them. usually, ends looking this: struct mystruct { a; b b; c c; bool operator<(const mystruct& rhs) const { if (a < rhs.a) { return true; } else if (a == rhs.a) { if (b < rhs.b) { return true; } else if (b == rhs.b) { return c < rhs.c; } } return false; } }; this seems awfully verbose , error-prone. there better way, or easy way automate definition of operator< struct or class ? i know people use memcmp(this, &rhs, sizeof(mystruct)) < 0 , may not work correctly if there padding bytes between members, or if there char string arrays may contain garbage after null terminators. this quite old question , consequence answers here obsolete. c++11 allows more elegant , efficient solution:...

asp.net - Data annotation attributes not working using buddy class metadata in an MVC app -

i have found hints mvc 2 recognises 'buddy class' type of property metadata, data annotation attributes applied 'buddy' metadata class, , metadatatype on actual entity class points buddy class, below. however, below, seems attribute makes difference rendered ui displayname . why other attributes datatype , required , , readonly not working? i.e. why can enter text in read field? why not error when required field empty? why datatype attribute have no apparent effect? why editorformodel not include validation messages? [metadatatype(typeof(customermetadata))] public partial class customer { public class customermetadata { [scaffoldcolumn(false)] public object customerid { get; set; } [displayname("customerno.")] [readonly(true)] [required(allowemptystrings = false, errormessage = "customer no. required.")] public object customerno { get; set; } } } i find behaviour same whethe...

sharepoint - Comment icon not updating after approval in blog site -

i set workflow comments in blog site. after approval should comment posted in blog. to test, created comment , received email approve. approved comment , added list. when click on comment icon displays new comment, little comment icon didnt update show new comment. still said (0 comments). need have update? thanks, ninel sounds caching somewhere along line. sure, try ctrl-f5 in browsers , see if updates.

iphone - How to implement a corner page curl UI? -

i have app 2 full-screen views, 1 on top of other. show corner of top view curled away, , allow user curl away more until view underneath showing. the user should able interact whatever part of view underneath exposed, , whatever part of view above exposed. i'd , feel page turn curling in ibooks. i've done lot of searching ibooks page curl, not turns up. there's great opengl implementation , don't know how there here. ideas? a simpler implement, , therefore simpler visually approach available here: http://github.com/brow/leaves you may have bit more success starting small.

Multithreading in MySQL? -

are mysql operations multithreaded? specifically, on running select, select (or join) algorithm spawn multiple threads run together? being multi-threaded prevent being able support lot of concurrent users? several background threads run in mysql server. also, each database connection served single thread. parallel queries (selects using multiple threads) not implemented in mysql. mysql can support "a lot of concurrent useres". example facebook started mysql.

c# - Capture a scrolling window contents screenshot -

Image
i need capture screenshot of scrolling window's client area, using .net. first priority capturing web page screenshots. can not 1 use case. example can text area in notepad. some applications (faststone capture, picpick) can emulate user behavior reach hidden part of scrollable area , capture it. i'm looking or recommendations alternative way same result. you can windows redirect wm_paint offscreen buffer wm_print , wm_printclient. better screenscraping because makes sure obscured parts of window(behind other windows) painted anyway. if target window scrolls scrolling child window position, wm_print should apply. maybe helps scenario.

installation - Getting error after installing sql server 08 Express edition -

i have installed sql server 08 express edition , tried connect using sql server management studio, getting below error: title: connect server cannot connect my-pc\sqlserver. ------------------------------ additional information: a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: sql network interfaces, error: 26 - error locating server/instance specified) (microsoft sql server, error: -1) for help, click: http://go.microsoft.com/fwlink?prodname=microsoft+sql+server&evtsrc=mssqlserver&evtid=-1&linkid=20476 ------------------------------ buttons: ok any clue. are sure referencing correct sql server name? think default instance name sqlexpress. so, might try connecting .\sqlexpress, "." represents local computer.

web applications - Open remote document and save back to remote server -

i have programmed web app office runs on server. of our documents on server well. able have user browse folder on server through web app, open in editor (online or desktop), able edit , save server, in location opened from. i've been looking google docs, doesn't have ability embed editor outside of google docs site. i have been looking ms office web apps required lot of prerequisites , it's pretty pricey ($370 per license, mean i'd have spend around $10k able have employees open, edit , save docs through web app). is there possibility of opening remote file in word , being able click "save" , have save remote location? or there other solutions problem? i'm sure many have come across issue , there lots of ways approach it. webdav worth looking at; has advantage of integration word file open/save dialogs. can use various versions of webdav built windows or come office (note: these not same), or can use 3rd party provider if deficiencies o...

java - Does ThreadPoolExecutor spawns a new thread if a current thread sleeps -

this question followup on this one . essentially doing declaring threadpoolexecutor 1 thread. overriding beforeexecute() method put sleep each of tasks executed delay among themselves. give away cpu other threads since thread kind of thrashing. so expected behavior is: for each new task in threadpoolexecutor , calls before execute function before executing task , hence sleeps 20s before executes task. however see: for each new task submitted: it executes task calls beforeexecute method sleeps 20s re-execute task! the order of 1. & 2. not same time. here questions: it appearing new thread comes in after/during sleeping , goes ahead , executes task right away while actual thread sleeping. threadpoolexecutor spawn new thread existing thread sleeps [thinking thread terminated]?? tried put keepalivetime > sleeptime ..so in case above assertion true .. atleast waits more sleep time spawn new thread ...[hoping in mean time sleeping thread awake , thread...

How can I open a Python shell at a network path in Windows? -

how can open python interpreter @ specific network path in windows? in explorer address bar path in unc form: \\myhost\myshare\... . i can't work out how change directory windows command line, nor in format pass argument os.chdir . i'm running python 2.5 on windows xp. idle installed. thanks! well, i'm going ask anyway because has bit me before have tried this? path = r'\\myhost\myshare\some_file.dat' the r being important bit here. see post well .

sql server - Conditional SQL ORDER BY ASC/DESC for alpha columns -

writing stored procedure in ms sql server 2008 r2, want avoid using dsql... i sort method (asc or desc) conditional. now, numeric column use case statement , negate value emulate asc or desc... is: ... order case @orderascordesc when 0 [numericcolumn] else -[numericcolumn] end asc what appropriate method doing alpha column? edit: thought of clever way seems terribly inefficient... insert ordered alpha column temp table autonumber sort autonumber using method described above. edit2: what guys think of approach? order case @orderascordesc when 0 [alphacolumn] else '' end asc, case @orderascordesc when 0 '' else [alphacolumn] end desc i don't know if forcing sort on uniform column more efficient deriving numbers sorted strings though one option ;with cquery ( select *, row_number() on (order sortcolumn) rownum mytable ) select * cquery order rownum * @direction --1 = asc or -1 = desc or case imho bi...

zend framework - Hudson failing build w/o revealing cause -

every build has failed of tuesday. i'm not sure happened. phing targets (clean/prepare) being executed properly. additionally, unit tests passing flying colors, warning duplicate code (not reason fail). tried removing phpdoc target see if causing error, build still failed. started user chris updating file://localhost/projects/svn/ips-com/trunk @ revision 234 no change file://localhost/projects/svn/ips-com/trunk since previous build [trunk] $ /opt/phing/bin/phing clean prepare -logger phing.listener.nobannerlogger buildfile: /var/lib/hudson/.hudson/jobs/ips/workspace/trunk/build.xml ips > clean: [echo] clean... [delete] deleting directory /var/lib/hudson/.hudson/jobs/ips/workspace/build ips > prepare: [echo] prepare... [mkdir] created dir: /var/lib/hudson/.hudson/jobs/ips/workspace/build [mkdir] created dir: /var/lib/hudson/.hudson/jobs/ips/workspace/build/logs [mkdir] created dir: /var/lib/hudson/.hudson/jobs/ips/workspace...

python - Chromosome representation for real numbers? -

i trying solve problem using genetic algorithms. the problem find set of integral , real values optimizes function. i need represent problem using binary string (simply because understand concept of crossover/mutation etc better when applied binary string chromosomes). a candidate solution s set {i1, i2, ... in, r1, r2, rm } where variables integers , r variables floating point numbers. i want able transform candidate solution s binary string, don't know how encode floating point numbers. any ideas on how encode set s chromosome? although solution supposed language agnostic, prefered choice of language (in decreasing order of preference particular task) is: python, c++, c btw, coding problem using pyevolve no, think binary representation wrong problem. basic data not binary, so, why use binary? mutation , crossover on real , integer numbers, not on binary representation. simplest crossover: first parent: abcde a, b, ... floating points numbers, seco...

A little Access VBA help? Validating against duplication of a non key field? -

i adding part name database using form, code put behind add part button validate against duplicate part names? (part number primary key) think need recordset search , compare table i'm bit lost, great. private sub btn_add_click() rs_parts.addnew rs_parts !partrno = lbl_partno.caption !name = txt_name rs_parts.update end i've discussed approach before, , given example form adding new record . i use unbound form collect information needed create new record, , have check duplicates, , present list of them user user can decide do. in case, sounds unique index in order, won't need worry close matches. still use unbound form capture new value , run check before attempting add it. in case, i'd notify user it's dupe.

python - How to use session on Google app engine -

i'm building application using google app engine python, , i'm stuck making sessions. there app app engine? thank you. i recommend gae-sessions . source includes demos show how use it, including how integrate users api or rpx/janrain. disclaimer: wrote gae-sessions, informative comparison of alternatives, read this article .

Interview Question: What is a hashmap? -

i asked in interview: "tell me know hashmaps." i proceeded that: it's data structure key-value pairs; hash function used locate element; how hash collisions can resolved, etc. after done, asked: "ok, explain said 5-year-old. can't use technical terms, hashing , mapping." i have took me surprise , didn't give answer. how answer? lets take big word book, or dictionary, , try find word zebra. can guess zebras near end of book, letter "z" @ end of alphabet. lets can find zebra inside of big word book. way can find zebras, or elephants, or other type of thing can think of in big word book. 2 words on same page apple , ant. sure page want at, aren't sure how close apple , ant each other until page. apple , ant can on same page , might not be, big word books have bigger words. that's how have done it.

jsp - Taglib in Java: tag with array parameter -

how can define tag receives array parameter? thanks jstl it, , can too. i happen have el function example handy, , i'll paste portion of c:foreach definition give idea: you pass delimited string, if want collection or array, can use this: <function> <name>join</name> <function-class>mypackage.functions</function-class> <function-signature>string join(java.lang.object, java.lang.string)</function-signature> </function> and /** * jstl's fn:join works string[]. 1 more general. * * usage: ${nc:join(values, ", ")} */ public static string join(object values, string seperator) { if (values == null) return null; if (values instanceof collection<?>) return stringutils.join((collection<?>) values, seperator); else if (values instanceof object[]) return stringutils.join((object[]) values, seperator); else return values.tostring(); } o...

c# - Help with using jQuery with ASP.NET MVC -

my app has "show comments" similar 1 in facebook. when user clicks on "show all" link, need update list has upto 4 comments comments. i'll show code first , ask questions: jquery: showallcomments = function (threadid) { $.ajax({ type: "post", url: "/home/getcomments", data: { 'threadid': threadid }, datatype: "json", success: function (result) { alert(result); }, error: function (error) { alert(error); } }); }; home controller: // get: /getcomments [httppost] public jsonresult getcomments(int threadid) { var comments = repository.getcomments(threadid).tolist(); return json(comments ); } questions: when tried instead of post, got error: "this request has been blocked because sensitive information disclosed third party web sites when used in request. allow requests, set jsonrequestbehavior allowget...

How do I push specific changesets to a shared library repo in Mercurial? -

i have repo called mysharedlib, , repo called myproject. mysharedlib included in many different repos force-pulling (like jedi), , not using subrepos. if clone myproject, left following structure: /myproject mysharedlib otherstuff files... mysharedlib not subrepo. pulling in changes mysharedlib easy running: hg pull -f path/to/mysharedlib. but if changes made /myproject/mysharedlib, what's straightforward/standard way push changes mysharedlib repo? mq? hg export? hg diff? hg transplant? understanding of these options work (some together, apart), i'd direction. and happens if dev makes commit includes other files within mysharedlib? avoid, i'm curious. here constraints govern can push: you can push whole changesets -- if commit changes it's or none on pushing front, can't break changeset after commit it you can't push changeset without pushing of ancestor changesets to so once you've committed linear history this:...

cocoa touch - Can I 'highlight' certain options in UIpickerview? -

i of options in upickerview have, say, blue, instead of white background color. implement pickerview:viewforrow:forcomponent:reusingview: method in delegate. create views want them , return them in method.

php - Sha1 substring question -

i making pastebin type site , trying make id random string paste.com/4rt65l i getting sha1 of id before add database getting substring of first 8 characters of sha1. possibility of being double copy of same sha1? dont want accidentaly second paste id has been used? well odds of having collision in 8 characters higher having collision 2 sha1 keys, doesn't mean happen. i recommend testing on it. generate random input , see how long takes before have collision. if results, go it. otherwise, you'll need longer string. edit: can calculate odds of collision looking @ birthday paradox . basically, if taking first 8 hex digits sha-1, have 16**8 (4,294,967,296) different available combinations. using online birthay paradox calculator, after 9200 hashes, have 1% chance of collision. take 30,000 hashes before have 10% chance, , 77,000 before have 50% chance. its important point out long hash function decent job of being pseudo-random, doesn't matter 1 use (whe...

Wrap dollar values in a span with jQuery? -

i've got bunch of h4 tags want wrap in <span class="red"> </span> some of text this: $12 , has space $ 5 how can wrap instances of $ , numbers follow jquery? let me clarify. want have <h4> item <span class="red">$42</span> , on sale</h4> i regular expression. like: var tempstring = $("h4").html().replace(/^(.*)(\$\s*\d+)(.*)$/, '$1<span>$2</span>$3'); $("h4").html(tempstring); the regular expression might need modification depending on situation. in second part of replace, put '$2' inside span tags class want add.

FailureResponse on otherwise successful OpenID login: Server denied check_authentication -

i'm testing openid authentication using python-openid on webpy's development web server. through yahoo! , myopenid, keep getting failure response message server denied check_authentication . strange part is, receive correct openid.identity . the same type of authentication works fine google (@ https://www.google.com/accounts/o8/ud ...). on 1 hand, gives me confidence i'm doing right, on other hand, inconsistency confuses me. return_to & trust_root both localhost:8080, may have it. here's code use send user yahoo! authenticate: def post(self): post_data = web.input() if post_data.has_key('openid_identifier'): openid_identifier = post_data.get('openid_identifier') c = consumer(session, openid.store.memstore.memorystore()) auth = c.begin(openid_identifier) auth_url = auth.redirecturl('http://localhost:8080', return_to='http://localhost:8080/authenticate') raise web.seeother(auth_ur...

Convert Sql Server 2008 to Sql Server 2005 Include Data -

how can convert sql server 2008 sql server 2005 need data of database , not structure using generate script it manual process regardless of questions posed. ran across solution , runs c# console application downgrade. rather elegant solution if ask me.

javascript - jQuery limit sortable to parent table row -

so have table has several categories, several items underneath in each category. something like: <tr> <td>category1</td> </tr> <tr> <td>item1<td> </tr> <tr> <td>item2</td> </tr> <tr> <td>item3</td> </tr> <tr> <td>category2</td> </tr> <tr> <td>item1</td> </tr> i want able sort each "item" within category only. "item1" inside "category2" should not able dragged "category1". not sure how accomplish this. you can implement jquery ui's sortable interaction achieve requirement. following working example: <style type="text/css"> .issortable { list-style-type: none; margin: 10px; padding: 5px; width: 60%; } .issortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; height: 1.5em; } html...

regex - How can I extract a pattern from all files in a directory, using Perl? -

i running command returns 96 .txt files each hour of particular date. gives me 24*96 files 1 day in directory. aim extract data 4 months result in 30*24*96*4 files in directory. after data need extract "pattern" each of files , display output. 1) below script 1 day date hardcoded in script 2) need make work days in month , need run june october 3) data huge , disk run out of space don't want create these many files instead want grep on fly , 1 output file . how can efficiently ? my shell script looks this for r1 in {0..9}; s1 in {0..95}; echo $r1 $s1 curl -h "accept-encoding: gzip" "http://someservice.com/getvalue?count=96&data=$s1&fields=hittype,querystring,pathinfo" | zcat > 20101008-mydata-$r1-$s1.txt done done this returns files need. after that, extract url pattern each of file grep "test/link/link2" * | grep category > 1. output you can use awk command urls awk -vrs=...

COM Exception trying to get Presence from Office Communicator 2007 -

i building proof of concept on new box has been set windows server standard running iis 7. the task need take logged in user , using office communicator 2007 check presence (and type of presence, online, offline, away, busy etc) of other users on exchange box on same machine. the code seems pretty simple: public string getstatus(string username) { try { if(this.currentcommunicator == null) this.currentcommunicator = new communicatorapi.messengerclass(); this.currentcommunicator.signin(0, "********", "*****"); if (currentcommunicator != null) { foreach (imessengercontact contact in currentcommunicator.mycontacts imessengercontacts) { if (!contact.isself) if (contact.signinname.contains(username)) { mistatus status = contact.status; ...

vbscript - Group file to New Folder? -

i have copy files, make new folder , paste files new folder often. i wonder if can make batch file or vbscript file perform task? select files , choose "group new folder" context menu. that'll awesome! i've found solution in .net 4.0 http://blogs.msdn.com/b/codefx/archive/2010/09/14/writing-windows-shell-extension-with-net-framework-4-c-vb-net-part-1.aspx

php - CakePHP: Strip HTML using Text helper? -

i'm using truncate method of text helper , in doing means html included in text being rendered. there anyway set text helper strip out html tags? echo $text->truncate( $project['project']['description'], 250, array( 'ending' => '...', 'exact' => false ) ); is there modification similar striplinks method? thanks, jonesy echo $text->truncate( $project['project']['description'], 250, array( 'ending' => '...', 'exact' => false, 'html' => true ) ); that make respect html structure. can use strip_tags(), there nothing wrong using php functions in cake :)

scala - Removing nodes from XML -

i want produce xml document another, filtering subnodes match specified criterion. how should that? you can use ruletransformer scala.xml.transform. suppose have action attribute "remove" value val removeit = new rewriterule { override def transform(n: node): nodeseq = n match { case e: elem if (e \ "@action").text == "remove" => nodeseq.empty case n => n } } new ruletransformer(removeit).transform(yourxml)

java - JSF / Mojarra 2.0.2: ui:repeat is totally broken when updating via AJAX -

using ui:repeat simple listing of elements produces strange results - when add element, first element replaced values last element before submit. same occurs when removing elements - first element shows removed element. with h:datatable same works perfectly. running mojarra 2.0.2. this because bug in mojarra 2.0.2 . @ least in case, updating mojarra 2.0.3 resolves issue. however, bug refers cases won't work 2.0.3. just wanted write separate question i've been having sorts of problems (and asking sort of questions) relating ui:repeat , specific case again. other failings ui:repeat : why doesn't h:datatable inside ui:repeat correct id? how refer datatable parent within datatable? my conclusion: whole ui:repeat tag totally broken @ least in mojarra 2.0.2. updating mojarra 2.0.3 fixes of issues.

wcf security - Mutual Authentication with Self-Hosted WCF Service -

i'm looking creating wcf service connect our product management system provide/update product licensing information. self hosting service wrapped in nt service , i'm looking @ ways mutually authenticate both service , client. clients desktop applications running on same machine service i'm thought nettcp binding transport security sufficient having looked @ documentation think can achieve windows credential security isn't going enough me. principally i'm trying prevent spoof applications invoking operations on our service , trying prevent spoof services masquerading our own. can give me suggestions? i'm little concerned might have certificates :s cheers, chris. you can use certificates (service / client) mutual authn. see http://msdn.microsoft.com/en-us/library/ms733102.aspx

android - Common tasks in Activities methods - how to organize them? -

i have common actions fired in onpause() , onresume() methods. (like registering , unregistering broadcatsreceivers ) now put them in abstract classes , extend activity classes. after creating abstract classes common actions end situation when can't extend activity because of java's lack of multiple inheritance. how deal such things? duplicate code or smarter? i'm wondering if it's wider problem - not concerning android, java language. task , task b 2 separate tasks. used in 1 class. can have single abstract class. abstract may not necessary if feel there no functions have overridden in child class. if reason there may task d, uses task alone, can following: public abstract class extendedabstractactivitya extends activity { public void taska() {} public void taskb() {} //other abstract classes } you can call these tasks individually respective classes.

iphone - Does EAAccessoryManager list bluetooth headsets connected? -

as per title, ios call eaaccessorymanager.connectedaccessories return connected bluetooth headsets (including not made-for-iphone registered? dont need connect want know if can use proximity of device trigger event. no. return eaaccessory instances representing made ipod devices publish protocol. external accessory programming topics: communicating external accessory requires work closely accessory manufacturer understand services provided accessory. manufacturers must build explicit support accessory hardware communicating ios. part of support, accessory must support @ least 1 command protocol, custom scheme sending data , forth between accessory , attached application.

Setting a field to a date in the future using jQuery or Javascript -

i need able set input field date 365 days current date. field sets expiration date of membership purchase. have javascript not work reason. <input type="text" name="zoneexpiry" id="expirydate" /> <script type="text/javascript"> function setexpirydate( ) { var dat=new date(); dat.setdate(dat.getdate() + 45); var monthname=new array("jan","feb","mar","apr","may","jun", "jul","aug","sep","oct","nov","dec") var pretty = dat.getdate() + "-" + monthname[dat.getmonth()] + "-" + dat.getfullyear(); document.getelementbyid("expirydate").value = pretty; } </script> i'm no javascript expert reason not setting input field proper value. is there way fix javascript or accomplish similar task using jquery? the date format needs 01-jan-2010, day-month-4digit year. thanks hel...

c# - Show Hide using Javascript on a control, inside a ASCX control in a gridview. (ASP.NET + Javascript) -

i have written web usercontrol (ascx). inside, there panel want show/hide on click of hyperlink inside usercontrol. normally, easy doing (the onclick attribute added hyperlink on prerender): var paneltoshow = document.getelementbyid('<%=panelinvoicehasbeencreated.clientid %>'); if (paneltohide != null) { paneltohide.style.display = 'none'; } but because ascx control held within gridview, above assess controls (of there many in gridview) name 'panelinvoicehasbeencreated'. time work when there 1 row in gridview. currently, existing code, if click hyperlink in row, shows/hides panel in bottom row of gridview! therefore, question how actual, unique id need show/hide on correct control in correct row?????? thanks in advance. you can @ rowdatabound event of gridview write below code @ gridview rowdatabound event var usercontrol1=(usercontrol)e.item.findcontrol("usercontrol1"); var hyperlink1=(hyperlink)userc...

Create HTTP post request and receive response using C# console application -

i need post data url (https://somesite.com) download file in responsestrem based on parameters posted. how can using c# console application? parameters: filename, userid, password, type take @ system.net.webclient class, can used issue requests , handle responses, download files: http://www.hanselman.com/blog/httppostsandhttpgetswithwebclientandcandfakingapostback.aspx http://msdn.microsoft.com/en-us/library/system.net.webclient(vs.90).aspx

java - Can visualvm connect automatically via JMX to a remote process? -

i have java process running on remote machine, , process sets mbeans. have jstatd running on machine same user java process. (the mbeans can set programmatically or using -dcom.sun.management.jmxremote... etc, doesn't appear make difference). visualvm able make jstatd connection process, discovers automatically, means don't access mbeans or, example, cpu history chart. alternatively can create explicit jmx connection, gives me usual range of useful tools, want application assigned random jmx port when starts, config can't static. is there way visualvm auto-connect process via jmx? require auto-discover jmx ports, have thought jstatd that. know of plugins visualvm automate this? unfortunately there no way assign random jmx port remote application. can start remote application -dcom.sun.management.jmxremote.port=<fixed port> -dcom.sun.management.jmxremote.ssl=false -dcom.sun.management.jmxremote.authenticate=false and visualvm able read configu...

cocoa - How to auto-select next row after deleting current row by core data context? -

i using core data manage objects , using nstableview display objects. table columns binded objects' properties through nsarraycontroller . when users click delete button, selected objects in nstableview deleted. remained objects left in nstableview . this works smoothly. after deleting selected rows, nstableview not select row automatically. result, users have type once arrow key or use mouse select new row. so question is: how make nstableview select next or previous row after selected rows deleted? of course, select left row programmatically after deleting. wondering whether there more elegant way achieve this. thanks

how to load a web start application into eclipse rcp -

i have webstart apps/jnlp in add made rcp client. can integrate web start application rcp appear under menu toolbar if clicked load ithe application.if how go doing that, need place plug-in? thanks help! check out this tutorial lars vogel learn how use commands in eclipse rcp (and enable command execution menus). then, in command handler, write code opens web browser url of application passed parameter: //assuming 'url' url of application platformui.getworkbench().getbrowsersupport().createbrowser(null).openurl(url); also, check out this link learn more eclipse rcp browser support. since didn't specify whether want opened internal or external browser, might want tweak code posted.

vb.net - Adding a subreport to Active Reports -

i'm writing report in vb .net (using active reports) displays details location, , displays bunch of images, stored in database. images displayed in main report via subreport. however, can't images load. have 2 files, main report (rptmain) , image subreport (rptsubimages). sub detail1_format in rptsubimages never gets ran, why images not appearing, , can't figure out why! i've included code below... can pinpoint why subreport detail section isn't getting called? rptsubimages report gets initialized, if put stop point inside detail sub, never gets caught during debug. here code: rptmain: imports datadynamics.activereports imports datadynamics.activereports.document imports system.data imports system.data.oledb public class rptmain private rpt rptsubimages private sub rptmain_reportstart(byval sender object, byval e system.eventargs) handles me.reportstart end sub private sub detail1_format(byval sender system.object, byval e system....

best jquery-based lightbox / popup dialogbox? -

i'm looking jquery-based popup dialog box use : displaying static content pages (terms of use, etc) the contact page (already uses jquery form plugin ajax submit) displaying full-size photo thumbnails. can recommend 1 can fulfills above , rather lightweight , easy use ? thanks in advance. i use fancybox - http://fancybox.net/ handles pretty kind of content, rather easy use , configure, , should work in browsers. needs little fix ie8 though think, can find on site or google easy enough.

tfs - Team Foundation Server: New Files -

we're in process of evaluating team foundation server source control. there doesn't seem great way "discover" developer has added file(s) solution. have tips make new files "jump out" bit? there several alternatives there option latest version when open new solution. (tools -> options -> source control -> environment -> when solution or project opened) you can set alerts on checkin see when has checked in files. easiest way install tfs power tools - http://visualstudiogallery.msdn.microsoft.com/en-us/c255a1e4-04ba-4f68-8f4e-cd473d6b971f - go tools -> alerts editor another tip when want integration of sources use team build.

javascript - IE problem with optgroup / option onclick event -

this doesn't work ie7. know work around? <select> <optgroup label="swedish cars"> <option value="volvo">volvo</option> <option value="saab">saab</option> </optgroup> <optgroup label="german cars"> <option value="mercedes" onclick="alert(1);">mercedes</option> <option value="audi">audi</option> </optgroup> </select> when pick mercedes, can see alert box. doesn't happen in ie. try this <select onclick="myalert(this.value)"> <optgroup label="swedish cars"> <option value="volvo">volvo</option> <option value="saab">saab</option> </optgroup> <optgroup label="german cars"> <option value="mercedes">mercedes</option> <option value="audi">...

sql - SSIS bulk insert into a single table concurrently -

i have ssis package task load out-of-process application bulk-insert data 1 table. problem multiple out-of-process applications run when multiple files arrive @ same time. result in insertion failure. can sql server broker service queue inserting data? sql server or ssis have mechanism handle concurrent reliable insertion? i use ssis' execute process task execute bulk insert linq sql console application thanks. it sounds you're getting timeout issues because first run of ssis package locking table , other running copies of package waiting lock released. there couple of things can confirm this. first, in sql server management studio (ssms), open query window , when situation occurring execute command exec sp_who2 . see blkby column in results. column contains spid value blocking selected process. you'll see 1 instance of package blocking other packages. in ssis designer, in data flow task, edit destination component. there's table lock check...