Skip to content

Instantly share code, notes, and snippets.

View enkeboll's full-sized avatar

Andy Enkeboll enkeboll

  • Plaid
  • New York, NY
View GitHub Profile
@enkeboll
enkeboll / facebook_post_scorer.py
Last active November 8, 2017 18:36
COMS 6998 Social Networks Facebook Post Scorer
__author__ = 'andyenkeboll'
import requests
# on mac, `sudo pip install facebook-sdk`
# https://pypi.python.org/pypi/facebook-sdk
import facebook
from collections import Counter
# `sudo pip install mechanize`
import mechanize
import re
@enkeboll
enkeboll / superbowl_digits.py
Last active August 29, 2015 14:14
Super Bowl Box Pool Digit Picker
import random
def main():
teams = ["Patriots","Seahawks"]
ones = {"Patriots": range(10),
"Seahawks": range(10)}
random.shuffle(teams)
for team in teams:
random.shuffle(ones[team])
@enkeboll
enkeboll / thebosco_gif_extractor.py
Created April 28, 2015 15:00
Download all gifs from a thebos.co (TheBosco) gif page
import urllib2
from os import path
from urlparse import urlsplit
dir = path.join(path.expanduser("~"),'Downloads')
url = "http://thebos.co/e/venmohq-celebration"
page = urllib2.urlopen(url).read()
soup = BeautifulSoup(page)
@enkeboll
enkeboll / open_folder_in_iterm.applescript
Last active August 27, 2015 22:46
Open Folder in iTerm2 from Finder
#!/usr/bin/osascript
# This is my version of
# http://peterdowns.com/posts/open-iterm-finder-service.html
# modified for iTerm 2.9+
# Create this as an "Application", save it as a .app file, and
# drag it onto the Finder window while holding the command key
# (in Yosemite, the command and option keys)
on run {input, parameters}
@enkeboll
enkeboll / superbowl_score_change_scraper.py
Last active February 8, 2016 17:59
Scrapes pro-football-reference.com for a history of super bowl scoring summaries, for the purposes of creating "Super Bowl Boxes" stats.
import csv
import requests
from bs4 import BeautifulSoup
base_url = "http://www.pro-football-reference.com"
next_page = "/super-bowl/i.htm"
# this website doesn't have a "next" button to SB XLIX, for some reason
extra = ['/super-bowl/xlix.htm']
def pair(a, b):

Keybase proof

I hereby claim:

  • I am enkeboll on github.
  • I am enkeboll (https://keybase.io/enkeboll) on keybase.
  • I have a public key ASAFYSl9y480O-OPtLFBOEA-F5508UFKGk6G3p57BQGk7Qo

To claim this, I am signing this object:

@enkeboll
enkeboll / cloudwatch_redshift.py
Last active April 30, 2018 05:04
Get Redshift metrics from Cloudwatch
import bisect
import datetime
import operator
import boto3
client = boto3.client('cloudwatch')
def get_metric(offset, metricname, threshold, oper='ge', stat='Average'):
if offset >= 64:
@enkeboll
enkeboll / python_db_decimals.py
Created January 30, 2018 21:42
Python MySQL DB API Decimal Test
create_table = """
DROP TABLE IF EXISTS `dec_test`;
CREATE TABLE `dec_test` (
`dec_2_2` decimal(4,2),
`dec_4_2` decimal(6,2),
`dec_8_4` decimal(8,4),
`char_15` char(15)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
insert into dec_test values
@enkeboll
enkeboll / csv_to_parquet.py
Last active February 1, 2018 14:19
CSV to Parquet
# from http://blogs.quovantis.com/how-to-convert-csv-to-parquet-files/
from pyspark import SparkContext
from pyspark.sql import SQLContext
from pyspark.sql.types import StructField, StructType, IntegerType, StringType, TimestampType
if __name__ == "__main__":
sc = SparkContext(appName="CSV2Parquet")
sqlContext = SQLContext(sc)
@enkeboll
enkeboll / redshift_queries.sql
Created June 27, 2018 17:11
Useful redshift quieries
redshift
-- COMMAND LINE CONNECT:
- seatgeek:
- psql "host=redshift-datawarehouse.service.seatgeek.prod dbname=sganalytic user=andy port=5439"
- greenhouse:
- psql "host=redshift.greenhouse.io dbname=greenhouse user=org_978 port=5439 sslmode=require"
-- CREDENTIALS LINE
CREDENTIALS 'aws_iam_role=arn:aws:iam::093535234988:role/Production-RedshiftCopyUnload'