Skip to content

Instantly share code, notes, and snippets.

View caseydm's full-sized avatar

Casey Meyer caseydm

View GitHub Profile
# read file
with open('names.txt') as f:
file_data = f.read()
@caseydm
caseydm / gist:116f1407f26ccdb88902
Created April 22, 2015 22:14
Python Management Command
from django.core.management.base import BaseCommand
from django.conf import settings
import csv
from bah_api.models import withDependents, withOutDependents, ZipMHA
class Command(BaseCommand):
def handle(self, *args, **options):
# Populate CSV file into model
def LoadCSV(file_location, my_model, delim):
f = open(file_location)
@caseydm
caseydm / gist:5149089
Last active December 14, 2015 21:09
Rails STI
# model finance.rb
class Finance < ActiveRecord::Base
# Attributes
attr_accessible :amount, :date, :description, :type
# Associations
belongs_to :users, :dependent => :destroy
@caseydm
caseydm / gist:5096447
Last active December 14, 2015 13:49
Rails Single Table Inheritance
# model finance.rb
class Finance < ActiveRecord::Base
attr_accessible :amount, :date, :description, :type
belongs_to :users, :dependent => :destroy
end
# model income.rb