// or more concisely var sys = require('sys') var exec = require('child_process').exec; function puts(error, stdout, stderr) { sys.puts(stdout) } exec("ls -la", puts);
observed: gedit starts with a new file called notes050210.txt in the ~/m directory.
Install and run a seperate instance of opera including tsocks -
# download and unzip opera ... % sh install.sh --prefix=/opt/opera-socks
# run opera with profile prefix and tsocks: % tsocks /opt/opera-socks/bin/opera -pd socks # opera does not support sockets directly # remember that dns is not routed over socks (afaik)
% cat /etc/tsocks.conf local = 10.0.0.0/255.255.255.0
server = 10.0.0.204 server_port = 1080 server_type = 5
BASH: Re-run previous command performing global substitution -
Re-run the previous command (accessed via !!) replacing 'foo' with 'bar' globally.
!!:gs/foo/bar/
Launch parallel shell process -
Bash in not specially well suited to run background jobs, but it can be accomplish. This is a simple parallel process launcher:
# run_parallel NPROCESS FACTORY # # Run N parallel proceses, wait until EOF and all running processes are finished # # # FACTORY is a process/function that returns (using stdout) the command to run # # The status code of FACTORY is interpreted like this: # # 0: There is more data # != 0: There is no more data to process # run_parallel() { NPROCESS=$1 shift
PIDS=() EOF=0 while test $EOF = 0 -0 ${#PIDS[*]} -ne 0; do if test $EOF = 0 -a ${#PIDS[*]} -lt $NPROCESS; then if ! COMMAND=$("$@"); then debug "EOF" EOF=1 fi if test "$COMMAND"; then $COMMAND & PID=$! debug "starting process: $@ ($PID)" PIDS[$PID]=$PID fi fi
debug "active processes: ${PIDS[*]}" sleep 0.5
for PID in ${PIDS[*]}; do if ! check_process $PID; then wait $PID unset PIDS[$PID] debug "process finished: $PID" fi done done }
while inotifywait "$@"; do bash -c "$COMMAND" || { echo "retcode: $?"; } done
open gem with textmate -
open_gem is a rubygem. It adds a Gem Command to easily open a ruby gem with an editor. The Editor is specified with the -c option (or in $GEM_OPEN_EDITOR or $EDITOR). After Installation