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 date, datetime, time | |
from decimal import Decimal | |
def to_json(python_object): | |
""" | |
Adding in custom serialization for Date & Decimal objects. | |
>>> import json | |
>>> from datetime import date, datetime, time | |
>>> from decimal import Decimal |
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
#!/usr/bin/env python | |
""" | |
Simple script that updates all events in an ical file to a new timezone. | |
Requires icalendar package (which pulls in pytz as a dependency). | |
By: @beardedprojamz (Ben Hayden) | |
""" | |
import argparse | |
import sys |
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
#!/usr/bin/env python | |
import random | |
from datetime import date | |
class BabyHayden(object): | |
"""A class of baby only a Dad could love.""" | |
def __init__(self, due_date): | |
self.due_date = due_date | |
self.gender = None | |
self.name = None |
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 redis | |
import web | |
SESSION = 'SESSION:' | |
class RedisStore(web.session.Store): | |
"""Store for saving a session in redis: | |
import rediswebpy | |
session = web.session.Session(app, rediswebpy.RedisStore(), initializer={'count': 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
# coding: utf-8 | |
import pandas as pd | |
df = pd.read_csv('lahman-csv_2014-01-31/Master.csv') | |
count_series = df.nameLast.value_counts() | |
top_10_names = count_series[:10] | |
plt.figure() | |
top_10_names.plot(kind='bar').set_title('Most Popular Last Names in MLB' |
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
#!/usr/bin/env python | |
import os | |
import boto.ec2 | |
from collections import Counter | |
with open(os.path.join(os.environ['HOME'], '.ssh', 'config'), 'w') as sc: | |
new_sc = "Host example\n User bill\n HostName 123.456.789.1\n" | |
templ = "Host {0}-{1}\n HostName {2}\n" | |
ec2 = boto.ec2.connect_to_region('us-east-1') | |
counter_dict = Counter(['red', |
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
#!/usr/bin/env python | |
from __future__ import print_function | |
import os | |
import xml.etree.ElementTree as ET | |
from multiprocessing.dummy import Pool | |
import boto3 | |
import requests | |
import pandas as pd |
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
''' | |
A function that handles a Slack "/trello" command and creates trello items in a board's "Inbox" list. | |
We use API Gateway to act as an AWS Proxy to call a lambda function asyncronously, along with an immediate response back to slack. | |
Once Lambda has created the card, and it then posts the new card url back to slack. | |
''' | |
import boto3 | |
import json | |
import urllib |
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
aws elasticbeanstalk describe-configuration-settings --application-name foo --environment-name foo-staging | jq '.ConfigurationSettings[0].OptionSettings[] | select(.OptionName=="Notification Topic ARN")' |
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
# kms encrypt/decrypt for macOS | |
function kms-encrypt { | |
# encrypts the passed key & plain text, and adds the base64 encoded string to your clipboard | |
aws kms encrypt --key-id "$1" --plaintext "$2" --query CiphertextBlob --output text | pbcopy | |
} | |
function kms-decrypt { | |
# decrypts the passed argument and adds it to your clipboard | |
aws kms decrypt --ciphertext-blob fileb://<(echo "$1" | base64 -D) --query Plaintext --output text | base64 -D | pbcopy | |
} |
OlderNewer