Skip to content

Instantly share code, notes, and snippets.

View alexjj's full-sized avatar

Alex Johnstone alexjj

View GitHub Profile
@alexjj
alexjj / bbc playlists
Created September 20, 2013 12:28
Convert BBC Radio playlists to use with mpd. e.g. on raspberry pi or other linux device
#!/bin/bash
set -e
playlistdir=/var/lib/mpd/playlists
declare -A radios
radios["BBC Radio 4"]="http://www.bbc.co.uk/radio/listen/live/r4_aaclca.pls"
radios["BBC Radio 2"]="http://www.bbc.co.uk/radio/listen/live/r2_aaclca.pls"
for k in "${!radios[@]}"
do
#This script allows an EncFS password to be stored in KDE’s kwallet. This is useful for anyone who has encrypted parts of their #harddrive and want them to be automatically mounted when logging on to KDE. On the first run, a dialogue will allow the password #to be stored in kwallet; subsequently, the kwallet password will be requested (if kwallet is not already authenticated) and then #the encrypted directory will be automatically mounted. The script has not been tested on recent versions of KDE, but it is known #to have worked in versions 4.2 and 4.3.
#Usage
#kdeencfs ROOTDIR MOUNTPOINT
#The call to kdeencfs can be placed in a file located in ~/.kde/Autostart:
# mount my private directories
kdeencfs /home/ben/.private /home/ben/private
kdeencfs /mnt/data/.secret /home/data/secret
@alexjj
alexjj / ex - archive extractor
Created May 3, 2014 03:40
Goes in bash profile and uses the right arguments to expand an archive
# ex - archive extractor
# usage: ex <file>
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
PIDFILE=/home/alex/radio.pid
if [ -e "$PIDFILE" ] ; then
PID=`/bin/cat "$PIDFILE"`
if /bin/kill -0 "$PID" > /dev/null 2>&1 ; then
exit 0
fi
fi
/bin/echo "$$" > $PIDFILE
@alexjj
alexjj / ZFS Snapshot Deletion
Created April 15, 2015 17:09
Delete all ZFS Snapshots
zfs list -H -o name -t snapshot | xargs -n1 zfs destroy
@alexjj
alexjj / keybase.md
Created April 29, 2015 04:44
Keybase Proof

Keybase proof

I hereby claim:

  • I am alexjj on github.
  • I am alexjj (https://keybase.io/alexjj) on keybase.
  • I have a public key whose fingerprint is 8B9B 891B 7CB8 D401 E268 068D 0EDC 6376 B245 2245

To claim this, I am signing this object:

@alexjj
alexjj / pkglist.txt
Created May 3, 2015 23:56
SAN Package List
autoconf
automake
bash
binutils
bison
bzip2
coreutils
cryptsetup
device-mapper
dhcpcd
@alexjj
alexjj / note
Created May 11, 2015 14:24
Keep a note
# Note
note () {
# if file doesn't exist, create it
if [[ ! -f $HOME/.notes ]]; then
touch "$HOME/.notes"
fi
if ! (($#)); then
# no arguments, print file
@alexjj
alexjj / screenlock.sh
Last active August 29, 2015 14:21
Lock screen of blurred workspace
# How to use:
#
# Just place a lock.png in your home folder to overlay whatever you want
#!/bin/bash
scrot -e 'convert -blur 0x3 $f ~/lockbg.png'
convert -gravity center -composite ~/lockbg.png ~/lock.png ~/lockfinal.png
i3lock -u -i ~/lockfinal.png
rm ~/lockfinal.png ~/lockbg.png
@alexjj
alexjj / portsupdate.sh
Created July 28, 2015 20:46
FreeBSD Ports update check script
#!/bin/sh
/usr/sbin/portsnap fetch update && \
/usr/local/sbin/portmaster -L --index-only | egrep '(ew|ort) version|total install'
echo -n "Last update: "
date -r `pkg query %t | sort | tail -n1` "+%Y%m%d"