This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
["Life isn’t about getting and having, it’s about giving and being.", "Kevin Kruse"] | |
["Whatever the mind of man can conceive and believe, it can achieve.", "Napoleon Hill"] | |
["Strive not to be a success, but rather to be of value.", "Albert Einstein"] | |
["Two roads diverged in a wood, and I—I took the one less traveled by, And that has made all the difference.", "Robert Frost"] | |
["I attribute my success to this: I never gave or took any excuse.", "Florence Nightingale"] | |
["You miss 100% of the shots you don’t take.", "Wayne Gretzky"] | |
["I’ve missed more than 9000 shots in my career. I’ve lost almost 300 games. 26 times I’ve been trusted to take the game winning shot and missed. I’ve failed over and over and over again in my life. And that is why I succeed.", "Michael Jordan"] | |
["The most difficult thing is the decision to act, the rest is merely tenacity.", "Amelia Earhart"] | |
["Every strike brings me closer to the next home run.", "Babe Ruth"] | |
["Definiteness of purpose is the starting point of all achievement.", "W. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
description "Hubot IRC bot" | |
# This will make Hubot start on system boot | |
start on filesystem or runlevel [2345] | |
stop on runlevel [!2345] | |
# Path to Hubot installation | |
env HUBOT_DIR='/opt/hubot/' | |
env HUBOT='bin/hubot' | |
env LOGFILE='/dev/null' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from collections import defaultdict | |
import subprocess | |
def main(): | |
git_log = subprocess.check_output(['git', 'log', "--pretty=format:%an\t%ct"]) | |
users = defaultdict(list) | |
for line in git_log.split('\n'): | |
name, commit_time = line.strip().split('\t') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from itertools import islice | |
def make_change(target, denominations): | |
"""Returns fewest coins needed to make up the target value | |
>>> make_change(100, [25, 10, 5, 1]) | |
[(25, 4)] | |
>>> make_change(30, [25]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''See http://en.wikipedia.org/wiki/Haversine_formula for more details''' | |
from math import sin, cos, sqrt, asin, radians | |
RADIUS_EARTH_M = 6371200.0 #The Earth's mean radius in meters | |
def haversine_distance(a, b): | |
'''Operates on two lat,lngs and returns the distance in meters''' | |
lng1, lat1 = map(radians, a) #lng, lat to radians |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
from itertools import islice, chain | |
def subtract_coords(a, b): | |
'''Returns a - b''' | |
return (a[0] - b[0], a[1] - b[1]) | |
def dot_product(a, b): | |
return a[0] * b[0] + a[1] * b[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import islice | |
def batch(items, n): | |
'''Splits a list of items into chunks of length n''' | |
i = iter(items) | |
while True: | |
items = tuple(islice(i, n)) | |
if len(items) == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Provides utility functions for encoding and decoding linestrings using the | |
Google encoded polyline algorithm. | |
''' | |
def encode_coords(coords): | |
'''Encodes a polyline using Google's polyline algorithm | |
See http://code.google.com/apis/maps/documentation/polylinealgorithm.html | |
for more information. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
def datetime_format(value): | |
'''Provides pretty datetime strings | |
The amount of information will change depending on how long ago the value is from now | |
If the value is today then just the time will be returned | |
If the value is this year then the year will be left off | |
''' | |
now = datetime.utcnow() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def daterange(v0, v1): | |
assert v0 <= v1 | |
if v0 == v1: | |
return v0.strftime('%b %d, %Y') | |
if v0.year == v1.year: | |
if v0.month == v1.month: | |
parts = (v0.strftime('%b %d'), | |
v1.strftime('%d'), |
NewerOlder