Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
function throw(){
local msg="${1}"
_ERR_MSG_="$msg"
kill -s USR2 $BASHPID
}
@matlinuxer2
matlinuxer2 / gist:2925005
Created June 13, 2012 16:07
embed python into shell script as a pipe function
#!/usr/bin/env bash
function pipe_in_python() {
python -c "$(cat <<EOPY
import sys
for line in sys.stdin:
print line.replace( 'asdf', 'ASDF' ),
EOPY
)"
tmp=$(cat <<EOPY
import sys
for line in sys.stdin:
print line.replace( 'asdf', 'ASDF' )
print(line)
EOPY)
echo "asdf.asdf.asdf.e" | python -c "$tmp"
@matlinuxer2
matlinuxer2 / gist:1391322
Created November 24, 2011 13:16
timely random
#!/usr/bin/env bash
function test_num(){
sleep $(( $RANDOM % 5 ))
echo $i
}
function echo_num(){
for (( i=1; i<=49; i++ ))
do