ref: 03baa934bacdbf48e9e8e94711e6687e6bb1fb30
dir: /fn/
# audio # playback samples from microphone (needs setup) fn admp{ dd -bs 4x441 </dev/audio >/dev/audio } # decode audio files(s) and visualize with pplay(1) fn pcm{ @{font=/lib/font/bit/terminus/unicode.12m.font; o=(); while(~ $1 -?) o=($o $1) && shift; play -o /fd/1 $* >[2]/dev/null | audio/pplay -b $o}} # same, without temporary variables (???) fn ppcm{ @{*=($*($#*) $* $#*) font=/lib/font/bit/terminus/unicode.12m.font play -o /fd/1 $1 >[2]/dev/null | audio/pplay -b $*(2-$*($#*))} } # convert a wolf3d digital audio lump fn wpcm{ audio/pcmconv -i u8c1r7000 -o s16c2r44100 <$1 >/dev/audio } # indispensible fn W{ games/wadfs /sys/games/lib/doom/d2/doom2.wad } fn all2mp3{ for(i in `{walk -f | grep '\.wav$'}) 2mp3 <$i > `{echo $i | sed s/wav/mp3/} } fn 2pcm{ play -o /fd/1 $* >[2]/dev/null } fn TD2{ audio/stretch -r 0.8909 -s } fn TD4{ audio/stretch -r 0.7937 -s } fn SD{ audio/stretch -r 1.1 } fn SU{ audio/stretch -r 0.9 } fn td2{ play -o /fd/1 $*(2-) | audio/stretch -r 0.8909 -s | audio/stretch -r $1 | audio/pplay } fn usbrec{ dd -if /dev/audioin -bs 1764x2 | audio/flacenc } # freqgraph.c from umbraticus fn usbgraph{ dd -if /dev/audioin -bs 1764x2 | freqgraph >/dev/null } # play(1) auxiliaries # skip to next track fn fw{ for(i in `{fpl}) echo 'echo kill >/proc/'^$i^/note } # pause playback fn sto{ for(i in `{fpl}) echo 'echo stop >/proc/'^$i^/ctl } # resume playback fn sta{ for(i in `{fpl}) echo 'echo start >/proc/'^$i^/ctl } # shortcuts for first play(1) process fn Fw{ fw | tail -1 | rc } fn Sta{ sta | tail -1 | rc } fn Sto{ sto | tail -1 | rc } # recursively list all files in arguments and play shuffled list forever fn shp{ *=`"{walk -f $*}; while(! ~ $#* 0) play `' '{echo -n $* | shl} |[2] sed -u '/^COVERART/d'} # shuffle play pre-arranged list of files forever fn shpp{ status='' while(~ $status '') play `{shl <$1} } # graphics # display wolf3d graphic lump using wpic and extracted picheader file fn wp{ a=(`{dd </n/tapefs/piched000.^$2 >[2]/dev/null -bs 4 -count 1 -skip $1 | xd -s -2d | sed 's/ 0+/ /g'}) wpic -x $a(2) -y $a(3) $*(3-) /n/tapefs/pic^$1^.$2 | page a=() } # programming # dump assembly fn asm{ 6c -FTVwSo /dev/null $1 } # ridiculous shortcut for one-file program builds fn b{ mk -f <{echo ' </$objtype/mkfile OFILES='$1'.$O </sys/src/cmd/mkone'} } # dump c function body (thanks aiju) fn catfn{ sed -n '/^'$1'\(/ {x;p;x;};/^'$1'\(/,/^}/p;h' *.c } # # file processing # recursive chown implementation, given fs access fn chown{ for(i in `' '{walk $*(2-)}){ chgrp $1 $i && chgrp -o $1 $i } } # lower filenames fn lw{ for(i in $*) mv $i `' '{echo $i | tr A-Z a-z} } # printing # show troff document fn doc{ troff -ms <$1 | page } # show ps document fn doc2{ echo `{doctype $1} '| lp -dstdout | page' | rc } # shortcuts # connect to aijuboard fn aib{ echo b115200 >/dev/eiaU*.1ctl && con -r /dev/eiaU*.1 } # ircs usage fn ii{ ircx -t '#cat-v' } # quake2 crbot fn q2cr{ qk2 -g crbot $* +set deathmatch 1 +set ctf 0 } # quake2 ctf fn q2f{ qk2 -g ctf $* +set ctf 1 } # launch graphical program on a unix host fn ff{ A=$*(2-); ssh $user@$1 'DISPLAY=:0 '^$"A^' >/dev/null 2>&1'; A=() } # defunct linux script shortcut #fn lnx{ linux -r $home/mroot /bin/bash -i } # vdir(1) fn ‡{ vdir $* } fn font{ echo -n /lib/font/bit/terminus/unicode.12m.font >/env/font } # rio # clear window fn clr{ {}>/dev/text } # get current window dimensions fn wsz{ dd -bs 4x12 -count 1 </mnt/wsys/wctl >[2]/dev/null | awk '{print $3-$1, $4-$2}' } # sys # bind hg repo to root and execute hg command fn hg{ bind -ac /dist/plan9front /; fn hg; hg $* } fn git{ bind -ac /dist/plan9front / } # hangup connections to given hosts fn nctl{ echo 'echo hangup >/net/'^`{netstat -n|sed -n 's,^([^ ]+) +([^ ]+) +[^ ]+ +[^ ]+ +[^ ]+ +'$1'.*,\1/\2/ctl\;,p'} } # show announced ports and established connections fn netopn{ netstat -n | grep 'Established|Listen' } # get list of /proc dirs for matched process names fn pn{ ps -n | sed -n '/.* '$1'$/s,[^ ]+ +([0-9]+).*,/proc/\1/,p' } # grep process table fn psd{ *=`{echo $"* | sed 's/ /|/g'}; ps -an | grep $* } # reset vga(8) state with vesa fn vr{ @{rfork n; aux/realemu; aux/vga -lm vesa $vgasize} } # mail # attempt at quoting fn qt{ cat | sed 's/^/> /' } # webshit # simple ninetimes fn 9t{ hget http://code.9front.org/hg/plan9front | htmlfmt | sed '1,6d;$d;/^[A-Za-z,]+ [0-9][0-9] [A-Za-z]+ 20[0-9][0-9] [0-9:]+ [0-9\+\-]+/{N;s/\n/ /;}' } # query english vocabulary fn geq{ plumb http://www.dictionary.com/browse/^$1 } # query german vocabulary fn gq{ plumb 'http://www.dict.cc/?s='^$* } # query weather fn wth{ plumb http://wttr.in/$1 } # trials from projects #fn ss{ sawk '{x[NR]=$4} END{freq(x); for(i in ans) print i, ans[i] | "sort -n"}' db0 } #fn wp{ # a=(`{dd </n/tapefs/piched000.^$2 >[2]/dev/null -bs 4 -count 1 -skip $1 | xd -s -2d | sed 's/ 0+/ /g'}) # wpic -x $a(2) -y $a(3) $*(3-) /n/tapefs/pic^$1^.$2 | page # a=() #} #fn shirc{ aux/listen1 -vp 1 tcp!*!17066 /bin/exportfs -R -r $home/lib -P <{echo '+ ^/k?irc$'} } #fn itest{ @{cd p/igfx/igdump; aux/vga -Vipm auto -l $vgasize >$home/v/vga >[2=1]; dumpsnb.rc | prettysnb.rc >>/tmp/snbv} } #fn idump{ @{cd p/igfx/igdump; dumpsnb.rc | prettysnb.rc > $home/vgam} } #fn gd{ *=`{echo $"* | sed 's/ /|/g'}; @{cd $home/p/not/ger; grep -i $* *} } #fn gq2{ # {for(i in $*) hget 'http://dict.tu-chemnitz.de/dings.cgi?query='^$i} | # sed -n 's/^.*onclick="return vi\(''([^)]+),[^,]+,''de'',''en'',this\).*/\1/p' | # sed 's/''//g;s/,/ → /' #} #fn ftp11{ ftpfs -/na anonymous@anonymous -o UNIX u11 } #fn ctopdf{ ps2pdf <{lp -dstdout -l100 -x0 -y0 -fCW.7 <{cat $*}} /fd/1 | pump } fn chi{ cd $home/p/sm2/cin && truetypefs && plumber && font=/n/ttf/unifont.ttf.16/font rio; unmount /mnt/plumb } fn chidiff{ diff <{ls *.pdf | sort} <{awk '{print $5}' db0 | sort} | sed -n '/^[0-9]/d;s/< /2.5 0 0 0 /p' }