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
import random | |
def unique(values): | |
return list(set(values)) | |
def choose_n(values, n): | |
assert len(values) <= n | |
return random.sample(values, n) |
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
# ~/.pythonrc | |
import readline, rlcompleter | |
### Indenting | |
class TabCompleter(rlcompleter.Completer): | |
"""Completer that supports indenting""" | |
def complete(self, text, state): | |
if not text: | |
return (' ', None)[state] |
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 bash | |
git diff --cached | pep8 --diff |
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
import mandrill | |
m = mandrill.Mandrill('YOUR_API_KEY') | |
assert m.users.ping() == "PONG!" |
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
#!/bin/bash | |
# This hook should be run after every virtualenv is activated. | |
# See `predeactivate-env-cleanup` to configure automatic clean-up. | |
# | |
# INSTALLATION | |
# Save the latest version of this file into your virtualenvwrapper | |
# hook directory (e.g., ~/.virtualenvs): | |
# $ echo "$(curl -fsSl https://gist.githubusercontent.com/kbambz/10002069/raw/postactivate-env-setup)" > $VIRTUALENVWRAPPER_HOOK_DIR/postactivate-env-setup | |
# | |
# Then tell postactivate to invoke the script when it runs: |
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
#!/bin/bash | |
# This hook should be run after every virtualenv is activated. | |
# See `predeactivate-env-cleanup` to configure automatic clean-up. | |
# | |
# INSTALLATION | |
# Save this file in $VIRTUALENVWRAPPER_HOOK_DIR (e.g., ~/.virtualenvs) | |
# in a file called `postactivate-env-setup`, then do: | |
# | |
# $ chmod +x $VIRTUALENVWRAPPER_HOOK_DIR/postactivate-env-setup | |
# $ echo "source \$VIRTUALENVWRAPPER_HOOK_DIR/postactivate-env-setup" >> $VIRTUALENVWRAPPER_HOOK_DIR/postactivate |
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
#!/bin/bash | |
# | |
# Ensure Homebrew is installed | |
# | |
which -s brew | |
if [[ $? != 0 ]]; then | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" | |
brew doctor | |
else |
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
#!/bin/sh | |
echo "$(curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash)" > ~/.git-completion.bash | |
echo "source ~/.git-completion.bash" >> ~/.bashrc | |
source ~/.bashrc |