Skip to content

Instantly share code, notes, and snippets.

View mnem's full-sized avatar

Dave Clayton-Wagner mnem

View GitHub Profile
@mnem
mnem / .bash_profile
Created July 26, 2011 19:10
Backup of my basic bash profile for OS X so I can lazy curl it to new installs.
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
# Setup the prompt so that it shows the current branch when in a git directory.
source /usr/local/etc/bash_completion.d/git-completion.bash
function setup_prompts_for_git
{
local BLUE="\[\e[0;34m\]"
local RED="\[\e[0;31m\]"
local YELLOW="\[\e[0;33m\]"
local PURPLE="\[\e[0;35m\]"
@mnem
mnem / .bash_profile
Created July 27, 2011 13:38
Setting FLEX_HOME in Lion for FDT Ant
export FLEX_HOME=/Users/mnem/Developer/Frameworks/flex/4.5.1.21328
launchctl setenv FLEX_HOME $FLEX_HOME
@mnem
mnem / Shuffle.as
Created August 11, 2011 15:30
A non-insane Array shuffler for AS3
package utils
{
/**
* Simple class to shuffle items in arrays using a modern Fisher–Yates shuffle as described
* by Richard Durstenfeld in ACM volume 7, issue 7: "Algorithm 235: Random permutation".
*
* Wikipedia: http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
*
*
* Author: David Wagner
@mnem
mnem / NSMutableArray+Shuffle.h
Created August 19, 2011 12:44
NSMutableArray category for Fisher–Yates style shuffling. See http://en.wikipedia.org/wiki/Fisher–Yates_shuffle
/**
* NSMutableArray+Shuffle.h
*
* (c) Copyright 2011 David Wagner.
*
* Complain/commend: http://noiseandheat.com/
*
*
* Licensed under the MIT license:
*
getSize(a):4
getSize(b):4
getSize(TestClass):880
getSize(this):428
getSize(a):4
getSize(aa):4
getSize(b):4
getSize(TestClass):884
getSize(this):428
@mnem
mnem / gist:1285665
Created October 13, 2011 22:00
Python: Hacking in a new builtin
def mnemlog(message):
import datetime
mnemlog = open("/Users/mnem/mnemlog","a+",0)
mnemlog.write(str(datetime.datetime.now()) + " " + message + "\n")
mnemlog.close()
mod = __import__("__builtin__");
mod.mnemlog = mnemlog
mnemlog("It has been done")
@mnem
mnem / Recipe - Scottish Tablet.md
Created November 4, 2011 17:44
My Mum's family recipe for tablet. It's awesome. Imagine a neutron star made from sugar. It'd be a bit like this.

Scottish Tablet

  • 397g tin of sweetened condensed milk. Don't confuse this with evaporated milk.
  • 200ml milk
  • 1kg sugar
  • A piece of butter around the size of a walnut

Method

@mnem
mnem / git_fetch_pull_all_subfolders.sh
Created December 6, 2011 14:35
Simple bash script for fetching and pulling all repos in the executed folder to the latest of the branch they are on
#!/bin/bash
################
# Uncomment if you want the script to always use the scripts
# directory as the folder to look through
#REPOSITORIES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPOSITORIES=`pwd`
IFS=$'\n'
@mnem
mnem / alias_pbcopy_pbpaste.sh
Created December 7, 2011 16:35
pbcopy and pbpaste for linux
# Emulate pbcopy and pbpaste for copying to and from the pasteboard/clipboard
#
# via: http://whereswalden.com/2009/10/23/pbcopy-and-pbpaste-for-linux/
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
@mnem
mnem / test.sh
Created December 14, 2011 18:06
#!/bin/sh
echo Tilde:~
echo HOME:$HOME
if [ `whoami` != 'root' ]; then
sudo $0 $* || exit 1
fi