Skip to content

Instantly share code, notes, and snippets.

View emesterhazy's full-sized avatar

Evan Mesterhazy emesterhazy

View GitHub Profile
@emesterhazy
emesterhazy / fizzbuzz.ml
Created January 13, 2020 03:51
First few lines of Ocaml...
open Base
open Stdio
let fizzbuzz i =
match (i % 3, i % 5) with
| (0,0) -> "FizzBuzz"
| (0,_) -> "Fizz"
| (_,0) -> "Buzz"
| _ -> Int.to_string i
@emesterhazy
emesterhazy / mysql_calendar_table.sql
Last active September 18, 2018 18:47 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
-- Creates a calendar table in mysql
DROP TABLE IF EXISTS calendar;
CREATE TABLE calendar (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
@emesterhazy
emesterhazy / df_sql_type.py
Created July 26, 2018 23:05
Return a dictionary of SQL datatypes inferred from a pandas dataframe for use with df.to_sql()
import sqlalchemy as sa
def sql_type(data_frame):
"""Return a dict of sql types inferred from pandas type"""
type_dict = {}
for i, j in zip(data_frame.columns, data_frame.dtypes):
if 'float' in str(j):
type_dict.update({i: sa.types.Float(precision=5,
asdecimal=True)})
elif 'object' in str(j):

Keybase proof

I hereby claim:

  • I am emesterhazy on github.
  • I am emesterhazy (https://keybase.io/emesterhazy) on keybase.
  • I have a public key ASAw1GnQdCu1VwTQqmDzEaZjHWJT5-yBv2VS9z5LHvKsXwo

To claim this, I am signing this object: