Skip to content

Instantly share code, notes, and snippets.

import sys
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-p', '--prefix', type='str', dest='prefix', help='Allows you to prefix the output name')
(options, args) = parser.parse_args()
def convert_field(x, prefix=None):
""""
@jpotts18
jpotts18 / model.conf
Created September 23, 2016 17:51
ML Database
// survival Survival (0 = No; 1 = Yes)
// pclass Passenger Class (1 = 1st; 2 = 2nd; 3 = 3rd)
// name Name
// sex Sex
// age Age
// sibsp Number of Siblings/Spouses Aboard
// parch Number of Parents/Children Aboard
// ticket Ticket Number
// fare Passenger Fare
// cabin Cabin
from __future__ import division
def calculate_mean(numbers):
total = sum(numbers)
count = len(numbers)
return total / count
def calculate_median(numbers):

Machine Setup

  • Install Python on your machine
  • Install the Python package manager
    • pip should be installed with most versions of python
    • Most likely you should upgrade your pip with $ pip install -U pip for mac or python -m pip install -U pip for windows
    • Check to see if it is installed with $ pip --version
  • $ sudo easy_install pip or download get-pip.py and $ python get-pip.py
@jpotts18
jpotts18 / etl.sql
Last active August 26, 2016 23:35
Data Vault / Kimball Modeling Exercise with Sakila Database
USE sakila;
-- Film
/*
This step represents moving the data from production tables into a new database.
This stage allows data manipulation without locking tables or impacting the production system.
*/
@jpotts18
jpotts18 / etl.sql
Created August 21, 2016 06:12
Data Vault / Kimball Modeling Exercise with Sakila Database
USE sakila;
-- Film
DROP TABLE IF EXISTS src_film;
CREATE TABLE src_film LIKE film;
INSERT src_film SELECT * FROM film;
@jpotts18
jpotts18 / converter.py
Created August 10, 2016 19:18
Camel case to underscore converter
camel_pat = re.compile(r'([A-Z])')
under_pat = re.compile(r'_([a-z])')
def camel_to_underscore(name):
return camel_pat.sub(lambda x: '_' + x.group(1).lower(), name)
def underscore_to_camel(name):
return under_pat.sub(lambda x: x.group(1).upper(), name)
@jpotts18
jpotts18 / convert_cases.py
Created August 10, 2016 19:18
Camel case to underscore
camel_pat = re.compile(r'([A-Z])')
under_pat = re.compile(r'_([a-z])')
def camel_to_underscore(name):
return camel_pat.sub(lambda x: '_' + x.group(1).lower(), name)
def underscore_to_camel(name):
return under_pat.sub(lambda x: x.group(1).upper(), name)
@jpotts18
jpotts18 / caudio
Created July 26, 2016 16:55 — forked from davidrichards/caudio
Collecting ffmpeg snippets that work for me and converting them to reusable scripts.
#!/usr/bin/env bash
set -e
gain=${3-"2"}
if [ "$#" -lt 2 ]; then
echo "Usage: $0 input.aifc output.aifc [gain=2]"
exit 1
else
source 'https://rubygems.org'
ruby "2.2.2"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Views
gem 'bootstrap-sass', '~> 3.3.4'
gem 'sass-rails'