Skip to content

Instantly share code, notes, and snippets.

View kbambz's full-sized avatar

Kate Bambino kbambz

  • Optum
  • Miami, FL
View GitHub Profile
import random
def unique(values):
return list(set(values))
def choose_n(values, n):
assert len(values) <= n
return random.sample(values, n)
@kbambz
kbambz / .pythonrc
Created May 29, 2014 20:28
~/.pythonrc
# ~/.pythonrc
import readline, rlcompleter
### Indenting
class TabCompleter(rlcompleter.Completer):
"""Completer that supports indenting"""
def complete(self, text, state):
if not text:
return (' ', None)[state]
#!/usr/bin/env bash
git diff --cached | pep8 --diff
import mandrill
m = mandrill.Mandrill('YOUR_API_KEY')
assert m.users.ping() == "PONG!"
@kbambz
kbambz / postactivate-env-setup
Last active July 28, 2018 16:53
virtualenvwrapper postactivate and predeactivate scripts to export all a .env file's declarations (foreman style) into your bash environment on activate, then clean them up on deactivate. Also tells npm and rvm to install packages directly into the active virtualenv. Useful for Heroku-hosted project development.
#!/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:
@kbambz
kbambz / postactivate-env-setup.sh
Last active December 30, 2015 10:19
virtualenvwrapper postactivate and predeactivate scripts for dumping a .env file's declarations (foreman style -- located in your project root) into your bash environment on activation, then cleaning them up on deactivate. Also tells npm and rvm to install packages directly into the active virtual environment.
#!/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
@kbambz
kbambz / git-setup.sh
Last active December 22, 2015 19:29
Install Git and setup bash autocompletion on Mac OS X using Homebrew.
#!/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
@kbambz
kbambz / git-completion-setup.sh
Last active December 22, 2015 18:48
Install Bash shell auto-completion for Git, as described by http://git-scm.com/book/en/Git-Basics-Tips-and-Tricks#Auto-Completion.
#!/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