Posts

Showing posts from August, 2012

How to tell the Android Emulator to use an external hardware device (e.g. a microphone)? -

is possible tell android emulator use external hardware? in case, want use microphone input app i'm developing... i know emulator start-up commands, can't seem these working... is there can tell me more how use start-up commands trough eclipse? or how determine backend have specify when using let's -audio-in <backend> start-up command... i need work, can't debug on phone use test apps... for additional(start-up) command below resolution: got project->run->run configuration->target->scroll down see additional emulator command line options.......give additional command here..android launch emulator youe specified command

multithreading - Thread BLOCK issue in java -

i have thread block issue. please me. in class, have 2 objects. 1 for synchronizing threads , other doing actual business operations. here class class a{ object lock = new object(); b b = new b(); public addsomething(){ synchronized(lock){ b.dothis(); } } } i have single instance of class 'a' , multiple threads accessing method a.addsomething(). encountering thread block issue this. the problem in b.dothis() . if isn't well-behaved (it takes long time execute or may never finish) other threads call addsomething blocked.

struts2 - captcha plugin for struts 2 -

any captcha plugin struts 2 other jcaptcha4struts2 , provide useful link also try this: http://code.google.com/intl/de-de/apis/recaptcha/docs/java.html it pretty straightforward struts 2. i recommend copy on source code (its asl licensed , therefore allowed) , follow instructions. or create taglib, if avoid java code in jsp. the server side instructions can modified use field names recaptcha_challenge_field , recaptcha_response_field. if add following methods action: public httpservletrequest gethttpservletrequest() { return httpservletrequest; } public void sethttpservletrequest(httpservletrequest httpservletrequest) { this.httpservletrequest = httpservletrequest; } and add following listener web.xml: <listener> <listener-class>org.springframework.web.context.request.requestcontextlistener</listener-class> </listener> you able catch httpservletrequest necessary validate captcha. hope helps. cheers, christian

asp.net mvc - How do I use autofac to resolve a WCF Data Service? -

i creating wcf data service using wcf data services toolkit , whitepaper building odata services on top of existing apis . service being added existing mvc 3 website configured use autofacdependencyresolver. code provided in whitepaper exposing service is: protected void application_start() { var factory = new dataservicehostfactory(); var serviceroute = new serviceroute("odata", factory, typeof(crmodataservice)); serviceroute.defaults = new routevaluedictionary { { "servicetype", "odata" } }; serviceroute.constraints = new routevaluedictionary { { "servicetype", "odata" } }; routetable.routes.add("odata", serviceroute); ... } is there simple way modify resolve service via autofac or need implement own servicehostfactory? i think figured out: protected void application_start() { var factory = new autofacwebservicehostfactory(); var serviceroute = new serviceroute("odata", factor

uitableview - iOS: editingStyleForRowAtIndexPath when adding a new cell -

i'm adding row uitableview section when user switches table editing mode code: - (void) setediting:(bool) editing animated:(bool) animated { [super setediting:editing animated:animated]; if (editing) { [self.tableview insertrowsatindexpaths:[nsarray arraywithobject: [nsindexpath indexpathforrow:0 insection:section_suppliers]] withrowanimation:uitableviewrowanimationfade]; } } the object being create "add new supplier ..." row. works, when table wants editing style can add plus or minus icon, have problem. - (uitableviewcelleditingstyle) tableview:(uitableview *) tableview editingstyleforrowatindexpath:(nsindexpath *) indexpath { return ([self.tableview isediting] && indexpath.row == 0) ? uitableviewcelleditingstyleinsert : uitableviewcelleditingstyledelete; } the sequence seems go this: the table switches editing. there 1 supplier row @ time queries editing style row == 0. the insert of new row done triggers query editing

php - how to use mysql implode while loop -

$mysqli->query("select b.t_follow_up, b.t_consultation, b.t_acid_peel, b.t_wrinkle_name, b.t_dermal_name, b.status, b.date_book, b.min_spent, b.b_ref, m.f_name, m.l_name, d.doctor_name, min(t.times) bookslot b left join timeslot t on b.id_timeslot = t.id_timeslot left join member m on b.id_member = m.id_member left join doctor d on b.id_doctor = d.id_doctor while($r = $q->fetch_array(mysqli_assoc)) : echo '. $r['t_consultation'] . ' ' . $r['t_follow_up'] . ' ' . $r['t_acid_peel'] . ' ' . $r['t_dermal_name'] . ' ' . $r['t_wrinkle_name'] '; endwhile; while loop result: i can put comma in while loop manually! problem when there no table treatment empty, comma still there consultation follow_up acid peel dermal i heard can use implode. how implement it? expected result: if echoing treatments: consultation, acid peel, wrinkle name, dermal name you can put values in array ,

sqlite - Fastest full text search today? -

spoiler : lucene vs sphinx vs whatever, saw other threads 2 years old, decided start again.. here requirement : data size : max 10 gb. rows : billions indexing should fast searching should under 0 ms [ ok, joke... laugh... keep low possible ] in today's world, which/what/how go ? edit : did timing on lucene, , indexing 1.8gb data, took 5 minutes. searching pretty fast, unless a* . a* takes 400 ~ 500 ms. biggest worry indexing, taking loooonnnnggg time, , lot of resources!! i have no experience other lucene - it's pretty default indexing solution don't think can go wrong. 10gb not lot of data. you'll able re-index pretty rapidly - or keep on ssds speed. , of course keep whole index in ram (which lucene supports) super-fast lookups.

Menu bar on the top of iPad:) -

i have created login page , applied navigation method switch next view on sign in button. want menu bar icons button on every next view. tryed tool bar on each each views 2 buttons didnt successed switch last view first view. can switch next view & previous view only. there standard code menu bar have saw menubar @ top in video sap businessone application. plz help.. -(ibaction)yourclass:(id)sender{ //[firstviewobj release]; yourclass *signupobj = [[yourclass alloc] initwithnibname:@"yourclass" bundle:nil]; [self.navigationcontroller pushviewcontroller:signupobj animated:yes]; [signupobj release]; } use above button click event , take toolbar common buttons on every class ui. when click toolbar button above u desire page(like home, settings pgs common screes)

iphone - is this a bad Core Data pattern for sharing functionality? -

i have app , there basic functionality needs shared across several controllers, 1 being adding , removing call bookmarkedobjects data store. created following funciton , seems working , apply pattern other function in code adding objects order, seeing if order exist ect.. here doing: +(void) removebookmark: (nsstring *) aitemid withcustomernumber: (nsstring *) acustomernumber withmanufacturerid: (nsstring *) amanufacturerid withmanagedobjectcontext: (nsmanagedobjectcontext *) acontext { nsfetchrequest *request = [[nsfetchrequest alloc] init]; [request setentity:[nsentitydescription entityforname:@"bookmarkeditem" inmanagedobjectcontext:acontext]]; [request setpredicate:[nspredicate predicatewithformat:@"customernumber==%@ , manufacturerid==%@ , itemid==%@", acustomernumber, amanufacturerid, aitemid]]; [request setfetchlimit:1]; nserror *error = nil; nsarray *results = [acontext executefetchrequest:request error:&error]; [

deployment - Django MEDIA_URL again ... Unhandle -

my settings.py file media_root = '/home/path/to/htdocs/mysite/public/media/' media_url = '/site_media/' admin_media_prefix = '/media/' in site_media have images , css ... href="{{ media_url }}/style.css" ... (with {{ media_url }}style.css same) after render href="/site_media/style.css" but @ http://example.com/site_media/style.css there unhandled exception (i thing no url mapped in urls.py) everything work fine in debug mode because have in urls.py if settings.debug: urlpatterns += patterns('', (r'^media/(.*)$', 'django.views.static.serve', {'document_root': os.path.join(os.path.dirname(__file__), 'media')}), (r'^site_media/(.*)$', 'django.views.static.serve', {'document_root': os.path.join(os.path.dirname(__file__), 'site_media')}), ) but need when debug = false what happening in debug mode django serves style.css file. tell line

java - How do you disable session creation for all JSPs with Tiles? -

is there way make jsps not create sessions when using jasper (tomcat)? apparently jasper create session unless specify not to: <%@ page contenttype="text/html;charset=utf-8" language="java" session="false" %> is there way entire webapp (session="false")? its seems can't change: org.apache.jasper.runtime.jspfactoryimpl.getpagecontext which create session unless jsp says session=false. this container-specific; see this question .

How to remove Empty Properties from a multi depth JavaScript Object? -

i've got js object: var test = {"code_operateur":[""],"cp_cult":["",""],"annee":["2011"],"ca_cult":[""]} when use function: for (i in test) { if ( test[i] == "" || test[i] === null ) { delete test[i]; } } i get: {"cp_cult":["",""],"annee":["2011"]} okay not bad, i'd remove empty "cp_cult" property (which array , not string other). note: don't want manually delete key! try: function isempty(thingy) { for(var k in thingy){ if(thingy[k]) { return false; } } return true; } for(i in test) { if ( test[i] == "" || test[i] === null || (typeof test[i] == "object" && isempty(test[i])) ) { delete test[i]; } } however, depending on complexity of object, you'd need more advanced algorithms. example, if array can contain array of

php - LDAP Auth on WAMP -

i'm trying write ldap authentication code on wamp server. i'm using this: <?php error_reporting(e_all); ini_set("display_errors", 1); $ldapconfig['host'] = 'my.server.province.country'; $ldapconfig['port'] = 389; $ldapconfig['basedn'] = 'dc=x,dc=y,dc=z,dc=x1'; $ldapconfig['authrealm'] = 'my realm'; ldap_connect($ldapconfig['host'], $ldapconfig['port']) or die ('could not connect'); echo 'connected'; ?> i'm getting error: fatal error: call undefined function ldap_connect() in c:\program files\apache software foundation\apache2.2\htdocs\oplweb\index.php on line 10 from basic googling, looks need turn on mod_ldap. seems simple. i've done following: went c:\program files\apache software foundation\apache2.2\modules , made sure mod_ldap.so exists. i've gone c:\program files\apache software foundation\apache2.2\conf\httpd.conf , made sur

c++ - How to convert an enum type variable to a string? -

how make printf show values of variables of enum type? instance: typedef enum {linux, apple, windows} os_type; os_type myos = linux; and need printenum(os_type, "my os %s", myos); which must show string "linux", not integer. i suppose, first have create value-indexed array of strings. don't know if beautiful way it. possible @ all? there no beautiful way of doing this. set array of strings indexed enum. if lot of output, can define operator<< takes enum parameter , lookup you.

Add an option to Flash contex window using Javascript -

i tring create chrome extension adds contex menu entry when ever right mouse button clicked. i need new entry displayed when right click on flash object (such youtube clip) cannot find way it... can done? directions should check? can't (not javascript, , probably not flash, either). menu when right-click in flash object generated flash interpreter, not browser - , iirc can't overridden.

Wordpress - Display Taxonomy Terms without Links - (get_terms, the_terms, wp_tag_cloud) -

is there way display taxonomy terms without them being link? i want display terms underneath taxonomy of "headings," without them being links. i've tried multiple solutions such get_terms, get_the_terms, the_terms, wp_tag_cloud unable find solution. thanks. the solution of bizarre returned terms, if need display terms per post item can use this: $terms = wp_get_post_terms( $post->id, 'taxonomy-term', array("fields" => "names") ); echo implode(', ',$terms); make sure right "taxonomy-term" correct!

Master list of high PPI mobile screens and how to detect/handle it via CSS? -

the iphone 4's retina display double density of of iphone 3, apple handled nicely making assumption , doubling pixels when rendering (so web page looks same physical size on each device). can use webkit media queries load additional css device (-webkit-min-device-pixel-ratio:2). the question: there resource a) lists other mobile devices using high ppi screens b) device default in terms of rendering web sites , c) if supports webkit check and/or it's own custom detection method? if not, perhaps post become resource (cw) posting info on specific devices answers. have start dealing blackberry , nokia devices using high res screens (and android coming along). data appreciated! update: after testing, i'm finding there aren't other mobile devices identify double-density iphone 4 does. there screens higher ppis (often on smaller devices) device doesn't in way declare high ppi. perhaps better way explain devices have 'really small pixels'. as such, the

java - send sms from web application -

i trying send sms java application using smppsim sms gateway , smppapi this code send sms public class synctransmitter extends smppapiexample { private log logger = logfactory.getlog(synctransmitter.class); public synctransmitter() { } public void execute() { try { logger.info("binding smsc"); myconnection = new connection("localhost", 2775); myconnection.autoacklink(true); myconnection.autoackmessages(true); bindresp resp = myconnection.bind( connection.transmitter, "smppclient1", "password", null); /** bindresp resp = myconnection.bind( connection.transmitter, "smppclient1", "password", systemtype, sourceton, sourcenpi, sourceaddress); */ if (resp.getcommandstatu

iphone - Passing variables bewteen view controllers -

i've app keep 4 variables in first view controller. second view controller, pushed through navigation controller, should send these variables web form. so need these 4 vars in second view controller. at moment, in 1st view controller set vars in app delegate with: mydelegate *delegate = (mydelegate *) [[uiapplication sharedapplication] delegate]; delegate.var1 = var1; delegate.var2 = var2; [...] and when need them in second view controller, i'll them through delegate. probably, wrong way. how can transfer vars between controllers? what's best way? declare properties these variables in second view controller , then, when create second view controller , before push navigation stack, assign values properties.

How I can force scheme to return #f explicitly instead of just void? -

(define every-aux (lambda(status predicate lst) (cond((null? lst) status) ((cond((equal? (predicate (car lst)) #t) (set! status #t) (every-aux status predicate (cdr lst))) (else (set! status #f) status)))))) above procedure returns void if predicate not match every element in lst? it not have problem returning #t though if predicate matches every element of lst. changing last line (else (set! status #f) status)))))) to (else (set! status "#f") status)))))) returns "#f" procedure correct. how can force scheme return #f explicitly instead of void? your code messy: you have cond inside another, cond intended multiple tests/results. there no reason have status modified -- scheme uses call-by-value, not doing whatever think does. specifically, there no reason use (else (set! status #f) status) -- return #f directly. the actual reason confusion weird cond nesting -- sec

Android MediaRecorder is throwing IllegalStateException -

i trying develop simple android video recorder. have created custom surfaceview mediarecoder handle recording. builds fine , runs fine on android device. when call startrecording() , giving me illegalstateexception . here code: package my.android.video; import android.media.mediarecorder; import android.view.surfaceview; import android.view.surfaceholder; import android.util.log; import java.lang.illegalargumentexception; import java.lang.illegalstateexception; import java.io.ioexception; import android.content.context; public class recorderview extends surfaceview implements surfaceholder.callback { private mediarecorder mediarecorder; public recorderview(context context) { super(context); surfaceholder holder = getholder(); holder.addcallback(this); holder.settype(surfaceholder.surface_type_push_buffers); holder.setfixedsize(400, 300); } @override public void surfacecreated(surfaceholder holder) { if (mediarecorder == null) { try {

c++ - How to use transactions in Informix CSDK and OIC++ -

i'd need advice how handle transactions informix csdk , oic++. conn open connection object. select works find. database here setup logging — found out while update stmt on own nothing. here's tried: conn.settransaction( itconnection::begin ); qtext = "update transit_kunde_s set erledigt='y' transitkunde='"+ts+"'"; cout << qtext << endl; code = query_up.execforstatus(qtext.c_str()); cout << "code " << code << endl; conn.settransaction( itconnection::commit ); okay once again answer myself... from informix c++ docnotes operations can performed on large objects within fetched row though connection still checked out (locked). connection checked out after itquery::execforiteration() method returns multiple rows in result set. remains checked out until either last row in result set has been fetched itquery::nextrow() or query processing

javascript - Why does this variable reference not work? -

this.prefixmonday[0] exists @ current scope this.prefixmonday array of 3 checkboxes within initcomponent method of extend of panel this.weekdays = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; for(var = 0; i<7; i++){ this['prefix' +this.weekdays[i] +'[0]'].on('check',this.somefunction, this); } firebug says can't find: this['prefix' +this.weekdays[i] +'[0]'] i'm pretty sure have acces this['prefix' +this.weekdays[i]][0] otherwise javascript search key string 'prefixmonday[0]' , don't think want. make more readable might want use helper variable store name: for(var = 0; i<7; i++){ var key = 'prefix' +this.weekdays[i]; this[key][0].on('check',this.somefunction, this); }

.net - WindowsFormsHost Mouse event problem -

we have wpf application uses winforms webbrowser control inside windowsformshost. getting complaints users because when click on control in displayed webpage mouseclick isn't registered if main window isn't activated. have click once activate window, click again use page. people doing data entry, annoying. i believe problem windowsformshost itself, because can reproduce in simple test application consisting of wpf window, windowsformshost , winforms button control. clicking button when main window not activated doesn't work. does know of way make work?

GridView.LayoutParams does not exist, Android code breaks -

i'm following along helloworld tutorials android when gridview exercise (http://developer.android.com/resources/tutorials/views/hello-gridview.html) i found if comment out line: imageview.setlayoutparams(new gridview.layoutparams(85, 85)); then works. did research , found gridview.layoutparams not exist. doing wrong? tutorial broken? i did research , found gridview.layoutparams not exist. where did research? gridview.layoutparams exist. layoutparams class inherited viewgroup class, super class of gridview . edit: just took , seems that, said, layoutparams not accessible gridview . use abslistview.layoutparams instead.

Default assignment operator= in c++ is a shallow copy? -

just simple quick question couldn't find solid answer anywhere else. default operator= shallow copy of class' members on right hand side? class foo { public: int a, b, c; }; foo f1, f2; ... f1 = f2; would identical to: f1.a = f2.a; f1.b = f2.b; f1.c = f2.c; this seems true when test need sure i'm not missing specific case. i'd say, default operator= copy . copies each member. the distinction between shallow copy , deep copy doesn't arise unless members being copied kind of indirection such pointer. far default operator= concerned, it's member being copied "copy" means, deep or shallow. specifically, though, copying raw pointer copies pointer value, doesn't referand. objects containing pointer members shallow-copied default operator= . there various efforts @ writing smart pointers perform clone operations on copying, if use everywhere in place of raw pointers default operator= perform deep copy. if object has sta

Apache: How to apply 'Order Deny,Allow Deny from all' for directory host/content/ with using only one .htaccess in host/.htaccess, without httpd.conf? -

how apply order deny,allow deny for directory localhost/content/ 1 .htaccess in localhost/.htaccess , without httpd.conf ? <directory> not allowed in .htaccess can't put files outside documentroot of website? only solution found redirecting when tries reach directory. redirect permanent /content/ http://localhost /emil

c# - SmtpClient: How do I get failed delivery notifications? -

i want users send mail application able notified of failures pull reporting mail sent account. but question focused on getting failed delivery notifications, how setup listens them modify sent email log in database reflect this? since marc_s used comment, i'll go ahead , put answer here. an smtp client responsible sending messages, , gets little feedback success status of message. it'll exception if smtp server down or something, smtp server handles actual sending attempts.

Implementing a secure two-factor authentication for a login page with Django form wizard -

so want achieve similar google two-factor authentication implementation. login form consists of 2-step form wizard: step 1 (verifying username , password) step 2 (authenticate security token) the usage scenarios be: user has security token associated account: logs user in if user passes step 1 , step 2 user doesn't have security token: logs user in right after passes step 1 only i'm subclassing django's form wizard used login view. in step 2, default django formwizard include field values submitted forms hidden fields. know, password entered in step 1, don't want include in step 2 security reasons. my first thought use session indicate if user has passed step 1, don't need include field values step 1.. may overlooking here. more secure solutions this? also don't quite understand use of security-hash in formwizard. can explain? thanks lot. i'm not getting point of security token, seem simpler , faster if forgo extending formwi

security - Ensuring an iOS 4 app only runs if device meets certain password criteria -

our (internally distributed) ios app relies on ios 4.2's encryption secure sensitive data. however, works satisfactory if user using system-wide password. i understand can enforced installing configuration profile on ios devices configuring rules password. since installation of profile optional our users, how can make sure our app works if profile installed, or alternatively, if password regulations met? (we not concerned jailbreaks , related cracks our software, ability test config profile or other criteria inside our own code sufficient.) what can do, create (self-signed) ssl certificate , add signing authority configuration profile. then, within app can attempt verify certificate. verification work if trust signing authority, happens if have configuration profile has been installed. you can read more process here if wish: http://blog.slaunchaman.com/2011/12/01/enforcing-ios-security-settings-in-third-party-applications/ note: may not acceptable submissi

Can I add my own snippets to MonoDevelop? -

is there means within monodevelop create own snippets, i.e. reusable bits of code? know in toolbox can other people's, can't seem find way add own stuff that. granted, i'm new enough monodevelop. in monodevelop, go tools --> preferences ---> text editor --> code templates --> press button add (in windows (monodevelop 5.9.6) tools --> options)

tsql - Can't add permissions to Sql Server 2005 table -

these commands i'm executing: use [messenger]; go grant delete on [dbo].[messages] [mm_tableaccess]; go grant insert on [dbo].[messages] [mm_tableaccess]; go grant select on [dbo].[messages] [mm_tableaccess]; go grant update on [dbo].[messages] [mm_tableaccess]; go mm_tableaccess role. toad tells me these commands executed successfully. after executing this, when @ permissions on table, shows none; viewing create script "permissions" turned on shows no grant commands. i've tried refreshing table; closing toad , reopening again; rebooting. nothing works. table in database (only 6 tables) can't add these permissions to. here's table create script: use [messenger]; go set ansi_nulls on; go set quoted_identifier on; go create table [dbo].[messages] ( [messageid] bigint identity(1, 1) not null, [parentid] bigint not null, [categoryid] bigint not null, [postedbyid] bigint not null, [dateposted] datetime not null, [messagetitle] nvarchar(50) null, [me

How generics influenced the design of C# and .NET? -

this might broad question not clear , curious. often times problems hear reasoning because generics not available in .net 1.0. makes me think either of these 2 things: generics not thought of before, developers came after .net 1.0 drastically affect design of c# , .net couldn't because of decisions made (backwards compatibility). generics planned since beginning, problem arise not releasing .net 1.0 not being able use till 2.0. other this, no redundant features introduced or wrong, irreversible decisions committed. i assume #1, #2 actual case? generics have been around long time , can loosely compared c++ templates, although concept (and implementation in other languages) predates that. .net 1.0 first cut of platform plan ship works reasonably. generics have have been on "planned future" if decent architect on team, added later. in fact, paper on implementing generics .net came out year before .net framework 1.0 rtm eventuated. timeline: ( http

shrink (truncate) file from beginning on linux -

is possible in linux (and/or on other unix) 'shrink' file beginning? i'd use persistent queue (no existing implementation suits needs). end of file guess it's possible truncate(). yes, can use cut or tail remove portions of file. cut -b 17- input_file tail -c +17 input_file this output contents of input_file starting @ 17th byte, removing first 16 bytes of file. note cut example add newline output.

ExtJs: Programly select rows of a GridPanel in an inactive tab not working? -

basicly, have window contains 2 tabs, second tab gridpanel , inactive. i want programly select 2 rows of gridpanel(via checkboxselectionmodel) clicking "show window" button , found not working. there javascript error thrown , no rows selected. after manually clicked second tab make grid visible, works well. what's possible mistake made? i'll paste code if it's not common mistake extjs beginner. this because tabpanel not render components not visible (i.e., components in second tab in case). if add following config option ext.tabpanel should fix problem: deferredrender: false

visual c++ - Problem with Boost Asio asynchronous connection using C++ in Windows -

using ms visual studio 2008 c++ windows 32 (xp brand), try construct pop3 client managed modeless dialog box. te first step create persistent object -say pop3 - boost.asio stuff asynchronous connections, in wm_initdialog message of dialog-box-procedure. like: case wm_initdialog: return (inipop3dlg (hdlg, lparam)); here assume inipop3dlg() create pop3 heap object -say pointed out pop3p -. connect remote server, , session initiated client’s id , password (user , pass commands). here assume server in transaction state. then, in response user input, dialog-box-procedure, call appropriate function. say: case ids_total: // how many emails in server total (pop3p); return false; case ids_detail: // date, sender , subject each email in server detail (pop3p); return false; note total() uses pop3’s stat command how many emails in server, while detail() uses 2 commands consecutively; first stat total , loop command retrieve content of each message. as

visual studio 2010 - Unable to create Event Handler WPF -

Image
i unable create event handler when double click on button or messagebox appears how ever when add event handler manually works.any idea might have screwed thanks the class in question "mainwindow" class within mainwindow.xaml.cs file. make sure it's first class in code behind file. i suspect added type file, , defined @ top. "break" designer, , give error message.

c# - Restore database timeout? -

i'm trying restore database using following code string restore = @"restore database [" + dbname+ "] disk = n'" + filepath + "' replace, file = 1, nounload, stats = 10"; sqlcommand restorecmd = new sqlcommand(restore, con); restorecmd.executenonquery(); it returns me timeout expired error, have set connect timeout=300 in connectionstring but running t-sql script restore database [dbname] disk = n'filepath' replace, file = 1, nounload, stats = 10 works fine what should fix this? set commandtimeout property of restorecmd so: restorecmd.commandtimeout = 300;

web services - API for document format conversion -

i looking restful web service can send document (doc, docx, xls, xlsx, ppt, pptx, , tiff @ minimum) conversion pdf , swf. the reason need swf in addition pfd can display document in browser using flash-based document viewer such flexpaper . i want transloadit.com documents. one option use scribd api, download pdf, , use swftools convert pdf swf. interested in alternatives. doxument.com might looking for. offer kind of rest api. i'm not sure formats though.

Allow access to Amazon AWS console using IAM -

is possible setup separate accounts using amazon's iam service allow 2 different users access amazon web dashboard/console? i'd separate account can access these pages i'd prefer not have give away keys kingdom so. if can iam policies specified allow restrict user can console? i've written short howto on adding ec2 user, similar policies. url: http://www.corbettbaker.com/blog-posts/creating-aws-user-ec2-only-permissions basically, replace ec2user whatever want user name be. -cb

iphone - xcode showing warnings as errors -

Image
i turned on setting "treat warnings errors" used while , turned off warnings still build errors. have restarted xcode , pc. try override setting on target level, rather project's.

java - How to validate JSON object? -

i validate incoming json object correctness @ server side. there standard / optimal way that? approach of validation? my advice - deserialize json , see if breaks. example, if you're using c# on server side, can use newfangled datacontractjsonserializer , or old way javascriptserializer arguably simpler. var serializer = new javascriptserializer(); var result = serializer.deserialize<dictionary<string, object>>(jsonstring); edit: , it's come out you're using java, of course c# example not going work you, concept same. stackoverflow has answers here : convert json string object in java me?

sql - Select a group of records based on one record in the group -

i seem stuck on problem. using crystal reports 2008 pull list of records ms-sql database. there 2 tables involved (they contain order data subscribers). first table ordermst , second orderdtl. joined 2 fields, account , subnumber. each account has many subnumbers , each subnumber has many invoicenumbers. each invoice row has column tells me wether or not it's recent invoice. need @ record determine whether customer active, cancelled, or expired. then, depending on status need select invoices subnumber. i'm stuck trying figure out way that. here's example: ordermst: account subnumber pub 72781651 0025 navl 72781651 0012 ryir 72781651 0001 rhcs 80156287 0015 vgfa 80156287 0012 navl orderdtl: account subnumber invoicenumber pubstatus renewalthere 72781651 0025 15894578 0 72781651 0025 15754897 r 1 72781651 0025 15753412 r 1 72781651 0012 15753357

asp.net mvc 2 - MVC2 controller method that can accept unknown number of variables? -

i need work below posted data, or variant thereof. basically, need post variable number of key-value pairs represent question id , answer string. how write asp.net mvc2 controller method signature accept unknown number of key-value pairs? attachmentid=8809&question_712=&question_713=&question_714=&question_715=&question_716=&question_717=&question_719=&question_720=&question_721=&question_722=&question_723=&question_724=&question_725=&question_726=&question_727=&question_731=&question_738=&question_739=&question_741=&question_742=&question_743=&question_744=&question_745=&question_746=&question_747=&question_748= please note in example, there 26 question keys empty values. there may more or less keys , may or may not have value. can reformulate way data sent client, if best solution rethink way sent, i'm open that. this data formcollection collects. it's

passing custom object to android service in different process -

i have service set start in separate process: <service android:name=".services.uploadservice" android:process=":uploadserviceprocess" /> and can bind using bindservice(). issue occurs when try send message calling messenger.send(): service.send(message.obtain(null, uploadservice.message_upload_request, uploadrequest)); where uploadrequest custom object implements parcelable public class uploadrequest implements parcelable { public file file; public boolean deleteonupload; public uploadrequest(file file, boolean deleteonupload) { this.file = file; this.deleteonupload = deleteonupload; } private uploadrequest(parcel in) { this.file = new file(in.readstring()); } public int describecontents() { return 0; } public void writetoparcel(parcel dest, int flags) { dest.writestring(this.file.getpath()); } public static final parcelable.creator<uploadrequest> creator = new parcelable.creator<uploadrequest&g

java - How to use file.seperator in ibatis resource attribute of sql-map tag -

i using ibatis or mapping of application. me , team working on 2 different operating systems, systems ubuntu , windows xp. have sqlmapconfig.xml file in refer ibatis query xml file, in write queries. but when create sqlmapconfig want give path of query.xml in resource attribute of sql-map tag using file separator can adjust separator operating system, have written code below in sqlmapconfig.xml <sqlmap resource="file:com${file.separator}platysgroup${file.separator}lmexserver${file.separator}mobile${file.separator}dao${file.separator}ibatis{file.separator}lmexusermobileinfo.xml" /> but when run application exception: com.ibatis.common.xml.nodeletexception: error parsing xml. cause: java.lang.runtimeexception: error parsing xpath '/sqlmapconfig/sqlmap'. cause: java.io.ioexception: not find resource file:comfile.separatorplatysgroupfile.separatorlmexserverfile.separatormobilefile.separatordaofile.separatoribatis{file.separator}lmexusermobi

WPF or Silverlight which one has the upper hand? -

i confused reading articles silverlight. whether should concentrate on wpf or silverlight or both?. it's asking web or desktop : 1 has upper hand? silverlight (web) , wpf (desktop) both similar. both have separate workplaces. you cannot have windows calculator , task manager or ms word (please don't mention google docs) applications on web on desktop. , same thing applies web applications. so, depends on platform want work on.

osx - original image size is not retained when it is exported as PDF using CGImageDestinationRef -

i developing desktop application supports exporting png image different image formats. when export png image (refer first link) pdf format, appears shown in link2. http://www.flickr.com/photos/36018837@n05/5472635835/ (original image) http://www.flickr.com/photos/36018837@n05/5473232908/ (exported image) the image has become larger. why happen? doing wrong in code? how solve this? following code snippet use export: //filepath: destination path //exporttype: kuttypepdf cgimagedestinationref imagedestination = cgimagedestinationcreatewithurl((cfurlref)filepath,(cfstringref )exporttype,1,null); bool success = no; if( imagedestination != null ) { cgimageref imageref = [ inimage createcgimage ]; if( imageref != null ) { cgimagedestinationaddimage(imagedestination, imageref, null); success = cgimagedestinationfinalize(imagedestination); cgimagerelease(imageref ); } cfrelease( imagedestination ); } thanks in advance. regards, deepa

javascript - The anatomy of uploading -

i wondering general consensus uploading moderately large files. have web app, , every time user uploads file (typically larger 5mb), web server tends hang until file upload finished. the above seems normal, because single upload can take single http request handler. web devs take consideration , either: a) pay more http handlers b) use other method overcome using ajax, or other approach i've heard quite normal web apps have few http request handlers take care of this, cost quite bit more. on other, if cost issue, have suggested trying upload directly web server or storage service (i.e. amazon s3) directly via flash + ajax. latter method takes bit of scripting , bit messy. my second concern: by using ajax upload files onto server. still take whole http request handler? i.e. server hang until upload finished? even flash, still need specify url upload to. url 1 of actions on controller. mean processing still takes place on server side. right far? i thinking. if we

ruby on rails - File rename while uploading -

i uploading files amazon s3 rails app , working fine, however, want know how can append string file uploaded. example if user has chosen file abc.jpg, need append header_abc.jpg. how can achieve this? path = picture.attachment.path() new_file_name = "header_" + picture.attachment_file_name fileutils.move(path, file.join(file.dirname(path), new_file_name)) picture.attachment_file_name = new_file_name picture.save

html - How to have text wrap around an image? -

what's best approach achieve following effect? [image removed poster] i need text wrap around image, should in bottom right corner. thanks. actually is possible if you're not opposed non-semantic markup. take @ working example: http://jsfiddle.net/chprpipr/zhz2v/ if set background image of container contain portrait image, can pretty close you're looking for.

c# 4.0 - How to run C# 4.0 app on Linux OS using mono? -

i want run c# application os linux using mono. new cross platform migration? please tell procedure doing that? thanks & regards. it depends on type of application is. console or winforms app, may simple. mono doesn't support wpf . well, first think you'll need install mono of course. want run moma determine application's compatibility. there's whole separate page porting winforms apps . if well, should able run application using: mono myapplication.exe after copying binaries over. if application web service or web application, you'll want think various hosting options. i suspect you'll want read lot of pages on mono start page .

Calling a WCF Service without a Service reference -

i have project has service reference wcf service. want invoke service in project b without service reference. understand, service reference way generate proxy , config , not used @ run-time. copied proxy class , node project project b. can create instance of proxy class in project b , expect directly use config. items , connect service without else? (i cannot try right now) short answer yes. as long have interface, way connect service, can create channel , talk service without having reference. the reference makes easier develop against.

windows - Thread ID vs. Thread Handle -

an embarrassing question: difference between thread id , thread handle? why both needed? there difference between windows , linux? linux's pthread library not, far know, have concept of thread handle. pthread_create , other pthreads functions, return thread id. under windows, thread handle different thread id, in same way file handle different file name. the thread handle token allows thread (typically wait or kill it). win32 has these tokens lots of objects, , calls them handle in general. the token pointer @ running (or stopped) thread , has set of abilities associated it, example, can have handle permits wait for, not kill, thread. in same way, can have file handle read-only. this level of indirection may or may not useful, it's way win32 it, , it's broadly consistent how handles other types of objects.

how to test (unit test) the android ui and how to test(functional test) the same android ui using the junit framework in eclipse -

i had tested ui of android applications .the output success one. test automatically assign , calculate things calculator activity.but ,iam confusing ,what unit test , functional test .if knows this.pls point me u know unit testing : software testing process done smallest testable parts in screen functional testing : see if fields(including non mandatory fields) functioning correctly

asp.net - Encrypt querystring using HttpHandler -

how encrypt querystring using httphandler? here's article might help http://madskristensen.net/post/httpmodule-for-query-string-encryption.aspx

wordpress - Extract Image Sources from text in PHP - preg_match_all required -

i have little issue preg_match_all not running properly. what want extract src parameter of all images in post_content wordpress string - not complete html document/dom (thus cannot use document parser function) i using below code unfortunately untidy , works 1 image src, want image sources string preg_match_all( '/src="([^"]*)"/', $search->post_content, $matches); if ( isset( $matches ) ) { foreach ($matches $match) { if(strpos($match[0], "src")!==false) { $res = explode("\"", $match[0]); echo $res[1]; } } } can please here... using regular expressions parse html document can error prone. in case not img elements have src attribute (in fact, doesn’t need html attribute @ all). besides that, might possible attribute value not enclosed in double quote. better use html dom parser php’s domdocument , methods: $doc = new domdocument(); $doc->loadhtml($search->post_content); foreach ($doc->gete

java - display image with jsp -

i want display image @ browser of given code images.jsp <%@ page contenttype="text/html"%> <%@ pageimport="javax.xml.parsers.documentbuilderfactory,javax.xml.parsers.documentbuilder,org.w3c.dom.*" %> <html> <body><center><table border="2"> <%documentbuilderfactory dbf = documentbuilderfactory.newinstance(); documentbuilder db = dbf.newdocumentbuilder(); document doc = db.parse("\\file1.xml"); nodelist pic1= doc.getelementsbytagname("pic1"); nodelist pic2= doc.getelementsbytagname("pic2"); %> <tr><td> <img border="2" src=<%= pic1.item(0).getfirstchild().getnodevalue() %> width="137" height="140"></td> <td> <img border="2" src=<%= pic2.item(0).getfirstchild().getnodevalue() %> width="137" height="140"> </td> </tr> </table> </center> </b

How to create an optionsMenu in an Android's TabActivity -

i try create options menu in tabactivity. but instead of see every activity within tabbar own options menu. is possible change behaviour? , if yes, how? thank you ok. think know solution. if there oncreateoptionsmenu in activity within tabbar, should modified bit: @override public boolean oncreateoptionsmenu(menu menu) { // activity withing tabactivity if (getparent() != null) { return getparent().oncreateoptionsmenu(menu); } ... }

android - CursorTreeAdapter - Return part of Groupcursor for Childview Data -

i'm using cursortreeadapter map curser expandablelistview in android. everything works fine except way data handled inside listview. data inside cursor give constructor of cursortreeadater - daa childview. problem android expects data childview received getchildrencursor function: @override protected cursor getchildrencursor(cursor groupcursor) { db.open(); return db.getepisode(groupcursor.getstring(0)); } here see problem. have return cursor i'm not able "cut out" 1 entry in cursor responsible specific childview. instead came querying database every single childview there is. not dumb since data there (inside groupcursor) ist pretty slow. my question if there kind of functionality of cloning specific entries of cursors or returning 1 entry instead of querying database. maybe i'm off using cursortreeadapter , using more general adapterclass beneficial. thank all, johannes i figured our myself. the answer switch cursortreeadapter

c# - How do I connect XtraReport to windows form on Visual Studio 2010 -

how connect xtrareport windows form on visual studio 2010(this must use xtragrid report viewing) create form add printbarmanager create new xtrareport and try use code in form public partial class yourform : xtraform { private yourxtrareport report; public yourform(printdocument document ) { initializecomponent(); report = new printingdocumentreport(document); } private void printingformload(object sender, eventargs e) { printcontrol1.printingsystem = report.printingsystem; report.createdocument(); } }

latex - NullPointerException with Texlipse and Miktex 2.9 -

when using texlipse miktex 2.9 on windows machine, system throws nullpointerexcpetion each time document compiled. the problem disappeared after have updated miktex 2.9 distribution using update manager. hope helps others have same problem. regards, pwndrian to me happens too. this workaround did, think not quite optimal solution. saw there bug opened http://sourceforge.net/tracker/?func=detail&aid=3306779&group_id=133306&atid=726818 . there class net.sourceforge.texlipse.builder.texlipsebuilder , made following changes overcome problem(please note differences in both functions). problem in texlipseplugin in function getcurrentproject acteditor null since there no active editor when importing projects or when pressing on clean while no editor open. @override protected iproject[] build(int kind, map args, iprogressmonitor monitor) throws coreexception { builderregistry.clearconsole(); iworkbenchpage page = texlipseplugin.getcurren

c - Are repeated recv() calls expensive? -

i have question situation face quite often. time time have implement various tcp-based protocols. of them define variable-length data packets begin common header ([packet id, length, payload] or similar). obviously, there can 2 approaches reading these packets: read header (since header length fixed), extract payload length, read payload read available data , store in buffer; parse buffer afterwards obviously, first approach simple, requires 2 calls read() (or more). second 1 more complicated, requires less calls. the question is: first approach affect performance badly enough worry it? the best way answer measure. strace program decent purpose of measuring system call times. using adds lot of overhead in itself, if merely compare cost of 1 recv purpose versus cost of two, should reasonably meaningful. use -tt option times. or can use -c option overview of time spent separated syscall spent on. a better way measure, albeit more of learning curve, oprofile .

Question about practices of Java reference and synchronized keyword? -

i'm confused issue reference , synchronized keyword long time. see code this: class someclass { ... private someobject mobject; ... public void somemethod() { ... final someobject obj = mobject; ... //then use 'obj' variable rather mobject ... } } my question why should use local final variable obj replace member variable? why not use member variable directly? i see example code associated 'synchronized' keyword,like this: public void write(byte[] out) { // create temporary object connectedthread r; // synchronize copy of connectedthread synchronized (this) { if (mstate != state_connected) return; r = mconnectedthread; } // perform write unsynchronized r.write(out); } why these code can achieve synchronized goal? thanks! from can understand of question , first example, code trying avoid threading problems wanting take local copy of memb

virtualization - Do virtualised machines require separate software licenses? -

i have windows 7 machine, various reasons need have access windows xp also. i know it's possible me have windows xp virtual machine set up, can have use of both. irritatingly, i've got situation must have visual studio 2008 installed on windows 7 , xp (don't ask!). question is, can share existing software licenses across virtual machine also, or have purchase separate ones? because running win7 on cpu has hardware virtualisation enabled, have option of using windows xp mode , virtualised copy of xp licenced, don't need licence it. if want setup separate virtual machine running xp yes, need separate licence xp itself. if sourced copy of vs through msdn subscription per user, can install multiple times. if bought single copy of vs licence per machine (which includes virtual machines).

css - Parent div to follow height of child - for child without float -

the answer can find problem clear float - have non. hope can answer :-) here code, , trying make parent div of button follow expansion done padding. <div class="button"> <a href="#">add</a> </div> and css .button { background-color: #ccc; } .button { background-color: #96bd1e; color: black; font-size: large; padding: 6px 12px; width: 120px; -moz-border-radius: 5px; -webkit-border-radius: 5px; -opera-border-radius: 5px; -khtml-border-radius: 5px; border-radius: 5px; height: 59px; margin: 10px; border-top-left-radius: 5px 5px; border-top-right-radius: 5px 5px; border-bottom-right-radius: 5px 5px; border-bottom-left-radius: 5px 5px; clear: both; } and here example of play http://jsfiddle.net/znlvz/1/ change css this: .button { background-color: #ccc; } .button { display:inline-block; background-color: #96bd1e; color: black; font-size: large; padding: 6px 12px; -moz-border-radius: 5px; -webkit-border-radius:

gcc - Distutils can't find Python.h -

i have distutils setup script extension section, looks this: from distutils.core import setup, extension my_module = extension('my_module', sources = ['my_file.c', 'my_other_file.c']) setup (name = 'my_module', version = '1.0', description = 'my module', ext_modules = [my_module]) running setup.py build works fine on mac. when move debian machine, fails: error: python/python.h: no such file or directory i have python2.6 , python2.6-dev installed, , file present @ /usr/include/python2.6 . the command executes problem file: gcc -pthread -fno-strict-aliasing -dndebug -g -fwrapv -o2 -wall -wstrict-prototypes -fpic -i/usr/include/python2.6 -c my_module.c -o -build/xyz/my_module.o so passing in location of header file. the obvious difference between mac vs linux environment gcc-4.2 vs gcc-4.4 , python 2.7 vs python 2.6 ideas? edit: in c file in question: #include <python/p

running a script exec command from php -

i have application need run php script exec() function of php. "php /var/www/server/data/scripts/threadhandler.php 145596 > /var/www/server/data/logs/threads/thread.145596.log 2>&1 &" also tried "php /var/www/server/data/scripts/threadhandler.php 145596 > /var/www/server/data/logs/threads/thread.145596.log 2>&1 " i running above command exec() function of php, not getting run, can't track error. please suggest change. try passthru('php -f /var/www/server/data/scripts/threadhandler.php 145596 > /var/www/server/data/logs/threads/thread.145596.log 2>&1'); also, try run linux command line

c# - Getting Overlapping Start and End Date -

given daterange need return list of start , enddates overlaps given period. what best way it? time in advance. static void main(string[] args) { //period 1stmarch 20th april var startdate = new datetime(2011, 03, 1); var enddate = new datetime(2011, 4, 20); list<bookedperiod> bookedperiods=new list<bookedperiod>(); bookedperiods.add(new bookedperiod {startdate = new datetime(2011, 02, 5), enddate = new datetime(2011, 3, 15)}); bookedperiods.add(new bookedperiod { startdate = new datetime(2011, 03, 20), enddate = new datetime(2011, 4, 10) }); bookedperiods.add(new bookedperiod { startdate = new datetime(2011, 04, 01), enddate = new datetime(2011, 4, 15) }); list<overlappedperiod> myoverllappedperiods = getoverllapedperiods(startdate, enddate, bookedperiods); } public static list<overlappedperiod>getoverllapedpe