Skip to content

Instantly share code, notes, and snippets.

@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 / record
Created April 8, 2012 01:04
vim record cheatsheet
q + (1234567890)
=> start record
q
=> stop
@(1234567890)
=> play
:reg
@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 / 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 / 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 / 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 / gist:3102414
Created July 13, 2012 02:59
AWK cheatsheet
HANDY ONE-LINE SCRIPTS FOR AWK 30 April 2008
Compiled by Eric Pement - eric [at] pement.org version 0.27
Latest version of this file (in English) is usually at:
http://www.pement.org/awk/awk1line.txt
This file will also be available in other languages:
Chinese - http://ximix.org/translation/awk1line_zh-CN.txt
USAGE:
getAlgorithms = -> ['md5', 'sha1', 'sha256', 'sha512']
generateCode = (url, algorithms, digits, callback)->
#increase code digits if all codes are registered
if algorithms.length is 0
algorithms = getAlgorithms()
digits += 1
algorithm = algorithms.shift()
@Rafe
Rafe / gist:3352492
Created August 14, 2012 20:18
LAMP wordpress install:
1. set user
useradd -ms /bin/bash [username]
passwd [username]
hostname [NEW_NAME]
2. login in new user, install packages:
sudo apt-get install apache2 php5 php5-mysql libapache2-mod-php5 apache2-mpm-prefork
sudo apt-get install mysql-server mysql-client
@Rafe
Rafe / gist:3974919
Created October 29, 2012 17:05
File reader api
reader = new FileReader()
reader.onloadend = =>
reader.result
reader.readAsDataURL event.target.files[0]
reader = new FileReader()
reader.onloadend = =>
$(event.target).prev('.image').attr 'src', reader.result