Skip to content

Instantly share code, notes, and snippets.

@Rafe
Rafe / cheatsheet.py
Created June 26, 2012 15:20
celery-cheat
#Quick Cheat Sheet
T.delay(arg, kwarg=value)
#always a shortcut to .apply_async.
T.apply_async((arg, ), {'kwarg': value})
T.apply_async(countdown=10)
#executes 10 seconds from now.
@Rafe
Rafe / unit.py
Created June 15, 2012 20:15
python unittest
assertEqual(a, b) #a == b
assertNotEqual(a, b) #a != b
assertTrue(x) #bool(x) is True
assertFalse(x) #bool(x) is False
assertIs(a, b) #a is b 2.7
assertIsNot(a, b) #a is not b 2.7
assertIsNone(x) #x is None 2.7
assertIsNotNone(x) #x is not None 2.7
assertIn(a, b) #a in b 2.7
assertNotIn(a, b) #a not in b 2.7
@Rafe
Rafe / gist:2926813
Created June 13, 2012 22:13
rc.code
200 OK OK
201 CREATED Created
204 DELETED No Content [1]
400 BAD_REQUEST Bad Request
401 FORBIDDEN Unauthorized [2]
404 NOT_FOUND Not Found
409 DUPLICATE_ENTRY Conflict [3]
410 NOT_HERE Gone [4]
501 NOT_IMPLEMENTED Not Implemented
503 THROTTLED Service Unavailable [5]
@Rafe
Rafe / gist:2389552
Created April 15, 2012 02:40
Grep cheatsheet
grep [PATTERN] [FILE]
grep apple fruitlist.txt
grep apple *.txt
grep ^app fruitlist.txt
"-x :: exact line
grep -x apple fruitlist.txt
@Rafe
Rafe / record
Created April 8, 2012 01:04
vim record cheatsheet
q + (1234567890)
=> start record
q
=> stop
@(1234567890)
=> play
:reg
@Rafe
Rafe / gist:2289021
Created April 3, 2012 03:12
jasmine matchers cheatsheet
expect(x).toEqual(y); compares objects or primitives x and y and passes if they are equivalent
expect(x).toBe(y); compares objects or primitives x and y and passes if they are the same object
expect(x).toMatch(pattern); compares x to string or regular expression pattern and passes if they match
expect(x).toBeDefined(); passes if x is not undefined
expect(x).toBeUndefined(); passes if x is undefined
@Rafe
Rafe / gist:2288326
Created April 3, 2012 00:40
Gmail multiple address search:
from:(some@example.com OR where@example.com OR *@not.example.com)
@Rafe
Rafe / gist:2164194
Created March 22, 2012 20:48
postgresql install
# Start/Stop PostgreSQL
If this is your first install, automatically load on login with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/postgresql/9.1.3/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
If this is an upgrade and you already have the homebrew.mxcl.postgresql.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
cp /usr/local/Cellar/postgresql/9.1.3/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
@Rafe
Rafe / gist:2146914
Created March 21, 2012 13:35
Ruby Exception Handling cheatsheet
begin
#do something...
raise Exception, "Error message"
raise ArgumentError
rescue Exception => e
puts e.message
rescue ArgumentError => e
puts e.message
ensure
@Rafe
Rafe / .autotest
Created March 20, 2012 02:58
Autotest
require "autotest/growl"
require "autotest/fsevent"
RSPEC=true