Skip to content

Instantly share code, notes, and snippets.

@przmv
Last active January 3, 2016 01:59
Show Gist options
  • Save przmv/8392747 to your computer and use it in GitHub Desktop.
Save przmv/8392747 to your computer and use it in GitHub Desktop.
data-uri generator in rc
#!/usr/bin/env rc
path=($PLAN9/bin)
fn datauri {
echo data:`{/usr/bin/file -bi $1 | sed 's/ //'}^';'base64,`{/usr/bin/base64 $1 | tr -d '\x0A'}
}
if(~ $#* 0)
echo usage: `{basename $0} file... >[1=2]
if not
for(f) test -f $f && datauri $f || echo file $f does not exist >[1=2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment