Skip to content

Instantly share code, notes, and snippets.

View tshauck's full-sized avatar

Trent Hauck tshauck

View GitHub Profile
@tshauck
tshauck / ar1.py
Created August 5, 2016 00:43
AR(1) model in edward
import edward as ed
import numpy as np
import tensorflow as tf
from edward.models import Variational, Normal
from edward.stats import bernoulli, beta
import pandas_datareader as pdr
class AR1(object):
@tshauck
tshauck / pandas-calendar.py
Last active September 19, 2015 05:12
pandas-calendar.py
"""
Created By: Trent Hauck
Date: 2015-09-18T21:52:35
License: Use the shit out of it.
"""
# pylint: disable=no-init, too-few-public-methods
from pandas.tseries import holiday as h
from pandas.tseries import offsets as o
@tshauck
tshauck / metrics.py
Last active August 29, 2015 14:27
tracking metrics with prometheus and flask_restful
from prometheus_client import Summary
from prometheus_client.exposition import generate_latest
from flask_restful import Resource
from flask import Response
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')
class Metrics(Resource):
""" Resource for exposing metrics to prometheus. """
@tshauck
tshauck / machine-create.sh
Created July 18, 2015 19:37
docker-machine spot
docker-machine create \
--driver amazonec2 \
--amazonec2-access-key $ACCESS_KEY \
--amazonec2-secret-key $SECRET_KEY \
--amazonec2-vpc-id $VPC \
--amazonec2-security-group $SECURITY_GROUP \
--amazonec2-instance-type "m4.2xlarge" \
--amazonec2-root-size 20 \
--amazonec2-request-spot-instance \
--amazonec2-spot-price 0.20 \
@tshauck
tshauck / case.py
Last active November 1, 2015 23:36
python case
def linkbase_type(filepath):
"""Get the type of linkbase from the filename."""
cases = (
(filepath.endswith("_cal.xml"), "calculation"),
(filepath.endswith('_def.xml'), "definition"),
(filepath.endswith('_lab.xml'), "label"),
(filepath.endswith('_pre.xml'), "presentation"),
(filepath.endswith('.xsd'), "reference"),
(filepath.endswith('.xml'), "filing"),
import simpy
import time
import pandas as pd
import datetime as dt
import numpy as np
import metrics
class DatedEnvironment(simpy.Environment):
def __init__(self, start_time, end_time, offset='h', initial_time=0):