Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# Sends an SMS. Usage:
# sms <number>
# Message is read from stdin.
#
# Access token is read from ~/pushbullet.token and device id from ~/pushbullet.device.
# I would recommend keeping these files chmod 400.
device=`cat ~/pushbullet.device`
@Snigelson
Snigelson / dynvsprintf.c
Created January 6, 2014 14:13
Dynamic vsprintf
/* Takes the same argumetns as vprintf. Allocates space to store the string and returns
* a pointer to it.
*/
static char* dynvsprintf(char* format, va_list argp)
{
char* buffer=NULL;
int length;
length = vsnprintf(NULL, 0, format, argp)+1;
buffer = malloc(length);
@Snigelson
Snigelson / bfc
Last active January 1, 2016 10:49
Brainf*ck compiler with example file
#!/bin/sh
# Convert brainf*ck to c and compile. Works astonishingly well.
# Usage: $0 < file.bf
sed '1imain(){char*m=calloc(30000,1);
s|[^][+><.,-]||g
s|]|}|g
s|\[|while(*m){|g
s|+|(*m)++;|g
@Snigelson
Snigelson / btrfsrotate.cron
Created December 26, 2013 12:25
Cron job handler for btrfs rotate
#!/bin/bash
source /etc/btrfsrotate.cron
set -e
set -u
function die {
echo "Error: $2" >&2
exit $1
}