Skip to content

Instantly share code, notes, and snippets.

View codelitt's full-sized avatar

Cody Littlewood codelitt

View GitHub Profile
# ============================================
# Upload → Unit-Type Map → Parse Rent Rolls → Elasticity
# (one-cell Colab script; generic across properties)
# ============================================
import sys, io, re, json
from pathlib import Path
import numpy as np
import pandas as pd
from google.colab import files
# =========================================
# All-in-One Colab: Price Elasticity by Unit Type (with autoscaling dropdowns)
# =========================================
# Upload -> Parse (Yardi two-row header) -> Build panel -> Estimate elasticities
# Primary: Logit (occupied ~ log(price) + month FE), cluster-robust by unit
# Fallback: Aggregated OLS (monthly occ_rate ~ log(avg_price)), HC1 robust
# 95% CIs, CSV exports, interactive charts
# Group dashboards: by Unit Size, Renovation (Classic/PR/CR), and Price Tier (Low/Med/High)
# Includes dropdown autoscale patch so switching views always shows data.
@codelitt
codelitt / traffic_sim.sh
Last active October 31, 2017 19:24
Quickly throw traffic at site
for i in `seq 1 100`; do curl $URL; done
## With basic HTTP auth
for i in `seq 1 100`; do curl -u username:password $URL; done
@codelitt
codelitt / main.go
Last active March 17, 2017 14:28
Trying to add cachebusted css file to the ExecuteTemplate method
package main
imports (
"path/filepath"
"strings"
"github.com/gorilla/mux"
)
func main() {
server_port := ":3000"
@codelitt
codelitt / csv-lovechild.sh
Last active July 27, 2016 13:16
Combine multiple csv files into one file while preserving the headers from the first csv
awk 'FNR==1 && NR!=1{next;}{print}' *.csv > newfile.csv
@codelitt
codelitt / arch.sh
Created August 7, 2015 12:09
Useful Arch commands for freeing up space
#See which files in / are taking up space
du -md1 / | sort -n
#better way to see which directories in / are taking up space.
ncdu -x /
#Clean pacman cache
pacman -Scc
@codelitt
codelitt / docker.sh
Last active August 29, 2015 14:13
Setting up docker for Go
#Build image from Dockerfile in same directory.
docker build --rm=true -t go_playground .
#Run docker image in a container with interactive shell connecting /go on my host machine to /go in docker container
# has name go-playgound and is ran from image go_playground.
sudo docker run -ti -p 9000:9000 -v /home/cody/projects/go:/go --name=go-playground go_playground /bin/bash -l
#Turns out that you don't need we don't need bin/bash. Line 52 in the dockerfile does that
#with no command at the end, it automatically uses what's in CMD in the docker file.
#Sometimes you still have to add the command on my setup for some reason though
@codelitt
codelitt / gist:90a80e582ba76ab97fdc
Last active August 29, 2015 14:08
Docker Workflow for Ruby and postgres
#create the data/volume container
docker run -v /var/lib/pgsql/data -v /home/cody/projects/warrantygenius:/var/www --name=wg_storage ubuntu true
#Build postgres image from within the dockerfile directory
docker build --rm=true -t wg_postgres .
#Create and run postgres container from the image
docker run -d --name=wg-postgres --volumes-from=wg_storage wg_postgres
#Build ruby image. rm clears cache? and -t tags it as that name
@codelitt
codelitt / gist:c47bece467e2be7352fe
Created October 15, 2014 01:48
Docker workflow
# Create ghost volume to store our data
docker run -v ghost-storage:/ghost-override --name=ghost-storage ubuntu true
# Create site volume
dockur run -v incoin.io:/var/www/incoin.io --name=site-storage ubuntu true
#Create nginx volume to store sites-enabled, logs and certs
docker run -v nginx/logs:/var/log/nginx -v certs:/etc/nginx/certs -v sites-enabled:/etc/nginx/sites-enabled --name=nginx-storage ubuntu true
# Start the ghost daemon using volume from ghost-storage

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname