Skip to content

Instantly share code, notes, and snippets.

@derrickj
derrickj / alerter.sh
Created April 5, 2012 01:23
Send text and email when a certain web page contains the word "Open"
#!/bin/sh
# given url (arg 1), alert user when it contains "open"
if [ -z "$1" ]; then
echo "Usage: $0 <url>"
exit 1
fi
URL="$1"
@derrickj
derrickj / my-launch-agent.plist
Created February 1, 2012 20:59
Quit torrenting when away from home
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>some-unique-label</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
@derrickj
derrickj / newjekyllpost
Created December 21, 2011 05:53
This shell script creates a template file for a new jekyll post. Typing in the date, time and title in the exact format for the filename and inside the file is a tiny bit too tedious when it can easily be automated.
#!/bin/sh
# get title from stdin
/bin/echo -n "Title : "
read TITLE
SAFETITLE=$(/bin/echo -n $TITLE | tr -sc [:alpha:] - | tr [:upper:] [:lower:])
FILENAME=$(date -j +%Y-%m-%d)-${SAFETITLE}.md
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
autcrlf = input
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://github.com/torvalds/linux.git
@derrickj
derrickj / gist:1182603
Created August 31, 2011 01:32
Show changes in the staging area (aka what is about to be commited). Especially useful after git add -i
git diff --cached
@derrickj
derrickj / gist:1176050
Created August 28, 2011 00:18
Convert every FLAC file in the current directory to ALAC (Apple Lossless)
for i in *.flac; do ffmpeg -i "$i" -map_meta_data 0:0 -acodec alac "`basename "$i" .flac`.m4a"; done;
@derrickj
derrickj / gist:965641
Created May 10, 2011 23:54
AuthSub request works fine with Google Calendar, but not Google Health
next = 'http://localhost:8080/auth'
# h9 scope for development
#scope = 'https://www.google.com/health/feeds/'
scope = 'https://www.google.com/calendar/feeds/'
#scope = 'https://www.google.com/h9/feeds/'
url_format = 'https://www.google.com/accounts/AuthSubRequest?next=%s&scope=%s&secure=%d&session=%d'
auth_sub_url = url_format % (next, scope, 0, 1)
#auth_sub_url = service.GenerateAuthSubURL(next, scope, secure = secure, session = session)
# replace this last line with whatever method you use to write out to the page
#facebook div#pagelet_netego_questions {
display:none;
}