Skip to content

Instantly share code, notes, and snippets.

@bps
bps / Rakefile
Created March 12, 2009 15:51
Rakefile to build plain-text applescripts and install them in ~/Library/Scripts/, maintaining proper hierarchy.
require 'ftools'
require 'rake/clean'
DESTDIR = File.join(ENV['HOME'], 'Library', 'Scripts')
SRC = FileList['**/*.applescript']
SCPTSDIR = 'build'
SCPTS = SRC.collect { |s| File.join(SCPTSDIR, s.sub(/\.applescript$/, '.scpt')) }
CLEAN.include(SCPTS)
CLEAN.include(SCPTSDIR)
@bps
bps / gist:101311
Created April 24, 2009 19:48
Problems with my new 2 week old Unibody MacBook Pro
Unibody MacBook Pro acceptance
- Hard freezes
- No cursor movement
- Audio short loop (like stuck record)
- Only happens (so far) with 4GB RAM
- Ran for 3-4 days with stock 2GB RAM
- Ran for 10 days with 4GB RAM
- Crash on day 2
- Crashes on days 6, 7, 8, 10
- Running since 4/22 evening on 3GB RAM, no freeze yet
@bps
bps / gist:198337
Created September 30, 2009 18:42
A vim function that will load a per-git-project vimrc.
vim ()
{
local vimrc="vimrc" # Name you want to use for your vimrc in .git/
local v="$(which vim)" # Or whatever vim you want
local g="$(__gitdir)" # This comes from the git bash completion script
if [ -z "${g-}" ]; then
"${v}" "$@"
else
local vrc="${g}/${vimrc}"
@bps
bps / time_delta
Created October 6, 2009 21:04
I often want to see a delta between two dates.
#!/usr/bin/env ruby
require 'date'
raise 'Give two parseable arguments' unless ARGV.length == 2
d1 = DateTime.parse(ARGV[0])
d2 = DateTime.parse(ARGV[1])
if d1 < d2
d1, d2 = d2, d1
end
@bps
bps / pre-commit
Created February 1, 2010 16:28
A git pre-commit hook to stop you from committing scratch code.
#!/bin/sh
# A hook to abort a commit if your diff adds XXX or FIXME.
# Set this config variable if you want to allow it anyway.
allowfixmes=$(git config hooks.allowfixmes)
disallow_list="XXX FIXME"
if [ "$allowfixmes" != "true" ]
then
for disallow in $disallow_list
@bps
bps / comm
Created February 9, 2010 16:00
screenrc for IRC and mail that uses newer screen features.
# Get HOL screen from http://git.savannah.gnu.org/gitweb/?p=screen.git
# 4.1.0 has vertical splitting and support for layouts, but has been cooking
# since at least early 2007. See
# http://lists.gnu.org/archive/html/screen-users/2007-02/msg00000.html for
# documentation on the new features, as they're not in the man page yet.
# Build it with "cd src && autoreconf -iv && ./configure --prefix=whatever &&
# make install"
# Communication layout, use a 160x50ish term
source ${HOME}/.screenrc
@bps
bps / gist:338298
Created March 19, 2010 23:05
Rakefile to deploy dotfiles
require 'rake'
require 'digest'
begin
require 'grit'
rescue
end
$home = ENV['HOME']
raise "#{$home} is not a directory" if not File.directory? $home
@bps
bps / sms_backup.sh
Created January 6, 2011 20:28
Script to back up your iPhone SMS from the iTunes database. Run it after you sync.
#!/bin/bash
set -e
BACKUP_DIR="${HOME}/Documents/Backup pile/SMS backup"
BACKUP_FILE="sms_backup.txt"
mkdir -p "${BACKUP_DIR}"
cd "${BACKUP_DIR}"
device_udid="put yours here"
@bps
bps / git_ps1.sh
Created March 23, 2011 14:29
Sometimes __git_ps1 takes too long. This disables it when we ^C.
# via https://gist.github.com/623371
if [[ $(declare -f __git_ps1) ]]; then
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
git_ps1_disable ()
{
_skip_git_ps1=1
@bps
bps / scons.vim
Created November 4, 2011 18:59
Vim Scons command
function! s:Scons()
if !executable("scons")
echohl Error
echo "No scons executable."
echohl None
return -1
endif
let sconstruct = findfile("SConstruct", ".;")
if len(sconstruct)
exec "cd" fnameescape(fnamemodify(sconstruct, ':h'))