Skip to content

Instantly share code, notes, and snippets.

Tyler Hartley tyleha

Block or report user

Report or block tyleha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tyleha /
Created Jan 11, 2016
Unified code needed to build a heatmap of your email data.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as dates
import matplotlib.gridspec as gridspec
from datetime import timedelta, datetime, date
import GmailAccount # my package
gmail = GmailAccount(username='', password=password)
tyleha /
Last active Jul 3, 2019
A simple IMAP manager class for Gmail
from imaplib import IMAP4_SSL
import email as em
from email.utils import parsedate, parsedate_tz
from email.parser import HeaderParser
class GmailAccount(object):
def __init__(self, username=None, password=None, folder=None):
self.username = username
self.password = password
self.folder = folder
tyleha /
Last active Aug 29, 2015
Map of Flights Taken
fig = plt.figure(figsize=(18,12))
# Plotting across the international dateline is tough. One option is to break up flights
# by hemisphere. Otherwise, you'd need to plot using a different projection like 'robin'
# and potentially center on the Int'l Dateline (lon_0=-180)
# flights = flights[(flights.startlon < 0) & (flights.endlon < 0)]# Western Hemisphere Flights
# flights = flights[(flights.startlon > 0) & (flights.endlon > 0)] # Eastern Hemisphere Flights
xbuf = 0.2
ybuf = 0.35
tyleha /
Last active Dec 1, 2017
Hexbin Map of Location History
figwidth = 14
fig = plt.figure(figsize=(figwidth, figwidth*h/w))
ax = fig.add_subplot(111, axisbg='w', frame_on=False)
# draw neighborhood patches from polygons
df_map['patches'] = df_map['poly'].map(lambda x: PolygonPatch(
x, fc='#555555', ec='#555555', lw=1, alpha=1, zorder=0))
# plot neighborhoods by adding the PatchCollection to the axes instance
tyleha /
Last active Nov 12, 2017
Choropleth of Location history
# Check out the full post at
# to utilize the code below
# We'll only use a handful of distinct colors for our choropleth. So pick where
# you want your cutoffs to occur. Leave zero and ~infinity alone.
breaks = [0.] + [4., 24., 64., 135.] + [1e20]
def self_categorize(entry, breaks):
for i in range(len(breaks)-1):
if entry > breaks[i] and entry <= breaks[i+1]:
return i
tyleha /
Last active Nov 25, 2016
Building a Matlab-style timing function that can be called with the bare-minimum number of keystrokes and thought.

A Simple Python Timing Function


# What this gist provides:

'''code to be timed'''
You can’t perform that action at this time.