- Tells you when your code is broken
- Manual testing sucks
- Prevent against regressions
- Upgrading dependencies
- Refactoring
- Documentation
- Other devs can read your tests to see how you intended your code to be used
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strconv" | |
) | |
// sentinel value for channels |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# homework average is worth 15% of the grade and lowest will be thrown out | |
HOMEWORK = [ | |
100, # hw1 | |
100, # hw2 | |
100, # hw3 | |
100, # hw4 | |
100, # hw5 | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first update all remote branches | |
git fetch --all --prune | |
# loop over all local/remote pairs | |
git for-each-ref --format="%(refname:short) %(upstream:short)" refs/heads | \ | |
while read local remote | |
do | |
# make sure remote exists | |
[ -z "$remote" ] && continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Testing Calculator</title> | |
<style type="text/css"> | |
#display { | |
width: 180px; | |
border: 1px solid black; | |
padding: 5px 7px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Counter() { | |
this.elements = {}; | |
} | |
Counter.prototype.lookup = function (element) { | |
var el, i; | |
el = this.elements[element] || []; | |
for (i = 0; i < el.length; i++) { | |
if (el[i][0] === element) { | |
return el[i][1]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interval_id = high = low = null | |
ticker = $ '#price' | |
alert_url = 'http://www.angelfire.com/ut/jlpicard/images/picalert.wav' | |
start = -> | |
do nodes.stop.show | |
do nodes.start.hide | |
interval_id = setInterval -> | |
current_price = parseFloat do ticker.text | |
unless high > current_price > low |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Naive Monte Carlo approximation of pi.""" | |
from __future__ import division | |
import math | |
from random import random | |
from itertools import repeat | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r"""Generate and check password hashes for Ubersmith DE (salted sha1). | |
Example use: | |
>>> my_new_hash = generate_hash('my_new_pass', 'salt') | |
>>> my_new_hash # store this in the database | |
'{ssha1}W77amZWRUSWjDLh04P/dlfsCvYdzYWx0\n' | |
>>> check_password('my_new_pass', my_new_hash) | |
True | |
>>> check_password('not_my_new_pass', my_new_hash) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse_git_dirty { | |
[[ `git status --porcelain` ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
} | |
export PS1="\n\[$BPurple\][\w]\n\[$BCyan\]\u@\h \[$BGreen\]\$(parse_git_branch)\n$\[$Color_Off\] " |