Skip to content

Instantly share code, notes, and snippets.

View jordanwade90's full-sized avatar

Jordan Wade jordanwade90

View GitHub Profile
@jordanwade90
jordanwade90 / unisearch.sh
Last active January 1, 2016 21:39
Searches plan9port’s Unicode character database and prints any matches along with their corresponding character.
#!/usr/local/plan9/bin/rc
opt=()
while(~ $1 -* && ! ~ $1 --){
opt=($opt $1)
shift
}
if(~ $1 --){
shift
opt=($opt -e)
}
@jordanwade90
jordanwade90 / automan.sh
Created April 28, 2014 22:36
Passes all arguments to plan9port's man(1); if that fails, try the unix man(1) instead.
#!/usr/local/plan9/bin/rc
# Passes all arguments to plan9port's man(1); if that fails, try the unix man(1) instead.
9 man $* >[2]/dev/null || u man $* | 9 sed -e 's/([^ ]+)[ ]+/\1 /g'
@jordanwade90
jordanwade90 / Slide
Created April 28, 2014 22:43
Use acme to switch between “slides” (actually just text files) in a directory. Blatantly stolen from Russ Cox (http://research.swtch.com/acme).
#!/usr/local/plan9/bin/rc
. /usr/local/plan9/lib/acme.rc
winname `{pwd}^/$1
winctl clean
winctl get
@jordanwade90
jordanwade90 / secstored.service
Created April 29, 2014 19:11
Systemd unit for plan9port’s secstored(1).
[Unit]
Description=Secstore server
[Service]
Type=forking
ExecStart=/usr/lib/plan9/bin/secstored -s tcp!*!secstore
[Install]
WantedBy=multi-user.target
@jordanwade90
jordanwade90 / randwp
Created April 30, 2014 01:57
Print the name of a random wallpaper from $home/wallpapers. (Used by my xinitrc.)
#!/usr/local/plan9/bin/rc
9 ls -F `{du -a $home/wallpapers | awk '{print $2}'} | grep -v '/$' | 9 fortune /dev/stdin
@jordanwade90
jordanwade90 / getpw
Created April 30, 2014 02:08
Gets a username and password from factotum and prints it to the terminal. I use this to grab website passwords since Chromium doesn’t talk to factotum.
#!/usr/lib/plan9/bin/rc
if(! ~ $#* 1){
echo usage: $0 domain >/dev/stderr
echo Gets a username and password from factotum. $0 prints '''ok username password''' if a key matching '''role=client proto=pass dom=DOMAIN user? !password?''' is known to factotum or if factotum can prompt for a key. | fmt >/dev/stderr
exit usage
}
tmp=`{mktemp -d --tmpdir getpw.XXXXXXXXXX}
f=$tmp/fifo
mkfifo -m 600 $f
{{echo start 'role=client' 'proto=pass' 'dom='^$1 'user?' '!password?'; awk -F ' ' '/done/{exit} /ok/{print "read"; fflush(); if(length($2) > 0) print $0 >"/dev/stderr"} /needkey/{print $0 >"/dev/stderr"; exit $0}' <$f} | 9p rdwr factotum/rpc >[2]/dev/null >$f} >[2=1]
@jordanwade90
jordanwade90 / eval-for-environ.rc
Created January 24, 2015 06:50
Function for the Plan 9 shell rc(1) to invoke a command with sh(1) and print out the specified environment variables in a form rc can read. I use rc for my shell but need to set up my environment like I was running sh.
# eval-for-environ COMMAND [VARIABLE...]
# Evaluates COMMAND using sh then arranges for rc to learn the values
# of each of the environment variables VARIABLE.... This will break if
# the value of any VARIABLE may contain a quote (').
fn eval-for-environ{
cmd=$1
shift
for(var){
cmd=($cmd ';' echo $var'=\''"$(echo $'$var' | sed s/\''/\''\''/g)"\''')
}
@jordanwade90
jordanwade90 / tengwarsegments.html
Created January 21, 2018 04:32
Prototype segmented display for Tengwar
<!DOCTYPE html>
<html version=5>
<head>
<style type="text/css">
svg{height:22mm}
svg path{stroke:#eee;stroke-width:0.1;stroke-linecap:round}
#t00 #c, #t00 #e, #t00 #j, #t00 #n{stroke:black}
#t01 #c, #t01 #e, #t01 #j, #t01 #l, #t01 #n{stroke:black}
#t02 #m, #t02 #q, #t02 #v, #t02 #x{stroke:black}
#t03 #m, #t03 #o, #t03 #q, #t03 #v, #t03 #x{stroke:black}