ref: 2eb32908f55cdbf2c67cc31d0b0e9adbca1ca14c
author: sl <sl@x1yg3>
date: Sat Jun 21 22:22:10 EDT 2025
initial import
--- /dev/null
+++ b/accel
@@ -1,0 +1,2 @@
+#!/bin/rc -x
+echo -n accelerated $1 > '#m/mousectl'
--- /dev/null
+++ b/backup
@@ -1,0 +1,58 @@
+#!/bin/rc
+# 2022-04-29T18:39:24-04:00
+rfork en
+if(~ $#boss 0 || ~ $boss '')
+ boss=sl@stanleylieber.com
+log=/usr/sl/lib/backup
+date=`{date}
+s=$1
+d=$2
+args=-U
+rnd=$pid
+fn error{
+ date=`{date}
+ echo $date $* >>$log
+ exit
+}
+if(! ~ `{ps -a | grep -s $1} ''){
+ echo backup: $1 already in progress. | mail -s 'backup: '^$1^' already in progress.' $boss
+ error backup: $1 already in progress.
+}
+if(~ $s /n/4ess/* || ~ $d /n/4ess/*)
+ rimport -c -s 4ess.$user.$rnd 4ess / /n/4ess >>[2]$log || error rimport 4ess failed
+if(~ $s /n/5ess/* || ~ $d /n/5ess/*)
+ rimport -c -s 5ess.$user.$rnd 5ess / /n/5ess >>[2]$log || error rimport 5ess failed
+if(~ $s /n/9front/* || ~ $d /n/9front/*)
+ rimport -c -s 9front.$user.$rnd 9front / /n/9front >>[2]$log || error rimport 9front failed
+if(~ $s /n/auth/* || ~ $d /n/auth/*)
+ rimport -c -s auth.$user.$rnd auth / /n/auth >>[2]$log || error rimport auth failed
+if(~ $s /n/catv/* || ~ $d /n/catv/*)
+ rimport -c -s catv.$user.$rnd catv / /n/catv >>[2]$log || error rimport catv failed
+if(~ $s /n/gaff/* || ~ $d /n/gaff/*)
+ rimport -c -s gaff.$user.$rnd gaff / /n/gaff >>[2]$log || error rimport gaff failed
+if(~ $s /n/rachael/* || ~ $d /n/rachael/*)
+ rb=rachael.$pid sshfs -s $rb -m /n/rachael -r / sl@rachael.inri.net
+if(~ $s /n/fs/* || ~ $d /n/fs/*){
+ if(~ `{cat /dev/sysname} deckard)
+ bind / /n/fs
+ if not
+ rimport -c -s fs.$user.$rnd deckard.inri.net / /n/fs >>[2]$log || error rimport fs failed
+}
+if(~ $s /n/osuny/* || ~ $d /n/osuny/*)
+ rimport -c -s osuny.$user.$rnd osuny / /n/osuny >>[2]$log || error rimport osuny failed
+{
+ echo $date
+ echo $0 $*
+} >>$log
+if(test -d $s){
+ mkdir -p $d
+ disk/mkfs $args -v -z 4096 -s $1 -d $d <{echo +} >[2=1] | tee -a $log
+}
+if not if(test -f $s){
+ mkdir -p $d
+ fcp $s $d >[2=1] | tee -a $log
+}
+for(i in 4ess 5ess 9front auth catv fs gaff osuny rachael){
+ if(~ $s /n/$i/* || ~ $d /n/$i/*)
+ rm -f /srv/$i.$user.$rnd
+}
--- /dev/null
+++ b/bg
@@ -1,0 +1,9 @@
+#!/bin/rc
+# 2018-08-07T23:05:01-0400
+rfork e
+raw=$1
+file=`{basename $raw}
+if(~ $raw http*//*)
+ hget $raw >$bg/img/bg/$file
+if not
+ fcp $raw $bg/img/bg/^`{date -n}^.^$file
--- /dev/null
+++ b/crip
@@ -1,0 +1,68 @@
+#!/bin/rc
+# 2016-10-22T22:34:59-0400
+# Repack .cbr as .cbz. Try to fix the file names.
+rfork e
+fn fixname{
+ sed '
+ s/( |\+|%C2)/_/g;
+ s/(\(|\)|\'')//g;
+ s/%..//g;
+ s/(__|___)/_/g;
+ s/_-_/-/g;
+ '
+}
+fn usage {
+ echo 'usage: crip [ -cdnrz ]' >[1=2]
+ exit usage
+}
+zip=(zip -v -f)
+switch($1){
+case -c
+ for(i in *.cbr){
+ wdir=`{pwd}
+ file=`{echo $"i | urlencode | fixname | sed 's/\.cbr$/\.cbz/g'}
+ dir=`{echo $"file | sed 's/\.cbz$//g'}
+ mkdir crip.$file &&
+ cd crip.$file &&
+ unrar x $"wdir'/'$"i &&
+ crip -n &&
+ cd $wdir &&
+ mv crip.$file $dir &&
+ eval $zip $file $dir &&
+ rm -r $dir &&
+ rm $"i &&
+ echo $file
+ }
+case -d
+ for(i in `{ls | grep -v -e '\.cb(r|z)'}){
+ file=`{echo $"i | urlencode | fixname}
+ if(! ~ $i $file)
+ mv $"i $file
+ eval $zip $file.cbz $file &&
+ rm -rf $file
+ echo $file.cbz
+ }
+case -n
+ for(i in *){
+ file=`{echo $"i | urlencode | fixname}
+ if(! ~ $i $file)
+ mv $"i $file
+ echo $file
+ }
+case -r
+ for(i in *.rar){
+ file=`{echo $"i | urlencode | fixname | sed 's/\.rar$/\.cbr/g'}
+ if(! ~ $i $file)
+ mv $"i $file
+ echo $file
+ }
+case -z
+ for(i in *.zip){
+ file=`{echo $"i | urlencode | fixname | sed 's/\.zip$/\.cbz/g'}
+ if(! ~ $i $file)
+ mv $"i $file
+ echo $file
+ }
+case *
+ usage
+}
--- /dev/null
+++ b/df
@@ -1,0 +1,2 @@
+#!/bin/rc
+du -h /root | tail -1
--- /dev/null
+++ b/fromdos
@@ -1,0 +1,7 @@
+#!/bin/rc
+
+for(i) {
+echo ',s/ //g
+w
+q' | ed $i >/dev/null
+}
--- /dev/null
+++ b/img
@@ -1,0 +1,101 @@
+#!/bin/rc
+# 2022-05-01T18:49:30-04:00
+# upload an image to http://img.stanleylieber.com
+rfork e
+argv0=$0
+barf=/usr/sl/www/werc/sites/img.stanleylieber.com
+if(! ~ `{cat /dev/sysname} gaff)
+ barf=/n/gaff^$barf
+fn usage {
+ echo usage: $argv0 '[ -f file] [ -l link ] [ -t tags ]' >[1=2]
+ exit usage
+}
+file=()
+img=()
+link=()
+tags=()
+while(~ $1 -*){
+ switch($1){
+ case -f
+ file=$2
+ shift
+ case -l
+ link=$2
+ shift
+ case -t
+ tags=$2
+ shift
+ case *
+ usage
+ }
+ shift
+}
+if(! ~ $#* 0)
+ usage
+if(~ $#file 1){
+ a_id=`{echo `{ls -p $barf/src | sort -n | tail -1}^+1 | bc}
+ if(~ $#a_id 0)
+ a_id=1
+ while(test -d $barf/src/$a_id)
+ a_id=`{echo $a_id^+1 | bc}
+ a_dir=$barf/src/$a_id
+ mkdir -p $a_dir/img $a_dir/tags
+ date >$a_dir/date
+ echo $"link >$a_dir/link
+ a_tags=`{echo $"tags | sed 's/[^A-Za-z0-9_\- ]//g'}
+ ifs=' '{a_tags=`{echo -n $a_tags}}
+ {
+ t=1
+ while(test $t -le $#a_tags){
+ >$a_dir/tags/$a_tags($t)
+ t=`{echo $t^+1 | bc}
+ }
+ }
+ for(i in $a_tags)
+ echo $a_id'/tags/'$i >>$barf/tags
+ nimg=$a_dir/img/^`{date -n}^.^`{echo $"file |
+ sed 's/^.*\.(gif|GIF)$/gif/g;
+ s/^.*\.(jpg|jpeg|JPG|JPEG)$/jpg/g;
+ s/^.*\.(png|PNG)$/png/g;
+ s/^.*\.(tif|TIF|tiff|TIFF)$/tif/g'
+ }
+ thumb=$a_dir/img/small.^`{basename $nimg | sed 's/\..*$//g'}^.png
+ switch($file){
+ case http*
+ hget $"file >$nimg
+ case *
+ fcp $"file $nimg
+ }
+ switch($nimg){
+ case *.bmp
+ cmd=bmp
+ case *.gif
+ cmd=gif
+ case *.ico
+ cmd=ico
+ case *.jpg
+ cmd=jpg
+ case *.png
+ cmd=png
+ case *.tif
+ cmd=tif
+ case *.tga
+ cmd=tga
+ }
+ eval $cmd -9et <$nimg | resample -x 500 | topng >$thumb
+ for(i in `{du -a $a_dir | sed 's/^.* //g'}){
+ chgrp www $i
+ chmod 775 $i
+ }
+ echo -n http://
+ echo -n `{basename $barf}
+ echo -n /src/$a_id/img/
+ echo `{basename $nimg}
+}
+if not {
+ hpost -u https://img.stanleylieber.com -p / fake:fake url: submit:add a_func:add_post a_img:$img a_link:$link a_tags:$tags |
+ grep -e 'img.stanleylieber.com\/src\/' |
+ sed 1q |
+ sed 's/^.........//' |
+ sed 's/" target.*$//g'
+}
--- /dev/null
+++ b/r
@@ -1,0 +1,56 @@
+#!/bin/rc
+# 2025-04-15T21:42:41-04:00
+# launch rio.
+# copy this file to $home/bin/rc and modify to suit.
+# use with: http://plan9.stanleylieber.com/rc/tobit
+. /$cputype/mkfile
+scr=(`{cat /dev/draw/new >[2]/dev/null})
+w=$scr(11)
+h=$scr(12)
+switch($w){
+case 28*
+ font=/lib/font/contrib.bit/hugevga/unicode.font
+case 21* 22* 25*
+ #font=/lib/font/contrib.bit/kurinto/kurinto.18.mono.font
+ #font=/lib/font/contrib.bit/gallant/unicode.22.font
+ #font=/lib/font/bit/fixed/unicode.10x20.font
+ #font=/lib/font/bit/lucida/unicode.10.font
+ font=/lib/font/bit/lucidasans/unicode.10.font
+case *
+ font=/lib/font/bit/vga/unicode.font
+}
+truetypefs
+switch($*){
+case -t
+ bind $home/lib/rio.theme.orig $home/lib/rio.theme
+ riocmd=(rio.themes)
+case -ta
+ bind $home/lib/rio.theme.amber $home/lib/rio.theme
+ riocmd=(rio.themes)
+case -tf
+ bind $home/lib/rio.theme.fairlight $home/lib/rio.theme
+ riocmd=(rio.themes)
+case -tg
+ bind $home/lib/rio.theme.green $home/lib/rio.theme
+ riocmd=(rio.themes)
+case -tmb
+ bind $home/lib/rio.theme.black $home/lib/rio.theme
+ riocmd=(rio.themes)
+case -tr
+ riocmd=(rio.themes)
+ bind $home/lib/rio.theme.tron $home/lib/rio.theme
+case -ts
+ riocmd=(rio.themes)
+ bind $home/lib/rio.theme.sigrid $home/lib/rio.theme
+case *
+ riocmd=(rio $*)
+ exec $riocmd -i $home/lib/riostart
+}
+#exec $riocmd -B <{tobit $riob} -i $home/lib/riostart # old
+if(~ $riocmd rio.themes){
+ riob=`{basename `{fortune <{hget http://bg.stanleylieber.com/index}}}
+ ramfs -m /n/bg
+ hget http://bg.stanleylieber.com/img/bg/$riob >/n/bg/$riob &&
+ tobit /n/bg/$riob >/n/bg/bg.img
+}
+exec $riocmd -i $home/lib/riostart
--- /dev/null
+++ b/rag
@@ -1,0 +1,8 @@
+#!/bin/rc
+rfork e
+raw=$1
+file=`{basename $raw}
+if(~ $raw http*//*)
+ hget $raw >$rag/img/$file
+if not
+ fcp $raw $rag/img/^`{date -n}^.^$file
--- /dev/null
+++ b/sparkline
@@ -1,0 +1,23 @@
+#!/bin/rc
+
+rfork e
+
+if (~ $#* 0) {
+ echo 'usage: '$0' n [n...]' >[1=2]
+ exit usage
+}
+
+min=$1
+max=$1
+
+for (i in $*) {
+ if (test $i -lt $min)
+ min=$i
+ if (test $i -gt $max)
+ max=$i
+}
+
+for (i in $*) {
+ q=`{hoc -e 'int(('$i' - '$min') / (('$max' - '$min') / 8))'}
+ echo -n $q | tr 012345678 ▁▂▃▄▅▆▇██
+}
--- /dev/null
+++ b/t
@@ -1,0 +1,5 @@
+#!/bin/rc
+if(~ $service unix)
+ transmission-cli $*
+if not
+ ip/torrent -pv $*
--- /dev/null
+++ b/tobit
@@ -1,0 +1,25 @@
+#!/bin/rc
+rfork e
+switch($1){
+case *.bmp *.BMP
+ ext=bmp
+case *.gif *.GIF
+ ext=gif
+case *.ico *.ICO
+ ext=ico
+case *.jpg *.jpeg *.JPG *.JPEG
+ ext=jpg
+case *.png *.PNG
+ ext=png
+case *.ppm *.PPM
+ ext=ppm
+case *.tga *.TGA
+ ext=tga
+case *.tif *.tiff *.TIF *.TIFF
+ ext=tif
+case *.v210 *.V210
+ ext=v210
+case *.yuv *.YUV
+ ext=yuv
+}
+eval $ext -9t $1
--- /dev/null
+++ b/todos
@@ -1,0 +1,8 @@
+#!/bin/rc
+
+for(i) {
+echo ',s/^$/ /g
+,s/[^ ]$/& /g
+w
+q' | ed $i >/dev/null
+}
--- /dev/null
+++ b/toface
@@ -1,0 +1,30 @@
+#!/bin/rc
+# 2015-11-20T16:44:57-0500
+rfork e
+ext=`{echo $1 | tr A-Z a-z}
+switch($ext){
+case *.bmp
+ cmd=bmp
+case *.gif
+ cmd=gif
+case *.ico
+ cmd=ico
+case *.jpg *.jpeg
+ cmd=jpg
+case *.png
+ cmd=png
+case *.ppm
+ cmd=ppm
+case *.tga
+ cmd=tga
+case *.tif *.tiff
+ cmd=tif
+case *.v210
+ cmd=v210
+case *.yuv
+ cmd=yuv
+case *.bit
+ iconv -c m8 $1 | resample -x 48 -y 48
+ exit
+}
+eval $cmd -c $1 | iconv -c m8 | resample -x 48 -y 48
--- /dev/null
+++ b/top
@@ -1,0 +1,96 @@
+#!/bin/rc
+# top
+rfork en
+
+flagfmt='d interval,m maxlines'
+args=''
+
+old=/tmp/top.$pid.old
+new=/tmp/top.$pid.new
+out=/tmp/top.$pid.out
+
+int=2
+max=20
+len=()
+
+fn usage{
+ aux/usage
+ exit usage
+}
+fn isfloat{
+ echo $1 | grep -s '^[0-9\.]+$'
+}
+fn isnum{
+ echo $1 | grep -s '^[0-9]+$'
+}
+fn get{
+ grep . */status |
+ sed '
+ s!/status:! !
+ s! +! !g
+ '
+}
+fn clear{
+ awk 'END { for(i = 0; i < '$len'; i++) printf "\x08" }' </dev/null
+}
+fn sigint{
+ rm -f $old $new $out
+ exit
+}
+fn top{
+ get | tee $new | join - $old |
+ awk '
+ {
+ newusr = $5
+ newsys = $6
+ oldusr = $17
+ oldsys = $18
+ delta = newusr + newsys - (oldusr + oldsys)
+ pid = $1
+ name = $2
+ user = $3
+ state = $4
+ mem = $11
+ usr = newusr / 1000
+ sys = newsys / 1000
+ printf("%-10s %8s %6s %4ld:%.2ld %3ld:%.2ld %8ldK %-8s %s\n",
+ user, pid, delta,
+ usr / 60, usr % 60,
+ sys / 60, sys % 60,
+ mem, state, name)
+ }
+ ' |
+ sort -nr +2 -3 | sed $max^q
+ mv $new $old
+}
+
+if(! ifs=() eval `{aux/getflags $*})
+ usage
+if(~ $#flagd 1){
+ if(! isfloat $flagd)
+ usage
+ int=$flagd
+}
+if(~ $#flagm 1){
+ if(! isnum $flagm)
+ usage
+ max=$flagm
+}
+cd /proc
+ramfs
+get >$old
+sleep $int
+
+while(){
+ {
+ echo
+ echo top:
+ top
+ } >$out
+ if(~ $#len 1)
+ clear
+ len=`{wc -r <$out}
+ cat $out
+ sleep $int
+}
+
--- /dev/null
+++ b/vtb
@@ -1,0 +1,12 @@
+#!/bin/rc
+# 2024-09-27T21:44:28-04:00
+scr=(`{cat /dev/draw/new >[2]/dev/null})
+w=$scr(11)
+h=$scr(12)
+switch($w){
+case 28*
+ font=/lib/font/contrib.bit/hugevga/unicode.font
+case 21* 22* 25*
+ font=/lib/font/bit/fixed/unicode.10x20.font
+}
+vt -2b -f $font
--
⑨