Posts

Showing posts from February, 2012

linux - My shell script stops after exec -

i'm writing shell script looks this: in $actions_dir/* if [ -x $i ]; exec $i nap fi done now, i'm trying achieve list every file in $actions_dir able execute it. each file under $actions_dir shell script. now, problem here after using exec script stops , doesn't go next file in line. ideas why might be? exec replaces shell process. remove if want call command subprocess instead.

java - string cannot be resolved to a type -

i getting "string cannot resolved type" error in code. public class main { public static void main(string[] args) { // todo auto-generated method stub formletter template; template = new formletter(); template.print(); template.composeformletter(sean, colbert, god); template.print(); } } class formletter { public void print(){ system.out.println(to + candidate + from); } public void composeformletter(string t, string c, string f){ = t; candidate = c; = f; } private string to; private string candidate; private string from; } string capitalized in java. cannot use lowercase string . (that's c#) side question: how following compiling @ all? template.composeformletter(sean, colbert, god);

image processing - Help editing a picture in python -

i have suppose i'm given picture, there shouldnt user inputs or calls media.chose file, given picture return average red value of pixels in picture (as int). if average calculation results in non-integer value, truncate result. example, if average values 10, 6 , 4, result 6. the question answered here how can read rgb value of given pixel in python? use pil load image, read pixel pixel , calculation.

c - Byte swapping a struct -

okay hate ask question ... here goes. writing code in c on x86 machine. want send struct on network , and want convert struct network byte order ... understand drama packing , the gcc packing pragmas ... want know how convert struct (or array or such arbitrary memory blob) network byte order. is there standard (unix/linux/posix) function call can use or must roll own. x in principle, can go through struct , call htonl or htons on each uint32_t or uint16_t field, respectively, assigning results or copy of struct. however, not recommend sort of approach. it's fragile , subject struct alignment issues, etc. unless transmitting , receiving data extremely performance-critical, implement proper serialize , deserialize methods structures. can write numeric values out 1 byte @ time in binary format, choosing whether want write least significant or significant part first. really, recommend choosing modern text-based serialization format json or (uhg, hate this) xml. c...

ios - Clear button on UITextView -

how can add clear button (cross inside circle) text view in text field? just make uibutton , put on uitextview , set action clear text view; uitextview.frame = (0,0,320,416); uibutton.frame = (310,0,10,10); [uibutton setimage:@"cross.png" forcontrolstate:uicontrolstatenoraml]; [uibutton addtarget:self action:@selector(clearbuttonselected:) forcontrolevents:uicontroleventtouchupinside]; -(void)clearbuttonselected{ uitextview=@""; } hope want clear text view text when click on cross button above if not understand can send proper program that

java - How to override the XML handler in the Struts 2 REST plugin -

i working on java web app uses struts 2 rest plugin. convention, url ends ".xml" sent through xstreamhandler. fine--it's want in cases. but in small number of cases want stream xml browser. know how set @result(type="stream") annotation , make return inputstream. i've done images in other parts of app. problem returning xml stream rest plugin sees caller requesting xml tries deserialize action class instead of streaming out inputstream. how can tell rest plugin, in these few special cases, not send xml result through xstreamhandler? thanks! oh, cool, figured out answer. secret return instance of class implements com.opensymphony.xwork2.result . assuming 'getfilename()' returns name of xml file want stream: @skipvalidation public com.opensymphony.xwork2.result streamfile() throws filenotfoundexception { return new streamresult(new fileinputstream(new file(getfilename()))); }

ASP.NET MVC application level soft coded settings -

i working on asp.net mvc 2.0 multi-presentation web application use common codebase support different websites. these websites differ in following aspects: each website have own headers, footers, images, css etc (i guess website specific master pages) some of ui elements different based on soft-coded settings @ website level what best approach handle these requirements? should storing these website level soft-coded settings in database or multiple config files? might have provide admin ui manage these soft-coded settings. how access these settings in different layers (mvc, services, repositories etc) of application? i need suggestions experts. regards, alex. develop sort of presentation object model (or possibly aggregate if you're ddd inclined) , persist db. per-user or per-site (if it's multi-tenanted app you're building) , mvc easy build html helpers accept these presentation model objects , render out customized header, css, images etc. poten...

iphone - iOS Jump to different view -

i have navigation based app. root view list of items. root view can tap on table cell item's detail view. or can go form view create new item via 'add' button in nav bar. my question how can jump form view detail view once new object has been created? i don't want push detail view on top of form view, because want root table view user see's after pushing 'back' nav button form detail view. i've tried following. pops root view fine, doesn't push detail view after that.. [context save:&error]; [self.navigationcontroller poptorootviewcontrolleranimated:no]; // display detail view goaldetailviewcontroller *detailviewcontroller = [[goaldetailviewcontroller alloc] initwithnibname:@"goaldetailviewcontroller" bundle:nil]; // pass selected object new view controller. detailviewcontroller.goal = goal; [self.navigationcontroller pushviewcontroller:detailviewcontroller animated:yes]; [detailviewcontroller release]; any , direction...

c++ - Faster to reuse a variable defined in a common scope or redefine it in each inner scope? -

c++ specifically, if matters, imagine answer lies in assembly code somehow. if have multiple blocks in common scope (say, function) each use variable of same type, faster define variable in common scope , reinitialise in each block, or redefine , initialise in each of blocks (or there no fundamental difference)? example: int i; {//block 1 = somefunction(); ... } {//block 2 = someotherfunction(); ... } versus {//block 1 int = somefunction(); ... } {//block 2 int = someotherfunction(); ... } if i pod type (like int shown in example), there no difference @ all. if i of type has nontrivial constructor or assignment operator exciting, there might huge difference , you'd have compare appropriate constructors , assignment operators do. if both blocks entered, you'll need consider destructor well. in general, shouldn't worry it. take cleaner approach , declare variable in restricted scope possible, close first us...

How can we turn on/off GPS programatically without going on setting screen in android? -

how can turn on/off gps programatically without going on setting screen in android? you cannot this. this important privacy reasons. how programmatically enable gps in android cupcake

iphone - Accessing an FTP connection for downloading files -

i new iphone.. want guidelines accessing ftp server through objective c ,where ftp url, username,password should given in program , want access lot of image files ftp , display in imageview. how store image files in locally , retrieve whenever needed.... thanks in advance.. ftp? really? username , password? unless server really configured, ftp security hole waiting happen. but... ok... answer question; there no built in ftp client api in ios. you'll either need roll own (hard, protocol documented) or use client library (maybe easy, maybe not). i'd start here (yes, google search, not meant flippant) , review various libraries see fits needs better. note omni's frameworks show on page. write code. however, best solution use http communicate between app , server. http support built in, http ubiquitous, , easier configure web server secure.

email - php mail function with html not shown correct in exchange -

i got strange problem php mail , exchange. when use simple php html mailscript, see below (can found on internet) see mail kind of plain text (see below) mail in microsoft exchange. when send mail other account outlook see mail html-mail should be. doest got clue? mailscript: <?php // multiple recipients $to = 'aidan@example.com' . ', '; // note comma $to .= 'wez@example.com'; // subject $subject = 'birthday reminders august'; // message $message = ' <html> <head> <title>birthday reminders august</title> </head> <body> <p>here birthdays upcoming in august!</p> <table> <tr> <th>person</th><th>day</th><th>month</th><th>year</th> </tr> <tr> <td>joe</td><td>3rd</td><td>august</td><td>1970</td> </tr> <tr> <td>sall...

c++ - How to forward declare a template class in namespace std? -

#ifndef __test__ #define __test__ namespace std { template<typename t> class list; } template<typename t> void pop(std::list<t> * l) { while(!l->empty()) l->pop(); } #endif and used function in main. errors. of course, know there more template params std::list (allocator think). but, beside point. have know full template declaration of template class able forward declare it? edit: wasn't using pointer before - reference. i'll try out pointer. the problem not can't forward-declare template class. yes, need know of template parameters and defaults able forward-declare correctly: namespace std { template<class t, class allocator = std::allocator<t>> class list; } but make such forward declaration in namespace std explicitly prohibited standard: only thing you're allowed put in std template specialisation , commonly std::less on user-defined type. else can cite relevant text if necessa...

tortoisesvn - SVN - delete a revision, or make an older revision the head -

i'm new svn , i've never had revert previous revision, although can copy of revision repository okay. i'm using tortoisesvn , visual studio svn plugin. i'd restore trunk previous revision. how can restore trunk - e.g. rollback previous revision , make head? thanks what need so-called reverse merge: svn merge -r head:<rev_you_want_to_revert_to> see tortoise svn merge documentation details on how tortoise svn. see the svn book (copied link another stackoverflow question ; it's faq).

android - How to get Bitmap from an Uri? -

how bitmap object uri (if succeed store in /data/data/myfolder/myimage.png or file///data/data/myfolder/myimage.png ) use in application? does have idea on how accomplish this? . . important: see answer @mark ingram below , @pjv @ better solution. . . you try this: public bitmap loadbitmap(string url) { bitmap bm = null; inputstream = null; bufferedinputstream bis = null; try { urlconnection conn = new url(url).openconnection(); conn.connect(); = conn.getinputstream(); bis = new bufferedinputstream(is, 8192); bm = bitmapfactory.decodestream(bis); } catch (exception e) { e.printstacktrace(); } { if (bis != null) { try { bis.close(); } catch (ioexception e) { e.printstacktrace(); } } if (is != null) { try { ...

php - Changing DIV color in CSS depending on database results? -

i want change background color of div depending on true/false values in database i'm running. can done in css or forced use inline css when comes this? one solution came had created several (4-5) classes called classes had same css rules except color , made me think redundant , waste of space. i researched , seems can have php variables in css. without making separate .css/.php file link in header several reasons. possible? maybe can explain better code. here concept i'm trying , want know if i'm able without external stylesheet?: <hml> <head> div.content { background-color: <?php echo $legendcolor; ?>; border-style:solid; border-width:2px; border-color: #000; margin: 10px 0px; } </head> <body> <?php /* after database connection & query*/ while ($row = mysql_fetch_assoc($result2)) { $var1 = $row["db_boolean_var1"]; $var2 = $row["db_boolean_var2"]; $var3 = $row["db_boolean_var3"]; $var4 = $r...

How do I write a Django model with ManyToMany relationsship with self through a Model -

i want have model manytomany relationship itself, don't know how write i'l try write code illustrate want do. class person(models.model): name = models.charfield() occupation = models.charfield() friends = models.manytomanyfield('self', through = personfriends) my model want friends go through class personfriends(models.model) ??? comment = models.charfield() in manytomany field through relationship if other model's name "pet" example i'd name fields in through class person , pet , make them models. foreignkey(person) , pet example what name fields in personfriends model 2 person-fields same model? you can this: class person(models.model): name = models.charfield(max_length = 255) occupation = models.charfield(max_length = 255) friends = models.manytomanyfield('self', through = 'personfriends', symmetrical = false) # ^^^^^^^^^^^ # has false when using `...

distributed - SQL Server 2005 Linked Server Query Does Not Return Expected Error -

i querying linked sql server , not getting error when querying locally. something this: select cast(columnname int) tablename and this: select cast(columnname int) servername.databasename.schema.tablename the first query when run locally returns error 'arithmetic overflow error converting expression data type int.' because values out of range. however, second query running different server, returns 'valid' rows. i expect working designed, have googled , cannot find anywhere explains difference in behaviour when querying locally versus distributed. can point me in right direction? i'd know if there configuration option change this. thanks in advance. look @ set arithabort , set ansi_warnings options. when both off, overflow error suppressed , null returned instead. can set in (at least) 3 different places: connection, database or code. means can unexpected behaviour because set database option , forgot it, or using connection library se...

image processing - C# Magic Wand Tool -

i want write function work magic wand tool dynamic in c# . can ? thanks you need flood fill algorithm. use this: http://www.codeproject.com/kb/gdi-plus/floodfillincsharp.aspx http://www.codeproject.com/kb/gdi-plus/queuelinearfloodfill.aspx http://en.wikipedia.org/wiki/flood_fill

Heroku Git Repository Size -

during late development of application i've been git pushing heroku such repository there large. i @ stage, before site launch, remove old versions repo seems sensible housekeeping. best way go online application uninterrupted? there no need heroku specifically, when push, compiles app slug quick deployment, , 1 step of dropping git repo entirely. but if want this, i'd suggest deleting .git/ directory project , starting new repo git init . heroku acts other git remote can push to, can normal git remote, can heroku git remote. if push new, empty repo it, should solve problem sure.

Android SOAP problem -

i m making application using soap in android. want login functionality calling web service on click of login button. in want user log in application checking user registered or not(webservice sending successfull or failed respose). can tell me procedure or nice tutorial or sample code. b helpfull. thanks in advance. you should check out ksoap2 lib android. found video tutorial useful: http://www.vimeo.com/9633556 . apart that, using soap in android apps discouraged, , not supported sdk. consider using rest, if that's possible, it's more lightweight.

How to get substring (x,y) location from UILabel text (iPhone SDK)? -

how substring (x,y) location uilabel text (iphone sdk) ? for example: i having multiline label placed on view. now want (origin.x,origin.y) location of substring of uilabel.text , possible ? how ? i have try goggling not found soln yet.

javascript - Adobe Air - window.nativeWindow undefined -

i have adobe air application opening window menu tray. html content have javascript code doing alert(window.nativewindow) on load. it works fine embeded html static file it not works jsp called file i have correctly included airaliases.js. there restriction nativewindow ? my goal to: open jsp file form submitting form itself if ok, hiding nativewindow but seems nativewindow undefined. , window.close() did nothing well in fact sandbox security restrcition. an html code other domain can't execute air script (eg closing window) all turn around disable (eval(), onclick=, ...) the way to: put iframe bridge parameters put xml file granting more security right adobe application there full explanation in security chapter of adobeair api

Keep absolute reference even when inserting rows in Excel 2007 -

i have spreadsheet want cell formula @ specific cell, if rows or columns inserted , specific cell moves. effectively, want @ 'top' cell of table, if new rows inserted @ top of table. eg. cell a2 has formula[=$e$2] now highlight row 1 , insert row. formula in a2 says [=$e$3] want looking @ new row 2. the dollars keep absolute cell reference no matter 'referencing' cell, want cell reference absolute no matter 'referenced' cell. if makes sense! effectively, have 'table' in excel 2007 , want reference top row. trouble rows added table top top row keeps moving down make room new top row. --- alistair. try =indirect("f2") . work if know top-right cell of table going $f$2 .

Map SharePoint Sub Sites into Separate Domains -

i want map sharepoint sub sites separate domains.what procedure on doing in sharepoint 2010 ? i afarid not possible map seperate domain subsites. lowest level can isolate upto webapplication. need use fba claims based authentication web application running 2 domain.

Can I make Rhino Mocks GenerateStub or GenerateMock return a new type every time? -

i want create ilist of objects different concrete types, so: var tasks = new list<itask>(); foreach (string taskname in tasknames) { var task = mockrepository.generatestub<itask>(); task.stub(t => t.name).return(taskname); tasks.add(task); } return tasks; the problem each stub object same concrete type. fine, have case want test each 1 being different type. can somehow configure rhino mocks this, in case? edit : the "you-must-be-doing-it-wrong-crew" out in force today. since seem think need justify use-case before can take stab @ answering question, here's i'm doing: itask in domain model, it's part of business layer. i have logic in higher level (presentation) layer takes itask argument. the presentation layer logic executes default strategy on itask, there can special cases need use different strategy, , strategy use depends entirely upon concrete type of itask object. the regular strategy pattern doesn't work ...

iphone - Cocos2d MenuItem Selector and Accessing Instance Variable -

i have instance variable declared in implementation file can accessed using property defined synthesize @synthesize myproperty now, want assign property inside selector event of menuitem in cocos2d library. can think of accessing myproperty in callback function. reason whenever access property says "property out of scope". tried assigned access self.myproperty worked!! but have memory leak in self.myproperty. if release self.myproperty in dealloc throws exception saying have myproperty release. update 1: (code) nsstring *voice; @property (nonatomic,retain) nsstring *voice; @synthesize voice; -(void)repeatalphabet:(id)sender { *// cannot access voice variable in function.* [[simpleaudioengine sharedengine] playeffect:[[voice lowercasestring] stringbyappendingstring:@".caf"]]; } -(void) addrepeatbuttononscreen { ccmenuitemimage * menuitem1 =[ccmenuitemimage itemfromnormalimage:@"image1.png" selectedimage: @"image2.png...

Changing User Default settings in JIRA -

is there way change default settings users within jira? for example, default, non-admin user (a developer, example) has access projects rather (only) assigned projects. or, has done admin when new user created? i've read permissions, schemes, etc. i'm having difficult time figuring 1 out. (i'm not programmer...) yes, jira schemes take while head around. way you're asking change group goes project role "users" project. role filled jira-users group can change jira group like. define jira group "special-people", add users should able access project, change project role users use new group , there are. there's more detail @ new jira development blog in recent article , in atlassian documentation ~matt

C++ Interop: How do I call a C# class from native C++, with the twist the class is non-static? -

i have large application written in native c++. have class in c# need call. if c# class static, trivial (there's lots of examples on web) - write mixed c++/cli wrapper, export interfaces, , you're done. however, c# class non-static, , can't changed static has interface (the compiler generate error if attempt make c# class static). has run problem before - how export non-static c# class native c++? update 2010-11-09 final solution: tried com, worked nicely didn't support structures. so, went c++/cli wrapper, because absolutely needed able pass structures between c++ , c#. wrote mixed mode .dll wrapper based on code here: how to: marshal arrays using c++ interop how to: marshal structures using c++ interop as target class non-static, had use singleton pattern make sure instantiating 1 copy of target class. ensured fast enough meet specs. contact me if want me post demo project (although, fair, i'm calling c# c++, , these days people want call ...

iphone - UIScrollView autoresizing content? -

if set uiscrollview height self.view.frame.size.height , setautoresizingmask:uiviewautoresizingflexibleheight when view loads uitabbarcontroller , uinavigationbar scroll view frame resizes suit. however content size (set at: self.view.frame.size.height ) doesn't change. fair enough guess - can't seem find autoresizing option that, why autoresize. my fix set content size less frame height, content height of frame. (eg: set content size height 10points). i'm wondering if best way go this, or if there's better way? i'm doing code in viewdidload . thanks tom the uiscrollview's contentsize property define size of view displayed span&zoom. not have relation container (i.e. scrollview) size if need resize content according scrollview size, can overload layoutsubviews method so.

ant - How to change the class loader in the application.xml file to support preference loading of deployed jars -

i have built web app using tomcat 6 container. using couple of jars of tomcat's , referring them ant build in eclipse. i've written ant build deploy app .war , application.xml deployment descriptor .ear deploying 7. in order support this, i've pulled jars war know they'll available app worked through tomcat. i know need put application.xml file cause class loader use jars i've pulled in , not was's life of me can't find decent resource read on full range of options exist in application.xml file let alone need type put (parent_last?) text in. 1) can point me full online document listing things can put application.xml control .ear 2) can post listing modifies below xml such when xml file included in .ear can deploy such container uses jars in enclosed war rather ones in setup. i eternally grateful. <?xml version="1.0" encoding="utf-8"?> <application id="client"> <display-name>client</displ...

recursion - javascript: recursive anonymous function? -

let's have basic recursive function: function recur(data) { data = data+1; var nothing = function() { recur(data); } nothing(); } how if have anonymous function such as... (function(data){ data = data+1; var nothing = function() { //something here calls function? } nothing(); })(); i'd way call function called function... i've seen scripts somewhere (i can't remember where) can tell name of function called, can't recall of information right now. you can give function name, when you're creating function value , not "function declaration" statement. in other words: (function foo() { foo(); })(); is stack-blowing recursive function. now, said, probably don't may not want this in general because there weird problems various implementations of javascript. ( note — that's old comment; some/many/all of problems described in kangax's blog post may fixed in more modern bro...

c - memory allocation for structures -

can please explain me peculiar output: #include <stdio.h> typedef struct node { int i; struct node *next; }node; main() { node *p,*q; printf(" %u ",sizeof(node)); // 16 p = (node *)malloc(sizeof ( node ) ) ; printf(" %p ",p); // 0x1cea010 q = (node *)malloc(sizeof ( node ) ) ; printf("\n %p ",q); // 0x1cea030 } i have 64 bit processor. when size shown 16 byes, why 32 byte allocated node?? checked out 32- bit machine. addresses had separation of 8 bytes. no padding , stuff. difference of 4 bytes solely cause of padding issue of 64 bit machine?? two malloc calls aren't going return consecutive memory areas. better way test be: main() { node *p; printf(" %u ",sizeof(node)); p = (node*)malloc(2 * sizeof (node)); printf(" %p \n %p ", &p[0], &p[1]); free(p); } by allocating array, can sure ba...

c++ - How do I make my application use the Windows theme? -

Image
i'm working windows api create little application. created buttons, windows, alright. but problem components created don't os theme. simple: see button example. how enable windows theme? can in c or delphi. for application using windows controls, documented in this msdn article edit: make long story short, windows needs know application if intended use new style controls. older apps aren't compatible new skinned looks of xp , later. each exe should therefore declare version compatible in manifest, embedded xml file in executable. manifest used other things declaring or aren't compatible (dll versions, 120 dpi) registration-free com.

Strip slashes that jQuery adds when returning HTML via ajax? -

i using jquery ajax method data database , return data via json object. 1 of values in json object html string. doing seen here except need know how can remove slashes jquery adding html string. ideas? example json.html = click <a href=\"http://example.com/example.php\">here</a>; //needs json.html = click <a href="http://example.com/example.php">here</a>; i hoping without code if possible. update ok found if htmlentites before returned, slashes not there when value comes in. now, jquery function use insert string inside td element without slashes being added .html or .text functions. here looks directly json.html value, click &lt;a href=\&quot;http://example.com\&quot;&gt;here&lt;/a&gt; and here after displayed using .html click <a href=\"http://example.com\">here</a> and here after displayed using .text click &lt;a href=\&quot;http://example.com\&quot;&...

grails - Spring Security is redirecting to localhost on production server -

i have grails application spring-security-core plugin installed. works fine locally. deployed staging server , worked fine. deployed our production server mirror of our staging server. can unprotected pages fine. when spring security kicks in , tries it's redirects redirecting localhost instead of grails.serverurl. i'm going turn logging high possible , redeploy see if can make heads or tails of anything. i'll post finding here. if has experienced before , knows might happening, please let me know. also, if there configuration files need seen can provide well. thanks. update added following bottom config.groovy grails.plugins.springsecurity.usesecurityeventlistener = true grails.plugins.springsecurity.onauthorizationevent = { e, appctx -> println "here" println e } locally, closure gets hit 2 times when try , access protected page. once initial url. second time auth url. deployed our production server , nothing. the redir...

android - Make my activity one of the mail apps shown in the intent chooser -

when clicking email address browser or contacts app... is there way app show mail client in intent list? as can see mail application's source , having application catch intent simple adding intent-filter androidmanifest.xml inside mail composition activity definition. <intent-filter> <action android:name="android.intent.action.view" /> <action android:name="android.intent.action.sendto" /> <data android:scheme="mailto" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.browsable" /> </intent-filter> you can see <data> tag specifies handle mailto: links. browsable category means can launched browser. k-9 mail similar, except using sendto action default category, , view action browsable category.

c# - Overlap ListBox Items -

i have 2 listboxes close together, 1 on top , 1 on bottom. possible have 1 of listbox items on top listbox overlap listbox below? you mean, this? if so, negative top margin answer: <dockpanel> <dockpanel.resources> <style x:key="{x:type button}" targettype="button"> <setter property="width" value="50" /> </style> </dockpanel.resources> <listbox dockpanel.dock="top"> <listboxitem> <button>foo</button> </listboxitem> <listboxitem> <button>bar</button> </listboxitem> <listboxitem> <button>baz</button> </listboxitem> <listboxitem> <button>bat</button> </listboxitem> </listbox> <listbox d...

asp.net - When I Branch from Trunk I need to create a new Virtual Directory. Anyway around this? -

the trunk of app points <iisurl>http:///localhost/myapp/</iisurl> whenever create new branch, end having edit myapp.csproj change target url <iisurl>http:///localhost/myappbranchname/</iisurl> is there way don't need this? reason number of branches starting add , there's lot of virtual directories in iis. suppose use asp.net dev server, solution configured use iis, i'd prefer keep using that. what delete virtual directory trunk - manual task , bit of pain gets job done , don't have worry breaking colleagues environments after merge trunk. vs prompt create iis vd when open branch solution. so have small manual task , 1 virtual directory @ time.

python - Implementing Bi-Directional relationships in MongoEngine -

i'm building django application uses mongodb , mongoengine store data. present simplified version of problem, want have 2 classes: user , page. each page should associate user , each user page. from mongoengine import * class page(document): pass class user(document): name = stringfield() page = referencefield(page) class page(document): content = stringfield() user = referencefield(user) (note page must defined before user. if missing pythonic way handle circular dependencies, let me know.) each document can created , saved fine, assigning page user throws error. u = user(name='jeff') u.save() p = page(content="i'm page!") p.save() p.user = u p.save() u.page = p u.save() traceback (most recent call last): file "<stdin>", line 1, in <module> file "build\bdist.win32\egg\mongoengine\document.py", line 71, in save file "build\bdist.win32\egg\mongoengine\base.py", line 303, in validat...

intentfilter - Is it possible in Android to open other App than the one you clicked on? -

i wondering if possible intercept open application call, any(most of the) installed application. or @ least opening activity having intent-filter's action set main (if exists app). no, sorry, not possible. startactivity() calls targeted specific components , cannot intercepted. after all, massive security hole otherwise.

c# - Sending Client Certificate though HttpWebRequest, intermittenly working -

i have created web application calls web service requires client certificate authentication. here snippet of how building request: // grab certificate x509certificate2 cert2 = new x509certificate2(appdomain.currentdomain.basedirectory + giftcardconfig.a2a_certificatelocation, giftcardconfig.a2a_certificatepassword, x509keystorageflags.machinekeyset); // first call status account stringbuilder urlstatus = new stringbuilder(giftcardconfig.a2a_url + "webservice.asp?"); urlstatus.append("userid=" + giftcardconfig.a2a_userid); urlstatus.append("&pwd=" + giftcardconfig.a2a_password); urlstatus.append("&sourceid=" + giftcardconfig.a2a_sourceid); urlstatus.append("&cardnum=" + cardnumber); urlstatus.append("&purseno=" + giftcardconfig.a2a_purseid); urlstatus.append("&status=activate...

osx - Git not removing files when switching branch -

sometimes when switching branches using git (version 1.7.2.1) not seem remove files/directories created specific branch switched away from. neither list untracked when running git status or log entries files. this happens , i'm not sure why or how reset files not belonging current branch gets deleted. if delete files manually, gets in sync again (as in gets deleted/revived when switching branch). anyone experienced this? i have seen too. git reset --hard followed git clean -f -d , trick. it seems happen when ide has lock on 1 of files in branch i'm switching from.

android - Why change ListView cursor to null on stop? -

i've been looking @ examples of cursoradapter implementations make sure i'm doing right. one thing i've noticed i'm not doing calling changecursor(null) on cursoradapter in activity's onstop() handler. madapter.changecursor(null); what purpose of this? i'm willing if there's reason, hate navigating activity, backing activity, , seeing blank screen second until new cursor queried. what purpose of this? as falmarri suggests, cursor no longer tied adapter, , can close() cursor without problems. imho, not necessary call changecursor(null) in onstop() . particularly if manage cursor ( startmanagingcursor() on activity ), android take care of cursor respect activity lifecycle.

mvvm - Loading the list of items asynchronously in a WPF listbox using Dispatcher -

i working on creating wpf solution uses mvvm pattern load searched items in search control asynchronously. search control wpf usercontrol created textbox enter search text , search button , hidden listbox visible when loads searched items list in it. user control in turn embedded wpf view has treeview of items. view has view model in logic load searched items of tree view loaded in search control. while, has been happening synchronously without use of dispatcher call. but, after change request, make happen asynchronously in different thread using dispatcher. could please let me know how handle of dispatcher of search control in view model class call begininvoke on using mvvm pattern wherein view model not aware of view? clue highly appreciated. public observablecollection<details> catalogsearchresults { get; private set; } private void executesearchcommand(object parameter) { catalogsearchresults.clear(); if (string.isnullorempty(parameter.tostring())...

Scala recursive generics: Parent[Child] and Child[Parent] -

update : clarified , expanded, since original question simplified far i need pair of traits, each of refers other such parent , child classes must relate each other. trait parent [c <: child] { def foo(c: c) } trait child [p <: parent] { def parent: p = ... def bar = parent.foo(this) } such implementing classes must come in pairs: class actualparent extends parent [actualchild] { def foo(c: actualchild) = ... } class actualchild extends child [actualparent] { } unfortunately, compiler doesn't these traits because generic types aren't complete. instead of c <: child needs c <: child[ something ] . leaving them unspecified doesn't work either: trait parent [c <: child[_]] { def foo(c: c) } trait child [p <: parent[_]] { def parent: p = ... def bar = parent.foo(this) } it complains on parent.foo(this) line, because doesn't know this of correct type. type of parent needs parent[this.type] call foo have right types. ...

php - Symfony : error while accessing an array -

i want output array containing numbers. i'm creating array (it recieved statistics last 7 days) : <?php public function getstatisticsteams() { $tab = array(); for($i=7;$i=0;$i--) { $q = doctrine_query::create() ->from('stjob j') ->where('j.created_at = ?', date('y-m-d h:i:s' , time() - 86400 * $i )) ->execute() ->count(); $tab[] = $q; } return $tab; } action.class.php $this->st_job = doctrine::gettable('stjob')->getstatisticsteams(); use of array in template.php : $chart->inlinegraph(array('hits' => $st_job), array('monday', 'tuesday', 'wednesday' ....), 'div_id'); when try access array it fails because function use must have array supposed contain example (43,5,87,3,29,8,10) , , when var_dump($st_job) (my array) object(sfoutputescaperarraydecorator)#363 (3) { ["count":"sfoutputescaperarraydecorator":p...

JQuery JSONP cross domain call not doing anything -

whenever jsonp call through jquery page set (either locally or on server) silent treatment. firebug reports 200 ok , response looks ok. setup alerts boxes popup on success or failure neither appears. doesn't seem matter url use, nothing pops up. but if use twitter json page success alert box appears expected there wrong response don't know what. as experiment copied twitter json response , uploaded booroo.com domain. should identical, still nothing. set headers on response page "application/json" , utf-8 still nothing. please help, i've spent day on , don't know else try. $.ajax({ datatype: 'jsonp', // url: 'http://booroo.com/json.asp?callback=?', url: 'http://twitter.com/users/usejquery.json?callback=?', success: function () { alert("success"); }, error: function(x,y,z) { alert("error"+x.responsetext); } }); the response json.asp file contains followi...

c# - Opening an explorer window with designated file selected -

i have application has option show selected file in folder in file resides. question is, how achieve this? to clarify, if user in program selected "test.txt" file, want windows explorer window pop , highlight file user selected. can see similar behavior in limewire , utorrent. if select file in either of programs , choose "show in folder", pops windows explorer window file highlighted , selected. trying duplicate behavior. i tried using following line: system.diagnostics.process.start("explorer"); this popup windows explorer window, however, seems open default in "my documents" folder. here go, string filetoselect = @"c:\temp.img"; string args = string.format("/select, \"{0}\"", filetoselect); processstartinfo pfi = new processstartinfo("explorer.exe", args); system.diagnostics.process.start(pfi); note: adding \" before , after {0} parameter enables filetoselect string c...

c# - System.Threading.Timer's Dispose method does not work with ManualResetEventSlim? -

i have following code sample console app simulate windows service. class program { private timer timer; private object syncroot = new object(); private bool stopsignalled = false; private manualreseteventslim mre = new manualreseteventslim(false); static void main(string[] args) { program p = new program(); p.start(); console.readline(); p.stop(); console.writeline("stopped at:{0:g}", datetime.now); } private void stop() { stopsignalled = true; mre.wait(); } private void timercallback(object state) { lock (syncroot) { if (!stopsignalled) { console.writeline("callback invoked at:{0:g}",datetime.now); } else { timer.dispose(mre.waithandle); console.writeline("timer disposed at:{0:g}", datetime.now); ...

internationalization - International merchant account services...exchange rate conversions -

i'm not sure if post couldn't find answers. hoping developers have run accross before. i building subscription based product can used internationally. offer subscription in foreign currency of customer. have contacted couple of merchant account services , transact credit card country , deposit money in usd bank account (im in us). problem how currency conversion. say want have customer in uk sign monthly subscription price of 65 gbp. every month uk customer expects statement 65 gbp, merchants i've looked @ can't this. want me send them file $100 usd , based on day's exchange rate charge uk credit card 62 gbp 1 month, possible 64 gbp month, or 68 gbp , deposit $100 usd bank account. is there merchant account out there provide international transactions, exchange conversion other way? in other words, charge uk customer 65 gbp deposit $97 bank account...i'm ok, having deposits bank account fluctuate, i'm more concerned international users being...

mysql - SQL Server Express alternatives beyond 2GB limit -

in our project (which developed using .net), use medium sized database 2 gb in size. using sql express edition; how alternates sql server express perform? considering mysql , postgresql. (windows 7 x86, x64) is there compelling advantage using mysql or postgresql? what native .net object support? built in xml types? supporting binary data? support of similar tool management studio? installation ease? memory footprint? performance comparisons of these 3 databases? is worth considering these alternatives, considering fact .net shop? i have referred these related questions: db2 vs postgresql vs sql server database can handle >500 millions rows mysql versus sql server express i'm person doesn't believe because .net shop have use microsoft sql server product, although microsoft loves if do. of course ties in nicely native libraries , development tools microsoft. me that's advantages stop sql server , it's more of playing field other ...

visual studio 2010 - I want to debug an ASP.NET MVC app in IIS using a custom URL defined in HOSTS -

i having trouble setting vs2010 can debug in iis: i have added custom url's hosts i have edited application properties use local iis i have created virtual directory in iis any resources fro setting up? deploy application iis and, when running, try attach process visual studio debugger (in debug / attach process ). make sure web.config have debug mode turned on , assemblies compiled debug symbols.

sql server - Simplify SQL Insert which uses NEWSEQUNETIALID() column default -

i have following insert stored procedure: create procedure dbo.appl_serverenvironmentinsert ( @serverenvironmentname varchar(50), @serverenvironmentdescription varchar(1000), @usercreatedid uniqueidentifier, @serverenvironmentid uniqueidentifier output ) recompile -- stores serverenvironmentid. declare @appl_serverenvironment table (serverenvironmentid uniqueidentifier) -- if @serverenvironmentid not supplied. if (@serverenvironmentid null) begin -- insert data table. insert appl_serverenvironment with(tablockx) ( serverenvironmentname, serverenvironmentdescription, datecreated, usercreatedid ) output inserted.serverenvironmentid @appl_serverenvironment values ( @serverenvironmentname, @serverenvironmentdescription, getdate(), @usercreatedid ) --...

sql server 2005 - FTP Connection string using expression in SSIS -

in ssis 2005 package, need give ftp connectionstring via expression need keep configurable user dtsconfig file. at moment tried giving following expression: connectionstring = @[user::ftpserver] + "." + @[user::ftpuser] + "." + @[user::ftppass] for unique syntax, took pointers discussion @ http://social.msdn.microsoft.com/forums/en-us/sqlintegrationservices/thread/3713e9a5-343a-4c5b-ac5d-1508cd5ab8be my ftpserver variable has port info in format myservername:21. but getting error "530 user anonymous unknown" any idea how can fix error? i think variables should have 2 :: not one. @[user::ftpserver] + "." + @[user::ftpuser] + "." + @[user::ftppass] edit: you may having trouble due password being cleared what set these details beforehand via script task. run script , run ftp task - think should work. public class scriptmain public sub main() dim ftpconnectionmanager connectionmanager 'set variable...

php - Is there a native CodeIgniter function that does the reverse of $this->db->escape()? -

i looking function reverse of $this->db->escape() original string when still unescaped. i have tried searching in codeigniter docs. don't think can find one. i tried finding native php function it( since uses mysql_real_escape_string when using mysql) far closest thing can find stripslashes() stripslashes unescape string correctly.

Android: Only one Looper may be created per thread -

i having problem android looper. have class has extended asyntask. inside doinbackground() method have looper.prepare() , code below. it runs , first time after gives exception " 1 looper may created per thread" . there seems solution use looper.quit() unable implement it. any appreciated. class looperthread extends thread { public handler mhandler; public void run() { looper.prepare(); mhandler = new handler() { public void handlemessage(message msg) { // process incoming messages here } }; looper.loop(); } }

Sending multiple email from codeigniter -

hi friends creating newsletter in codeigniter. there way send multiple email ci email lib or should use third party ? using email class, like: foreach ($list $name => $address) { $this->email->clear(); $this->email->to($address); $this->email->from('your@example.com'); $this->email->subject('here info '.$name); $this->email->message('hi '.$name.' here info requested.'); $this->email->send(); } would work. (straight docs). depends on how many addresses have, , constraints such server/mail queue processing/script time out etc i'm not aware of 3rd party ci newsletter plugin/library haven't looked hard.

java - Does Spring MessageSource Support Multiple Class Path? -

i designing plugin system our web based application using spring framework. plugins jars on classpath. able sources such jsp, see below resourcepatternresolver resolver = new pathmatchingresourcepatternresolver(); resource[] pages = resolver.getresources("classpath*:jsp/*jsp"); so far good. have problem messagesource. seems me reloadableresourcebundlemessagesource#setbasename not support multiple class path via "classpath*:" if use "classpath:", messagesource 1 plugin. does have idea how register messagesources plugins? exist such implementation of messagesource? the issue here not multiple classpaths or classloaders, how many resources code try , load given path. the classpath* syntax spring mechanism, 1 allows code load multiple resources given path. handy. however, resourcebundlemessagesource uses standard java.util.resourcebundle load resources, , simpler, dumber mechanism, load first resource given path, , ignore else. i d...

php - How to make a join statement between multi table to one table? -

Image
first, have 4 table , columns such feeds (id, type, type_id) feeds_normals (id, type, content) feeds_links (id, type, title, link) feeds_youtubes (id, type, title, link, description, image) feeds_photos (id, type, link) the table of "feeds type_id" match/linkup "id" of normals, links, youtubes, photos and the table of "feeds type" using identified table should joined for example: feeds: id: 1, type: "normal", type_id: 1 id: 2, type: "link", type_id: 1 feeds_normals: id: 1, type: "normal", content: "this test" feeds_links: id: 1, type: "link", title: "this title", link: "http://yahoo.com" result: id: 1, type: "normal", content: "this test", title: null, link: null id: 2, type: "link", content: null, title: "this title", link: "http://yahoo.com" finally in case, how write sql statement? something wro...

HTML5 Websocket and ISA Proxy issue -

i'm not expert in isa server, issue following: var wsuri = "ws://192.168.1.7:8887"; websocket = new websocket(wsuri); these 2 lines work fine. when try 192.168.1.7 external computers set rule in isa server: websocket.domain.com -> (redirect 192.168.1.7, bridging = redirect request http port 8887) and following doesn't work: var wsuri = "ws://websocket.domain.com"; websocket = new websocket(wsuri); i see in isa log "status: 10061 no connection made because target machine actively refused it." seems websocket doesn't transform message http tunneled destination server. thanks in advance! finally i've made workaround. installed pc, gave public static ip , deploy websocket on it.so pc out of network , doesn't deal isa. came conclusion isa 2006 not pass original http message , somehow corrupted it.

internet explorer - IE6 displays JavaScript error for below given function and error is also mentioned below -

Image
i have function function setbid(catid) { if(catid == 30) { document.getelementbyid('bannerid').value = 1; } else if(catid == 31){ document.getelementbyid('bannerid').value = 2; } else if(catid == 32){ document.getelementbyid('bannerid').value = 6; } } this function being called onchange event of select box. now when value of select box changed ie throws me error saying "document.getelementid(....)" null or not object.. now can infer this? please help.. update as per david's reply how can check existance before assignment of value field,? other browsers not display error, have bannerid field hidden field in document... should done? below screen shot of error displayed onchange of select box update 2 update per answer of @haylem <script> function setbid(catid) { var lookup = { '30' : 1, '31' : 2, '32' : 6 }; if (lookup.hasownproperty(catid)) { var el = document....