Skip to content

Instantly share code, notes, and snippets.

Building open-source projects that I should really be charging money for.

Todd Birchard toddbirchard

Building open-source projects that I should really be charging money for.
Block or report user

Report or block toddbirchard

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
toddbirchard / TwitterWidget.js
Last active Mar 7, 2020
Twittter widget for GatsbyJS displaying tweets from a user's profile. Based on the tutorial:
View TwitterWidget.js
import React from 'react'
import PropTypes from 'prop-types'
import { StaticQuery, graphql } from 'gatsby'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
const TwitterWidget = ({ data }) => {
const tweets = data.tweets.edges
const twitterProfile = data.twitterProfile.user
return (
toddbirchard /
Created Oct 20, 2019
Helper function to compare two DataFrames and find rows which are unique or shared.
def dataframe_difference(df1, df2, which=None):
"""Find rows which are different."""
comparison_df = df1.merge(df2,
if which is None:
diff_df = comparison_df[comparison_df['_merge'] != 'both']
diff_df = comparison_df[comparison_df['_merge'] == which]
def timeit(method):
"""Print execution time of decorated function."""
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if 'log_time' in kw:
name = kw.get('log_name', method.__name__.upper())
kw['log_time'][name] = int((te - ts) * 1000)
import sys
import pymysql
import logging
class Database:
"""Database connection class."""
def __init__(self, config): = config.db_host
toddbirchard /
Last active Mar 28, 2019
Recursively retrieve all images in a given site, generate retina images, convert all images to webp format.
import os
import json
import glob
import PIL
from PIL import Image
def get_all_images():
"""Create an array of PNGs and JPGs."""
img_arr = []
toddbirchard / animated-terminal-session.markdown
Created Mar 13, 2019
Animated Terminal Session For Linkbox API
View animated-terminal-session.markdown
import os
import json
import boto3
from botocore.client import Config
import botocore
from urllib.parse import unquote
import PIL
# Initialize a session using DigitalOcean Spaces.
toddbirchard /
Created Feb 2, 2019
Google BigQuery: Create a Table With an Auto-generate Schema
from import storage
from import bigquery
import pprint
bucket_uri = 'gs://your-bucket/'
bucket_name = 'your-bucket'
bucket_target = 'datasets/data_upload.csv'
local_dataset = 'data/test.csv'
bucket_target_uri = bucket_uri + bucket_target
You can’t perform that action at this time.