Skip to content

Instantly share code, notes, and snippets.

View dustinfarris's full-sized avatar
💭
🇺🇸

Dustin Farris dustinfarris

💭
🇺🇸
View GitHub Profile
@dustinfarris
dustinfarris / df.sh
Last active August 29, 2015 14:02
A couple handy git shortcuts
#!/bin/sh
MASTER_BRANCH="master"
STAGING_BRANCH="staging"
function new_issue() {
#
# Create a new branch from master using the provided name
#
if [ -z $2 ]; then
@dustinfarris
dustinfarris / safe-string.js
Last active August 29, 2015 14:03
Basic SafeString Handlebars helper
// app/helpers/safe-string.js
import Ember from 'ember';
/**
* Do not escape special characters.
*
* Usage:
*
* ```hbs
* {{safe-string "<span>My raw HTML code</span>"}}
#
# Borrowed largely from the PeepCode prompt:
# http://peepcode.com/blog/2012/my-command-line-prompt
#
function +vi-git-status() {
# Check for untracked files or updated submodules since vcs_info does not.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
hook_com[unstaged]=' %F{8}✗%f'
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Initialize virtualenvwrapper
export VIRTUALENVWRAPPER_PYTHON="/usr/local/bin/python3"
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
#
# Executes commands at login pre-zshrc.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# Browser
#
#
# Sets Prezto options.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
#
# General
#
@dustinfarris
dustinfarris / python.vim
Created August 6, 2014 00:31
python indentation with 2 spaces for hanging indents (put in .vim/indent)
" Python indent file
" Language: Python
" Maintainer: Eric Mc Sween <em@tomcom.de>
" Original Author: David Bustos <bustos@caltech.edu>
" Last Change: 2004 Jun 07
" Only load this indent file when no other was loaded.
if exists("b:did_indent")
finish
endif
@dustinfarris
dustinfarris / user_serializer.py
Created November 16, 2014 17:50
Attempt at a user serializer in DRF 3.0
class UserSerializer(serializers.ModelSerializer):
password = serializers.CharField(
min_length=6, write_only=True, required=False)
class Meta:
model = User
fields = ('id', 'first_name', 'last_name', 'password')
def create(self, validated_data):
password = validated_data.pop('password', None)
@dustinfarris
dustinfarris / investment_fund_fees.py
Last active August 29, 2015 14:10
A very elementary way of projecting the impact of investment fund fees
def calc(principal, fee_pct, avg_growth_pct, annual_contrib, years):
"""
>>> calc(10000, 1.5, 7, 5500, 35)
(154256.73, 48243.27)
>>> calc(10000, 1.0, 7, 5500, 35)
(168507.21, 33992.79)
>>> calc(10000, 0.5, 7, 5500, 35)
(184508.4, 17991.6)
"""
fee = fee_pct / 100
@dustinfarris
dustinfarris / python_breakpoint.vim
Created February 18, 2015 21:48
Map F6 to inserting a Python breakpoint (F7 to remove)
python << EOF
import vim
import re
ipdb_breakpoint = 'import ipdb; ipdb.set_trace()'
def set_breakpoint():
breakpoint_line = int(vim.eval('line(".")')) - 1
current_line = vim.current.line