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
    
  
  
    
  | # Set up custom zsh command prompt. | |
| PROMPT='%(?.%F{green}√.%F{red}%?)%f %B%F{240}%1~%f%b %# ' | |
| # Aliases. | |
| alias l='ls -G' | |
| alias la='l -a' | |
| alias ll='l -l' | |
| alias lla='l -la' | |
| alias b='cd ..' | 
  
    
      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 | |
| cd `dirname "$0"` # cd to the directory containing this script. | |
| cd `git rev-parse --show-toplevel` # cd to the root of the git repo. | |
| set -e # Fail on errors. | |
| set -x # Print commands. | |
| # Some example code below: | 
  
    
      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
    
  
  
    
  | # This module is meant to be imported. | |
| # You'll need to run: | |
| # pip install pydot | |
| ''' | |
| # Example usage: | |
| import graph_helpers as gh | 
  
    
      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
    
  
  
    
  | from funcy import memoize | |
| # Returns difference between two words. | |
| # O(N^2) in space and time. | |
| @memoize | |
| def diff(a, b): | |
| if a == "" and b == "": | |
| return (0, "") | |
| if a == "": | 
  
    
      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 subprocess | |
| def run_bash_command(command): | |
| ''' | |
| Returns the stdout of the command. | |
| If the exit code is non-zero, raises a subprocess.CalledProcessError. | |
| Note: If the command involves ssh, it's recommended that you pass the -T option to ssh, to prevent it from messing with your terminal modes. | |
| ''' | |
| return subprocess.check_output(['bash', '-c', command]).strip() | 
  
    
      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 | |
| ''' | |
| This script reads a set of numbers and plots a histogram. | |
| ''' | |
| import sys | |
| import matplotlib.pyplot as plt | |
| import numpy as np | 
  
    
      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
    
  
  
    
  | from math import sqrt | |
| from scipy.stats import norm | |
| def normal_dist_params(num_trials, num_successes): | |
| # Returns the mean and variance of the normal distribution approximation that models the actual success rate given the experiment results. | |
| p = float(num_successes) / float(num_trials) | |
| n = num_trials | |
| mean = p | |
| variance = p * (1-p) / n | |
| return (mean, variance) | 
  
    
      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
    
  
  
    
  | # -------------------------------------------------- | |
| # Output: | |
| # We randomly distribute T tasks across N shards. | |
| # We compute the 95th percentile of (size of largest shard / size of average shard). | |
| # 2 shards, 2 tasks = 2.00 | |
| # 2 shards, 8 tasks = 1.75 | |
| # 2 shards, 40 tasks = 1.30 | |
| # 2 shards, 200 tasks = 1.14 | |
| # 5 shards, 5 tasks = 3.00 | |
| # 5 shards, 20 tasks = 2.00 | 
  
    
      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
    
  
  
    
  | Cherry Pick without committing: | |
| Script target: /usr/bin/env | |
| Parameters: git cherry-pick --no-commit $SHA | |
| Checkout working tree from commit: | |
| Script target: /usr/bin/env | |
| Parameters: git checkout $SHA -- $REPO | 
  
    
      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
    
  
  
    
  | # bash/zsh completion support for core Git. | |
| # | |
| # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> | |
| # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
| # Distributed under the GNU General Public License, version 2.0. | |
| # | |
| # The contained completion routines provide support for completing: | |
| # | |
| # *) local and remote branch names | |
| # *) local and remote tag names | 
NewerOlder