Posts

Showing posts from January, 2011

c - convert a pointer of array in Java -

i'm trying convert program in c java. don't know c programming, i'd understand bit btw. well i've got functions in c: static int memcmp( byte *a, byte *b, int len) { int i; (i = 0; < len; i++) if (a[i] != b[i]) return 0; return 1; } static int rfind(byte *data, int pos, int leng) { int i; (i = pos - leng; > -1; i--) if (memcmp(data+i, data+pos, leng)) return i; return pos; } that can't workout. seems function memcmp compare 2 blocks of memory. when size of data: printf("size %d \n", sizeof(data)); i got 8 result while orignal size can 32 or 40 (any documentation pointers welcome). anyone me translate bit java have gratitude (and more). thanks java doesn't have pointers, can't translate code directly. in c, can treat pointers arrays, whereas in java need use indexes same array. more or less direct translation can come with: public int rfind(byte[]...

Android getting RESULT_CANCELED when I specifically add RESULT_OK -

this problem, have main view shows 1 button, pressing button view shown. view has button, when button push current view finishs , control backs previous view. to show second view use startactivityforresult, put code here. private void startnewview() { intent = new intent(getapplicationcontext(), newview.class); startactivityforresult(it,view_id); } the view called has button event, here code button b = (button) findviewbyid(r.id.close); b.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { setresult(result_ok); finish(); } }); and finally, method onactivityresult in main view, here code protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if(requestcode == view_id && resultcode == result_ok) { tv = (textview) findviewbyid(r.id.tv); tv.settext("the...

Data model for timesheet to task and/or timesheet to project? -

let's want make simple project tracking system. manager can create project. can create tasks project. team members can record hours work each task or project whole. is following design t_timesheet table idea? timesheet_id - primary key, autoincrement project_id - not null, foreign key constraint t_project task_id - nullable, foreign key constraint t_task user_id - not null, foreign key constraint t_user hours - decimal or should this: timesheet_id - primary key, autoincrement task_id - not null, foreign key constraint t_task user_id - not null, foreign key constraint t_user hours - decimal in second option, intend have record in t_task labelled "miscellaneous items" foreign key relevant t_project record. i'll able track hours project aren't particular task. are of ideas above good? better? while believe nullable foreign keys have place in relational databases, in case tend towards second option. forces project manager explicitly ...

javascript - Can onclick take a function in a function? -

this want. onclick="pager(function2();) but doesn't seem work. take out semicolon: onclick="pager(function2())" http://jsfiddle.net/bqyvv/ you not passing function function, value. when element clicked, function2() called, , it's return value becomes argument pager() function. if function2 not return anything, pager receive undefined argument.

Can UPnP Discovery be done from Javascript? -

i'm working on webpage on want discover upnp devices, client maybe on different vlan server. so, upnp discovery needs happen on client. apparently udp not possible javascript. know if there way upnp discovery client's browser? javascript has no built-in raw networking capabilities. example, can't natively pings. can diy ping/port scanner using img tag, , setting src attribute target , testing response. but, other that, need plugin or activex. i suggest using java.

sockets - How to Broadcast to a shutdown system using java? -

we use socket.send(packet) function in java send "packet" given port. problem have send packet shutdown system using udp protocol. problem send() function first verifies whether host ip multicast or not. local area network of broadcast type. having problem using function. can please give me way ? do know how send udp packets in java? first of all, broadcasting must enabled in network. then, servers must join agreed multicast address. inetaddress address = inetaddress.getbyname( "230.0.0.1" ); multicastsocket socket = new multicastsocket( 12345 ); socket.joingroup( address ); when want activate system shutdown, send agreed message (for example, "die") multicast address. datagrampacket packet = new datagrampacket( buf, buf.length ); socket.receive( packet ); string received = new string( packet.getdata(), 0, packet.getlength() ); the servers when accept message should initiate shutdown flow.

Error while loading a file in Python-Set Up path Problem -

following error occurred while trying add or remove files in installation directory: [errno 13] permission denied: '/usr/local/lib/python2.6/dist-packages/test-easy-install-20294.pth' installation directory specified (via --install-dir, --prefix, or distutils default setting) was: /usr/local/lib/python2.6/dist-packages/ perhaps account not have write access directory? if installation directory system-owned directory, may need sign in administrator or "root" account. if not have administrative access machine, may wish choose different installation directory, preferably 1 listed in pythonpath environment variable. information on other options, may wish consult documentation at: http://peak.telecommunity.com/easyinstall.html please make appropriate changes system , try again. how change directory? or how make change accepts changes in root directory? the easiest way run command administrator privileges. looks you're using form of li...

c++ - String static member error -

i making basic program takes input , prints getting strange error static variable.please me out.thanks code: /* date:5th january 2011 programmer:fahad */ #include <iostream> #include <string> using namespace std; class persons //a class store name,addresses , id numbers of users { private: string name_; string address_; int id_number_; public: static int count;//this count of objects created persons(); void getdata(int n); void displaydata(int n); //~persons(); }; static int count;//initializing static member int main() { cout << "enter number of persons:"; int n;//this number of objects user wants make. cin >> n; persons *ptr;//a pointer used dynamic memory allocation. /*exception handling*/ //////////////////////////////////////////////////////////////////// try { //ptr=new [sizeof(persons) * n]; ptr=new persons[n...

c++ - Can there be two public section in a class? If yes then why ? And in which circumstances we do so? -

there bugging me classes. example class { public: a() { ..... ..... } void cleanup() { .... .... .... } public: uint a; ulong b; }; in above example there 2 public section. in first section defining constructor , method , in second section declaring data members. above class i.e. correct. can that? if yes why needed , in circumstances should use it? since can entire thing in 1 section why there 2 sections? access qualifiers apply code follows until next qualifier. there no restriction on number or order of such qualifiers. it not necessary repeat same access qualifier in class, , doing confuse reader. may have effect on layout of class, since data members following same qualifier must laid out in order declared, there no such restriction between qualifiers.

javascript - To trigger everytime with .click()? -

i tried have .click() on <a> find out wont trigger every time click, suppose open dialog. that not problem need pass value jquery to. cant figure 1 out. i need <a> because it's gone in dropdown menu. got suggestions? edit code use , workes $(document).ready(function() { $('#dialog').dialog({ autoopen: false, bgiframe: true, modal: true, height: 600, width: 1000, close: function() { $(this).dialog('destroy'); } }); $('a').live('click', function(evt) { evt.preventdefault(); var ids = $(this).attr('id'); var first = "<iframe style='width: 100%; height: 100%;' src='" + "" + "'</iframe>'"; $('.iframe').html(ids); $('#dialog').dialog('open'); }); }); this code intilise dialog, open on every click , work every time, trick me here 'destroy' @ ...

c++ - Qt TcpServer architecture -

the question architecture of server qt. example, there slot readyread() being called when socket signals readyread() if there several kind of requests can void server::readyread() { qstring msg = readfirstwordfromavaiabledata(); switch (msg){ case "ping": case "get": // , on } } i wonder there other way this. guess isn't expandable , comfortable. if want server work client written on java, c, perl, etc should use qbytearray only, right? in samples qtdemo client sends size of message before message. necessary? it nice if suggest me samples servers written qt (on github, bitbucket, etc). want how production servers arranged. if each of commands have fixed length of payload, may not necessary send message length. qbytearray convenient wrapper around unsigned char array, , has useful utility methods, it's thing use. can use qstring if protocol text-based, though aware default qstring unicode, character takes 2 by...

c# - How do you embed a resource so that it can be accessed for icons? -

i have c# project using vs2005. have 2 icons, 1 application, , 1 files associated application. i have associated these files application, , know how set icons in registry, can set them application icon because seems external resource. i've tried having icons either in resource file (.resx), or seperate file (.ico) compiled exe @ compile time, neither work. to show mean, i've built app , opened resource hacker, , you'll notice 1 of 2 icons there, using 1 icon , 1 icon group. http://img442.imageshack.us/img442/3189/resourcesx.jpg http://img442.imageshack.us/img442/3189/resourcesx.jpg i not think can done. may have resort c++ project can embedd icons in way can recognized shell. note not mean dll has contain else ;) don't think .net assemblies can contain shell compatible resources.

postgresql - Postgres Function to Validate Email Address -

a check constraint call function validate email addresses not working fine me. create or replace function f_isvalidemail(text) returns boolean 'select $1 ~ ''^[^@\s]+@[^@\s]+(\.[^@\s]+)+$'' result ' language sql; select f_isvalidemail('myemail@address.com'); the function returning false, should true. have tried couple of other regexs in vain. can point out what's wrong function? screenshot before go putting lot of effort this, thing want make sure you're not kicking out valid email addresses. there's kinds of insane rules can or can't in email address, , if wrong, in wrong direction, user valid email address might rejected system. the best way determine if email address valid use part of registration process email required. else lot of work little gain.

php - Retrieving SELECT information from an INSERT .. SELECT mysql statement -

i'm using insert .. select statement in mysql copy information 1 table want retrieve select information set variables in php. possible in insert .. select statement? doesn't work me using mysqli_fetch_array function on resource , right having select statement seems kinda unnecessary step me. no, insert query (no matter type) not return result set read values from. need issue select query if want bring rows php.

php - Checksum Failure -

i've got script , produces following error: 001 checksum failure this script, don't know what's wrong it, me? <?php /* access control targetpay pay per use (c) targetmedia 2007 upload file in protected directory , make sure .htaccess support enabled. modifications in code allowed not supported product-id: 28717 generated: 16-01-2011 14:57:05 */ define ("checksum", "739b54dc26"); define ("err001", "001 checksum failure"); define ("err002", "002 can't open .htaccess writing. check rights."); define ("err003", "003 i/o error, cannot write .htaccess. disk full?"); list($thispage) = explode("?", "http://".$_server["http_host"].$_server["request_uri"]); $payscreen = "http://www.targetpay.nl/send/?id=28717&rtlo=51090". "&pm=".urlencode("inline=1"). "...

error handling - Catching "NullPointerExceptions" in JavaScript -

i'm writing quite bit of code in prototype.js returns null if dom-id wasn't found. $("someid").show(); if someid doesn't exist, method called on null, halts entire program, in effect disabling js effects after error. check null before executing such statement, getting tiring. i catch exception i'm not sure 1 is. mdc lists following ecma script error types, on first glance none of them seem want: * error * evalerror * rangeerror * referenceerror * syntaxerror * typeerror * urierror * domexception * eventexception * rangeexception also, browsers have unified way of dealing method call on null? i don't believe there's unity found. chrome throws typeerror, ie throws error, have catch , make severe assumptions. better check null first. var element = $('someid'); if (element) { element.show(); // whatever else... } if element.show() thing need for, can written lot shorter, in cases appropriate.

vb.net - Error: Syntax error in UPDATE statement -

the error while executing code below in oledb try con.open() dim cmd new oledbcommand("select * customer", con) cmd.commandtext = " update customer set hr =@hr,min =@min " cmd.parameters.addwithvalue("@hr", comboboxhr.selectedindex.tostring()) cmd.parameters.addwithvalue("@min", comboboxmin.selectedindex.tostring()) cmd.executenonquery() twodigit(comboboxhr) messagebox.show("conratulations! ...click start button see changes") catch ex exception messagebox.show(ex.message.tostring()) end try which works fine if remove "min" part. reason? i believe aakashm right. can use keyword column name long put in [] try con.open() dim cmd new oledbcommand("select * customer", con) cmd.commandtext = " update customer set hr =@hr,[min] =@min " ...

visual studio 2008 - Configuring xUnit test output in Hudson -

i have simple poc project in hudson. poc has unit tests written via unittest++ , outputs results xml consumption xunit munge junit format. here salient relevant i have project configured use msbuild build 2008 solution. the project contains both dll build , unit tests run post-build step. i set workspace in hudson set c:\develop\money (money name of project) , in hudson console can see workspace folders, solution file , output folders (/bin, /doc, etc). the test console app outputs file 'money_unit_tests.xml' folder 'reports' (making c:\develop\money\reports) precreated. however seems workspace isn't sticking. if submit workspace directory shows me folders if reload page shows 'no files in directory' message. why hudson not use c:\develop... configured it? what can change it? if can't change it, can mitigate these changes? (i don't want hardcode output xml c:.hudson...) it appears in configure there advanced option h...

interop - check if a sheet exists in excel -

how check if sheet exists in excel using interop. tried following throws comexception if not there.. there better way of finding out looking @ exception worksheet sheet = null; sheets worksheets = some; sheet = (worksheet)worksheets.get_item("sheetname"); if(sheet!=null) { //do } edit: thanks input guys. i wrote function private dictionary<string, worksheet> getsheetsmap(sheets worksheets) { if (worksheets == null) throw new argumentnullexception("worksheets"); dictionary<string, worksheet> map = new dictionary<string, worksheet>(stringcomparer.currentcultureignorecase); foreach (worksheet s in worksheets) { map.add(s.name, s); } return map; } and use below dictionary<string, worksheet> sheetmap = getsheetsmap(worksheets); worksheet sheet = null; if (sheetmap.trygetvalue(extendedtemplatemanager.basicusertemplate, out sheet)) ...

iphone - How to check if Location Services is On or not? -

how can check if user has turned off location services ? so can prompt him/her turn on in order use app. thank ! the cllocationmanager provides class methods determine availability of location services: - (bool)locationservicesenabled (for < ios 4.0) + (bool)locationservicesenabled (for ios 4.0 , greater) + (clauthorizationstatus)authorizationstatus (for ios 4.2+) (and others, see documentation)

iphone - connect UITableView + UITableView -

right have indexed uitableview goes detail view want go uitableview detail view. my code this: ` - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { displyanncontroller *ancontroller = [[displyanncontroller alloc] initwithnibname:@"annview" bundle:[nsbundle mainbundle]]; detailviewcontroller *dvcontroller = [[detailviewcontroller alloc] initwithstyle:uitableviewstylegrouped]; switch (indexpath.row) { case 0: [self.navigationcontroller pushviewcontroller:ancontroller animated:yes]; [ancontroller release]; ancontroller = nil; break; case 1: [self.navigationcontroller pushviewcontroller:dvcontroller animated:yes]; [dvcontroller release]; dvcontroller = nil; break; default: break; }` and when press cell index 0 in simulator, program crash! what's problem? pleas me .. no, didn't override -initwithnibname , use same way here,but p...

sorting a timer in matlab -

ok seems simple problem, having problem have timer each data set resets improperly , result timing gets mixed. ideas correct it? without losing data. example timer col ideally should be timer , mine reads 1 3 2 4 3 5 4 6 5 1 6 2 how change colum 2 or make new colum reads colum 1 without changing order of ther rows have data example file lengths 86000 long , have missing timers not want miss , imples no data period of time. thanks edit: not want change other columns. coulm 1 gps counter , not sync comp timer due other issues. want change row 1 such goes high low without effecting other rows. take care of missing pts ( if did not care missing pts simple n=1: max work. missing data in case indicated missing timer. example have 4,5,8,9 missing 6,7 ok let me try edit agian 8600x 80 matrix of data: timer 1 row should go 0 8600 timer starts @ odd times , have start of data middle , le...

Haskell IF statements -

i'm pretty new haskell, if make if statement: function b c | (a+b == 0) = true | --etc. | otherwise = false is second if statement same else if in other languages, or if. assume former can have 1 output, want make sure. the construct used called guard . haskell checks given alternatives 1 after until 1 condition yields true . evaluates right hand side of equation. you pretty write function n | n == 1 = ... | n == 2 = ... | n >= 3 = ... thus guard kinds of represents if/elseif construct other languages. otherwise defined true , last | otherwise = will true , therefore represents catch-all else clause. nontheless, haskell has usual a = if foo 23 else 42 statement.

C# Create Values in Registry Local Machine -

this not working me: public bool createregistry() { if (!registryexists()) { microsoft.win32.registry.localmachine.createsubkey("software\\xelo\\"); microsoft.win32.registry.localmachine.opensubkey("software\\xelo").setvalue("hostname", (string)hostname, microsoft.win32.registryvaluekind.string); return true; } else { return updateregistry(); } } the exception error not authorized this. apreaciated exeption: system.unauthorizedaccessexception | "cannot write registry key" for working answer read comment on accepted solution non-admin , unelevated admin users don't have rights modify hkey_local_machine key. run program 'as administrator'.

ruby - Is there one Rack app instance per HTTP request? -

i'm building facebook app called lovers , using sinatra app on heroku . it's running on ruby 1.9.2 on heroku's bamboo-mri-1.9.2 stack . it's modular sinatra app , , in lovers source code , i'm giving each instance of sinatra app ( lovers::application ) instance of facebook::application : require 'sinatra/base' class lovers::application < sinatra::base attr_reader :facebook def initialize(app=nil) @facebook = facebook::application.new( lovers::conf.fb_app_id, lovers::conf.fb_app_secret, lovers::conf.fb_canvas_name) super(app) end # ... end that way, can lovers.application.facebook access facebook::application instance anywhere within lovers module, lovers::user . does make sense, or should have instances of lovers::application (if there's ever more one) share same facebook::application instance, i.e., lovers.facebook . that's we're doing redis: lovers.redis , makes sense me. guess i'm lea...

PHP,SMARTY - File upload not working in IE alone -

i have form defined via smarty, consisting of multiple tabs various purposes. 2 of tabs have file upload controls placed inside it. form submission works without flaws in firefox, when same in ie8/7, form submission working first file upload control. second file control not @ picked browser, while submitting form. file upload control defined in normal way, , not making use of smarty tags that. <input type="file" name="e2c[vids_upload]" maxlength="100000"/> code. working in firefox without issues my guess have 2 inputs same name. browsers expect unique names each file input instance. see both similar names, i'd suggest doing this: <input type="file" name="e2c[vids_upload][]" maxlength="100000" /> this put each file it's own index under e2c[vids_upload] can see them both on other side. admittedly, if issue, i'm surprised firefox working @ all.

xml - Default value of xmlns? -

consider have following xml document <?xml version="1.0" encoding="utf-8"?> <root> <child /> </root> as can see root not have default namespace specification. default namespace specified attribute xmlns . the question default namespace of such xml document? if post answer please include reference information taken from, e.g. w3c. there no default schema or namespace in xml. if not declare namespace in xml document, has none. from spec : for name n not in namespace, namespace name has no value.

swing - Java JTextPane RTF Save -

i have following code trying save contents of jtextpane rtf. although file created in following code empty! any tips regarding doing wrong? (as usual dont forget im beginner!) if (option == jfilechooser.approve_option) { //////////////////////////////////////////////////////////////////////// //system.out.println(chooser.getselectedfile().getname()); //system.out.println(chooser.getselectedfile().getabsolutefile()); /////////////////////////////////////////////////////////////////////////// styleddocument doc = (styleddocument)textpanehistory.getdocument(); rtfeditorkit kit = new rtfeditorkit(); bufferedoutputstream out; try { out = new bufferedoutputstream(new fileoutputstream(chooser.getselectedfile().getname())); kit.write(out, doc, doc.getstartposition().getoffset(), doc.getlength()); } catch (filenotfoundexception e) { } catch (ioexception e){ } catch (badlocationexception e){ } } edit: htmleditorkit if use htmleditorkit works , thats wanted. solved! ...

c - strstr and occurrences to match -

i have several possible occurrences test strstr . if ((a = strstr(string, "foo")) != null || (a = strstr(string, "bar")) != null || (a = strstr(string, "foo2")) != null ||(a = strstr(string, "bar2")) != null || (a = strstr(string, "foo3")) != null ||(a = strstr(string, "bar3")) != null) // and based on occurrence found need var = strlen("the_one_matched_above"); what way without using lots of if statements? are willing use comma operator: if ((lookfor = "foo", = strstr(string, lookfor)) != null || (lookfor = "bar", = strstr(string, lookfor)) != null || ...) { var = strlen(lookfor); } the comma operator allow evaluate multiple expression in left right order. value of expression whole value of rightmost esub-expression.

ipad application memory warning when using little memory -

i running ipad application compiled release , seing memory warnings once in while. when run app on device , connect instruments, see app never passes 40mb of real memory, warnings still occurring. what might causing this? how can better track down reason? 40 mb of real memory lot, ipad. if not, system deliver low-memory warning time time anyway, without application being main culprit. tracking down precise memory usage in application hard, i’d suggest spend time object allocation instrument while working app. if not getting killed , sure not leak memory, can ignore warnings.

c++ - How to specify preference of library path? -

i'm compiling c++ program using g++ , ld . have .so library want used during linking. however, library of same name exists in /usr/local/lib , , ld choosing library on 1 i'm directly specifying. how can fix this? for examples below, library file /my/dir/libfoo.so.0 . things i've tried don't work: my g++ command g++ -g -wall -o my_binary -l/my/dir -lfoo bar.cpp adding /my/dir beginning or end of $path en` variable adding /my/dir/libfoo.so.0 argument g++ add path new library ld_library_path (it has different name on mac ...) your solution should work using -l/my/dir -lfoo options, @ runtime use ld_library_path point location of library. or use rpath option via gcc linker - runtime library search path, used instead of looking in standard dir (gcc option): -wl,-rpath,$(default_lib_install_path) this temporary solution. linker first searches ld_library_path libraries before looking standard directories. if don't want permanently u...

c# - Sending command to showDialogue Form from inactive form -

Image
i want send keys show dialogue form inactive form.see picture form showing dialogue.behind form has customized keyboard , numpad. send keys against these button clicks. how possible can send keys keyboard show dialogue form. what you're asking impossible. once understand how modal dialogs work (forms shown using showdialog method modal), understand why. modal dialog used when want force user interact only dialog. prevents them interacting other windows in application disabling windows. become impervious mouse clicks, don't receive keyboard input, , can't receive focus. windows beeps @ , flashes title bar of modal dialog when try, it's non-subtle way of shaking head , saying "no, no, no". so what's going on here when show "deposits" form modal dialog using showdialog method, of other windows in application disabled. in particular case, means window contains on-screen keyboard disabled, too, , can't receive mouse click e...

Eclipse - Handling Java Exceptions like in NetBeans -

i moved netbeans eclipse , miss 1 great feature - whenever use method throws kind of exception, netbeans alerted me , needed add try-catch , netbeans automatically generated exception type me. there similiar eclipse? f.e. : integer.parseint(new string("foo")) ; netbeans alerts need catch numberformatexception. eclipse doesn't alert me @ all i using eclipse java ee ide web developers, 3.5 - galileo it does. have hit "save" (ctrl + s) before that, of course. of course, shouldn't have declared method throw exception (for example throws exception ) also make sure have project > build automatically selected. important : don't declare or catch runtimeexception or subclasses - these unchecked exceptions, , them eclipse rightly doesn't offer options. numberformatexceptions 1 of these. try methods of fileinputstream , example, ioexception - checked exception - thrown. (for record - netbeans doesn't integer.parseint(.....

networking - "select" in Racket -

i want write event loop single threaded web server deal each request in racket. see there select method in unix can call, there similar in racket api can call? or should write own select method polling ready fds? in advance! apologies if i'm misunderstanding question, sounds you'll want use tcp-listen on ports; success here create input ports. in order synchronize on multiple open input ports, check out "synchronizable events"; can use 'sync' on whole bunch of open ports simultaneously. i remiss if failed add there's complete web server included racket; i'm assuming have own reasons wanting re-implement this.

java - Best way to style GWT widgets in a library -

i'm developing widgets library internal use @ company work for. i don't know what's recommended way style widgets. there @ least these ways: use widget.setprimarystylename , let user provide external css. use maven archetypes build applications can provide default styles. anyway don't much. use gwt 2.0 cssresourcebundle. can compile css module , optimized (and can browser-dependant too). provide module styling. default gwt themes. don't know how works. i want to: make components cohesive can (don't depend on externally included css's) leave open door modify styles (if want change way widget looks in concrete application). what's experience in subject? note: if looking definitive answer through answers , comments. there different ideas , ones. choose best :) i think best way provide styles in module. way able restyle, or add "themes" controls. i'm doing similar project hosted on github ( http://github.com...

Android DatePicker Date Limiting -

i using datepicket in activity , i want limit date picked user todays date. they should not able select date greater todays date. thank you. yes can easely validation here exemple: if(dateobj1.before(dateobj2) || dateobj1.equals(dateobj2)){ //the program runs } else{ new alertdialog.builder(pm_edit.this) .settitle("wrong data input!") .setmessage("the end date must before start date, please insert new date values") .setneutralbutton("ok", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { } }).show(); } credits to: http://www.brighthub.com/mobile/google-android/articles/41545.aspx

iphone - how can I delete videos stored in documents folder? -

i have stored videos in documents folder. path /users/sridhar/library/application support/iphone simulator/user/applications/ec177e77-8665-485c-93de-62350fa6d0e7/documents/air.mp4 i want delete video . how can programmatically. it should work: nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *filepath = [documentsdirectory stringbyappendingpathcomponent:@"air.mp4"]; bool succeed = [[nsfilemanager defaultmanager] removeitematpath:filepath error:nil];

asp.net mvc - asp mvc home root not working with mono, fastcgi and nginx -

i have mono 2.6.7 , i'm trying port asp.net mvc application. i've managed solve case sensitivity problem setting variable mono_iomap=all . have still 1 more problem, home root isn't working. page not found error (although /home , /home/index work). i'm using nginx , fastcgi. here configuration nginx: server { listen 80; server_name mydomain.com; access_log /var/log/nginx/mydomain.com.log; location / { root /home/ec2-user/www/mydomain-web/; index index.html index.htm default.aspx default.aspx; fastcgi_index default.aspx; fastcgi_pass 127.0.0.1:9000; include /etc/nginx/fastcgi_params; } this ended working me. server { listen 80; server_name mydomain.com; access_log /var/log/nginx/mydomain.com.log; location / { root /home/ec2-user/www/mydomain-web/; fastcgi_index /; fastcgi_pass 127.0.0.1:9000; include /etc/nginx/fastcgi_param...

bison/flex: Peek at the next letter or token -

when dealing strings (it has own state comments) need find out if next letter " or not. if dont end string state. happens dont end string in string state (i use <string_state>. , process letter letter). happens is, mark if last string " , if current isnt exit state , unput last letter. this has weird effect. when errors on lines strings see letter (usually ',' or ')') twice. , if happens on end of line side effect counts 2 lines! (even if there isnt error). how can solve this? option create global var , mark when leave string state , hack yy_user fix itself? kind of want avoid that. cleaner @ next letter or token, possible? in flex, can "peek ahead" @ future tokens using / lookahead operator. rule like ab/cd will match 'ab' input if , if followed 'cd'. means flex matches 'cd' rule, pushes input buffer before calling action rule, yytext contains 'ab' when see it, , 'cd' read again ...

dynamics crm - Retrieving related entities using RetrieveMultipleRequest -

i have entity called invoice , entity called invoiceitem. there 1 many relationship called new_invoice_invoiceitem. there lookupattribute in invoiceitem called new_parent_invoice_invoiceitem. i trying retrieve invoiceitems related invoice particular id using following code: queryexpression query = new queryexpression(); query.entityname = "new_invoiceitem"; query.columnset = new allcolumns(); conditionexpression condition = new conditionexpression(); condition.attributename = "new_parent_invoice_invoiceitem"; condition.values = new object [] { new guid("fe1009cc-e034-49d5-bc59-ab4c3091a6f9") }; condition.operator = conditionoperator.equal; filterexpression filter = new filterexpression(); filter.addcondition(condition); query.criteria = filter; retrievemultiplerequest request = new retrievemultiplerequest(); request.query = query; retrievemultipleresponse response = (retrievemultipleresponse)crmservice.execute(request); businessentitycollect...

php - Merge entries in CakePHP -

let's have model, example user, , want merge 2 instances of model, merge user2 user1. explicitly mean: if field filled in user1, should remain same if field missing in user1 present in user2, should copied if somemodel belongsto user, every instance of somemodel pointing user2 should modified point user1 same if somemodel hasandbelongstomany user if somemodel hasmany user, , somemodel1 has user2 no other instance has user1, should modified somemodel1 has user1 instead if somemodel hasmany user, somemodel1 has user1 , somemodel2 has user2... well, i'm not sure here, guess solution discard somemodel2, since user1 can belongto 1 somemodel. finally user2 should removed. is there way automate this? maybe behaviour? if not, may consider creating it, since need lot. we made merge behaviour purpose in 2008. it may require tweaking work correctly latest cakephp stable release can find here

asp.net mvc - Binding collections in MVC -

i have view model consists of applicant object , teammember collection. when post model team collection null. i've tried changing collection original ienumarable list didn't make difference. changed controllers edit action accept formcollection , , verified there data in viewmodel["member.firstname"] . i'm lost why binding isn't working. tried clean out code samples as possible i'm confused @ i'm missing. appreciated! view model properties public class myviewmodel { public applicant applicantinfo { get; set; } public list<teammember> teammembers { get; set; } } controller [httppost] public actionresult edit(myviewmodel viewmodel) { // viewmodel.applicantinfo has form data // viewmodel.teammembers = null } view <% using (html.beginform()) {%> <h3> <a href="#">applicant information</a> </h3> <label> city ...

c# - Set IsEnabled Property of ComboBox Based on SelectedItem -

i want enable/disable combobox based on if there item selected in combobox. able working setting trigger on style, overrides custom global style combobox. there way same functionality without losing style? <combobox grid.column="1" grid.row="1" name="analysiscombobox" minwidth="200" verticalalignment="center" horizontalalignment="left" itemssource="{binding path=availableanalysis}"> <combobox.style> <style targettype="{x:type combobox}"> <setter property="isenabled" value="true" /> <style.triggers> <datatrigger binding="{binding selecteditem,elementname=applicationcombobox}" value="{x:null}"> <setter property="isenabled" value="false" /> ...

flash - ActionScript 3 : XML data exhange -

let's say, example, flash file loaded. while loading, retrieves data xml file. if wanted change value in xml, automatically change in glash? if not? there method in actionscript allow change occur instantly after xml file changed? when flash loads in xml file, it's downloading data - it's one-time transaction. if change file, flash retains version downloaded unless tell download again. it sounds want bit more dynamic simple xml config file, right? there ways make flash interact directly server, without using xml dump intermediary. depending on need, might consider looking amfphp flash remoting - allows flash call methods directly on server, , passes typed objects. this, depending on data you're passing around implement server polling flash calls server once every few seconds see if there's new data, or effect? alternately, if need tighter information flow between server , flash might consider setting socket connection. google flash's native so...

iphone - Is there any way to change TextView font type by adding in settings? -

is there way add item settings changes textview font type ? (for ex timesnewroman calibri etc ) in settings there no way, maybe new xcode version, in code easy, can do: [mytextview setfont:[uifont fontwithname:@"trebuchetms" size:14]]; also http://iosfonts.com/ can lot, font names , ios versions available.

drupal - Displaying User Relationships Module Blocks -

i'm unable display of user relationships' auto-created blocks in of sidebars. have tried enabling modules , permissions can think of, no success. block i'm interested in block allow users invited existing relationship (e.g. friend), nor of other blocks display. other drupal blocks , custom blocks display fine. blocks show in blocks listing, , i've tried different ways of configuring them. help, or confirmation has been able latest stable versions of drupal , user relationships module, appreciated. thank you. sorry trouble you, think found problem: me! had incorrect notion (actually hope) "add relationship" block display without allowing users access overall user list. turns out block display if user can select user list of users. i'm sure i'm missing something, seems me weakness of user relationships module. know if friendslist module works similarly? again.

c# - Print content of a javascript tabcontrol: Gridviews -

i've got jquery tabcontrol (4 tabs), each of them control 1 gridview. got button "print". activates javascriptfunction, should build page, containing gridviews. got something, not work: function doprintpage() { mywindow = window.open('', '', 'titlebar=yes,menubar=yes,status=yes,scrollbars=yes,width=500,height=600'); mywindow.document.open(); mywindow.document.writeln("<link href='/styles/layout.css' type='text/css' rel='stylesheet' ></link>"); mywindow.document.write(document.getelementbyid('tabcontainer').innerhtml); mywindow.document.close(); mywindow.focus(); mywindow.print(); return true; } i thought may getelementbyid() , 'tabcontainer' (which contains tabs) or 'tabcontent' (the content of each tab) or 'gridview1' or something, wrong. ain't got clue... solution: func...

Timeout issue making system call in Ruby on Windows XP -

the following code require 'timeout' begin timeout(20) # line 4 result = `hostname` end # line 6 rescue timeout::error puts "timeout" exit end puts "result:" + result # line 12 throws error issue.rb:12:in <main>': undefined local variable or method result' main:object (nameerror) but if comment out timeout element (lines 4 , 6), works fine. have tried using io.popen, io.select etc none of helps. i've used timeout technique in many other areas , worked fine. it doesn't appear related timeout value have experimented larger , smaller values. am using ruby 1.92 on windows xp. appreciated. p.s. original problem not running "hostname" more complex sql server batch job. bonus point, long running system task exceeded timeout automatically killed? have read lots of posts timeout library not honouring timeouts when busy running system tasks? t...

ipad - Cocoa touch SDK 3.2 - How to play video -

possible duplicate: using mpmovieplayerviewcontroller in sdk 3.2 ipad how play video on sdk 3.2 (ipad)? read many questions here talked iphone. example, movieplayer example here http://developer.apple.com/iphone/library/samplecode/movieplayer_iphone/introduction/intro.html that works on 3.1.3 when run on 3.2, doesn't work. so i'm able play video on 3.1.3 using code same code won't run on 3.2 nsstring *moviepath = [[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent:@"movie.mp4"]; mpmovieplayercontroller *movieplayer = [[mpmovieplayercontroller alloc] initwithcontenturl:[nsurl fileurlwithpath:moviepath]]; movieplayer.moviecontrolmode = mpmoviecontrolmodedefault; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(moviefinishedcallback:) name:mpmovieplayerplaybackdidfinishnotification object:movieplayer]; [movieplayer play]; thanks, tee mpmovieplayercontroller doesn't work on ipad...

android - How to register an application as a Home alternative -

i'm building alternative home application (a replacement of standard launcher). there's don't know how make : how register application called when user click on home hard button ? it depends on intent filter: <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.home"/> <category android:name="android.intent.category.default" /> </intent-filter>

c# - Managed form as child of unmanaged HWND -

i need show system.windows.forms.form child window of unmanaged c++ hwnd. c# sdk code retrieves nativewindow: public static nativewindow mainwindow() { diagnostics.process process = diagnostics.process.getcurrentprocess(); if (null == process) return null; intptr handle = process.mainwindowhandle; if (intptr.zero == handle) return null; nativewindow wnd = new nativewindow(); wnd.assignhandle(handle); return wnd; } this how implemented in plug-in: iwin32window rh_wnd = rhino.rhinoapp.mainwindow(); doceditor.show(rh_wnd); this works.... of time. fails first time call code: hwnd error http://www.freeimagehosting.net/uploads/f29bc27823.png call again, works fine. what's going on?!? possibly because rh_wnd null? there atleast 2 cases return null mainwindow(). might idea check iwin32window rh_wnd = rhino.rhinoapp.mainwindow(); if ( rh_wnd != null ) doceditor.show(rh_wnd); and if above stops errors, might want check of above conditio...

html - JQuery check box loop not working -

function generatetermsheet() { var urlstring = "<%= system.web.virtualpathutility.toabsolute("~/mvc/indications.cfc/renderpartialtermsheetview/")%>" $("#termsheetpopup checkbox:checked").each(function(){ alert("clicked"); var json = { id : getguidvalue(), name : $(this).attr("name") } $.ajax({ type: "post", url: urlstring, data: json, success: function(data) { } }); }) } i never see alert appear. if put on every line above is, appears, know it's problem loop of checked boxes i'm guessing. doing right? here div it's looping through: <div id="termsheetpopup"> <div style=...

html - Hosting Website On Dropbox -

hey people, have simple 1 page site have in public dropbox folder, can access public url file. want have site website.com redirect dropbox url url in browser still saying mysite.com. said simple html page doesn't need redirect different domain, 1 file. possible do? read might possible using cname records i'm not sure if how it. thanks. your hosting provider might provide way redirect in frame, preserving domain in browser address bar (i know 123-reg this).

html - jQuery Closing Open Tags -

while trying parse xml file table format, jquery keeps closing opening <tr> tag. there work around this? <script type="text/javascript"> $(document).ready(function(){ $.ajax({ type: "get", url: "sample-data.xml", datatype: "xml", success: parsexml }); }); function parsexml(xml) { $(xml).find("user").each(function() { var id = "#sortable"; $(id).append("<tr>"); $(id).append("<td>" + $(this).find("name").text() + "</td>"); $(id).append("</tr>"); }); } </script> <table id="table" class="tablesorter"> <thead> <tr> <th>test</th> </tr> </thead> <tbody id="sortable"> </tbod...

Could not load "my-icon.png" image referenced from a nib (iPhone) -

i receiving following error message: 2011-02-11 14:47:13.815 myproject[13177:207] not load "icon-troubleshoot.png" image referenced nib in bundle identifier "com.mycompany.myproject" this file old file being used before, has been deleted. far know icon-troubleshoot.png not used anywhere in project. tried cleaning , rebuilding, emptying caches didn't work. searching string troubleshoot textual reference , "contains" selected returned nothing. know how can find causing error? as far know search tool of x-code not search inside xib files that's why search returns nothing. anyway it's probable there's still reference in xib file somewhere. because xib files xml, if don't want check them manually, try open xib text editor textmate , perform global text search on content .png filename. hope helps. ciao!

How to use capistrano for a non-rails app? just a static html site -

i have been using capistrano on rails site, , set did usual: capify . now how use on static html site publish? check out railsless-deploy gem.

php - Jquery failure after site went live -

edit: posted head code edit 2: clarification on php i have been designing site weeks using jquery. don't have local server or testing server created directory through ftp, '/testing'. working great in testing directory. i attempted go live tonight moving files in '/testing' root directory , changed file paths , script sources accordingly. site loads, related jquery non-functional. javascript console gives errors of (just example plugin): '$.os.name' not function i'm @ loss do. changed paths referencing jquery library, installed fresh copy of jquery (to new directory), etc. there wordpress installation in different directory '/blog'. i've read compatibility issues wordpress, seems related using jquery inside wordpress, not. here head code: <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link href="main.css" rel="stylesheet" typ...

flash - Loading image twice via Actionscript3? -

i'm trying use infinite scroll as3 discuss in this question . i'm developing using flashcs5 ide. the absolutely last thing need load large background image ("header_bg_vert.jpg") externally after rest of movie has loaded, instead of requiring entirety of animation load beforehand (or preloading header animation in). my as3 below. "infinite loop" works placing 2 copies of same seamless image end-to-end, moving second image front after scrolls off screen -- currently, code displays 1 copy of image. what's wrong it? also, best way of accomplishing this? many thanks. stop(); //load bg image var request:urlrequest = new urlrequest("header_bg_vert.jpg"); var s1:loader = new loader(); var s2:loader = new loader(); s1.contentloaderinfo.addeventlistener(progressevent.progress, loadprogress); s1.contentloaderinfo.addeventlistener(event.complete, loadcomplete); s2.contentloaderinfo.addeventlistener(progressevent.progress, loadprogress); s2....

linux - Shared Memory and Process Sempahores (IPC) -

this extract advanced liniux programming: semaphores continue exist after processes using them have terminated. last process use semaphore set must explicitly remove ensure operating system not run out of semaphores.to so, invoke semctl semaphore identifier, number of semaphores in set, ipc_rmid third argument, , union semun value fourth argument (which ignored).the effective user id of calling process must match of semaphore’s allocator (or caller must root). unlike shared memory segments, removing semaphore set causes linux deallocate immediately. if process allocate shared memory, , many process use , never set delete (with shmctl), if them terminate, shared page continues being available. (we can see ipcs). if process did shmctl, when last process deattached, system deallocate shared memory. so far (i guess, if not, correct me). what dont understand quote did, first say: "semaphores continue exist after processes using them have terminated." , then: ...

asp.net mvc - Should the model be responsible for holding lists that will ultimately populate dropdownlists in the view? -

this might similar asp.net mvc - populate commonly used dropdownlists . i want populate dropdownlists. of static data. of comes database. couple of times found myself forgetting call code populates lists , sets viewbag accordingly. worth adding unit test this. way think suits unit test if place in model/service. there best practice kind of thing? i'd suggest data contained within model perhaps constructed html.helper method. way, keep plumbing markup out of view , leave controller free invoke neccesary view , model. you of course hand off partialview <ilist<selectlist>> model. cats , skin :)

c# - .NET : StreamReader does not recognize ° characters -

i trying run regex locate degree characters (\u00b0|\u00ba degrees in addition locating other form of ' --> \u00b4). reading latitude , longitude dms coordinates one: 12º30'23.256547"s the problem way reading file can manually inject string 1 below (format latitude, longitude, description): const string myteststring = @"12º30'23.256547""s, 12º30'23.256547""w, somewhere"; and regex matching expected - can see º values where, when using streamreader, see � unrecognized characters (the º symbol being included 1 of unrecognized characters) i've tried: var sr = new streamreader(dlg.file.openread(), encoding.utf8); var sr = new streamreader(dlg.file.openread(), encoding.unicode); var sr = new streamreader(dlg.file.openread(), encoding.bigendianunicode); in addition default ascii. either way read file, end these special characters. advice appreciated!! you need identify en...

c - In a process using lots of memory, how can I spawn a shell without a memory-hungry fork()? -

on embedded platform (with no swap partition), have application main process occupies of available physical memory. problem want launch external shell script application, using fork() requires there enough memory 2x original process before child process (which execl smaller) can created. so there way invoke shell script c program without incurring memory overhead of fork()? i've considered workarounds such having secondary smaller process responsible creating shells, or having "watcher" script signal touching file or somesuch, i'd rather have simpler. some unix implementations give vfork (part of single unix spec) fork except shares stuff parent. with vfork , there limited number of things can in child before calling exec overwrite address space process - that's vfork built for, minimal copy version of fork fork/exec sequence.

Application not running on Rails 2.3.8 and Ruby 1.8.6 -

i have upgrade rails 2.3.8 , ruby 1.8.6. have managed start existing application when clicking on link on page, give me error "stack level deep" following stacktrace: /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/buffered_logger.rb:98:in `flush' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/buffered_logger.rb:96:in `synchronize' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/buffered_logger.rb:96:in `flush' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/buffered_logger.rb:116:in `auto_flush' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/buffered_logger.rb:65:in `add' /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/buffered_logger.rb:72:in `debug' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb:198:in `log_info' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/activ...