Posts

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...