Posts

objective c - Launching app from root account -

i developing cocoa gui app has objective-c daemon. daemon launched launchdaemon, gui launched using loginitems each user. when update deployed need update daemon, simple, , update gui. able exit gui, replace app, , relaunch on each user account running on. daemon of course running root. how can either: 1) root, quit , re-launch app in user's interface? 2) root, quit , re-launch particular loginitem each user logged it? i have tried searching , there lots of discussions including similar question , there doesn't appear working solution available. any appreciated. i believe nsdistributednotificationcenter should work this. note using nsdistributednotificationcenter communicate between processes in different user accounts not, in , of itself, require root privileges. to coordination between user accounts, might distinguish instance of gui app , daemon active , in control, , instances passive. can use nsworkspace's notifications (nsworkspacesessiondid...

javascript - assign value to select box ( form validation ) -

i creating form validation, , have fields working great. trickyness seems arise parsing value select box i know how assign value within form element, have: <select id="sms" name="sms" class="medium"> <optgroup label="sms alerts"> <option value="">please choose</option> <option value="1">yes</option> <option value="0">no</option> </optgroup> </select> but not sure within js select box. currently field have: $("#mobile").blur(function() { if(validate_form_field($(this), $(this).val().length>9)) { mobile_passed = true; } else { mobile_passed = false; } }); essentially, want validate value ...

Bubble Sort logical error VB.NET -

this program suppose sort records(in arysort) in ascending order last name(index 1 in arytemp , arytemp2) , place result in list box on old, preloaded, unsorted records. it sorts them strangely, have click multiple times ascending button actual sort result suppose clicking button once. why doesn't sort items single mouse click? the source: public class form1 dim file_name string = "students.txt" dim numberofrecords integer 'total number of records private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load if system.io.file.exists(file_name) = true dim objreader new system.io.streamreader(file_name) while objreader.peek() <> -1 lstbox.items.add(objreader.readline) numberofrecords += 1 loop objreader.close() end if end sub private sub btnascending_click(byval sender system.object, byval e system.even...

python truncate text around keyword -

i have string , want search keyword or phrase , return portion of text before , after keyword or phrase. google talking about. here string grabbed web: "this filter truncates words original truncate words django filter, instead of being based on number of words, it's based on number of characters. found need when building website i'd have show labels on small text boxes , truncating words didn't gave me best results (and truncating character is...well...not elegant)." now lets want search phrase building website , output this: " ... need when building website i'd have show ... " edit: should have made more clear. has work on multiple strings / phrases, not one. building on answers of others (especially cababunga's) function, take 25 (or many) characters, stopping @ last word boundary, , provide nice match: import re def find_with_context(haystack, needle, context_length, escape=true): if escape: needle =...

PowerShell Close File/Delete File After Emailing via .NET -

i'm stuck @ end of script working on file emailed out before being deleted. except.. file seems still opened, smtp client, error when try delete it. of course restarting shell let me delete it, thats not point. ;-) point i'd create it, email it, delete it, in 1 script. the error: cannot remove item c:\temp\myfile.csv: process cannot access file 'c:\temp\myfile.csv' because being used process. code: $emailfrom = 'noreply@localhost' $emailto = 'aaron@localhost' $smtpserver = 'localhost' $filename='myfile.csv' $filepathname='c:temp\' + $filename $subject = 'emailing: ' + $filename $body = 'this message been sent following file or link attachments: ' + $filename $msg = new-object net.mail.mailmessage $att = new-object net.mail.attachment($filepathname) $smtp = new-object net.mail.smtpclient($smtpserver) $msg.from = $emailfrom $msg.to.add($emailto) $msg.subject = $subject $msg.body = $body $msg.at...

c - Buffer Overflow Problem -

i trying run buffer overflow example run code, problem when try run code buffer overflow, windows throws prompt stating "program has stopped working, windows checking solution program. when try make sure has overflow 1 byte. program runs, doesn't pause command window in order me see segmentation fault error address. understanding need in order change , make run desired window passed parameter.here simple program. #define buf_len 5 int main(int argc, char **argv) { char buf[buf_len]; if (argc > 1) { strcpy(buf, argv[1]); } return 0; printf(buf); system("pause"); } the problem lies fact buffer overflow behavior not standardized - example may refer older version of windows, still printed error address, or different operating system. additionally, not buffer overflows cause program crash - depends on data written where. small buffer overflows, may overwriting other local variables or padding space, instead of essential program execution (like f...

linux - How to send three pipes of data over ssh? -

i have bash script on remote host produces large amount of data on fd=3 possibly interesting data on stdout , stderr. want to: log stdout , stderr file on local machine. write data on fd=3 stdout on local machine. here's how done if big script local: exec 3> >(cat) ./big_script.sh -o /dev/fd/3 2>&1 >big_script.log exec 3>&- however, want run big_script.sh on remote machine , have 3 pipes (fd=1, fd=2, , fd=3) come out of ssh program separate. best way that? nc (netcat) , tunnels ? can make kinda log radio on net way!