Skip to content

Instantly share code, notes, and snippets.

@jiffyclub
jiffyclub / slash_argparse.py
Created December 1, 2017 20:34
Utilities for creating command line-like interfaces for Slack /slash commands.
"""
Utilities for creating command line-like interfaces for Slack /slash commands.
Define your parser spec using an instance of SlashParser and then pass it to parse_args
for parsing. Be sure to check the returned success flag to know whether parsing
was successful or if there was a parsing error.
"""
import argparse
import re
@jiffyclub
jiffyclub / ipythonblocks Demo.ipynb
Last active September 5, 2022 03:46
ipythonblocks.BlockGrid is a class that displays a colored grid in the IPython Notebook. The colors can be manipulated, making it useful for practicing control flow stuctures and quickly seeing the results.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / hdf_to_parquet.py
Last active September 24, 2022 16:05
Do the same thing in Spark and Pandas
"""
Convert Pandas DFs in an HDFStore to parquet files for better compatibility
with Spark.
Run from the command line with:
spark-submit --driver-memory 4g --master 'local[*]' hdf5_to_parquet.py
"""
import pandas as pd
@jiffyclub
jiffyclub / game_of_life.ipynb
Created September 24, 2012 21:15
Conway's Game of Life in an IPython Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / markdown_doc
Last active August 1, 2023 11:16
This script turns Markdown into HTML using the Python markdown library and wraps the result in a complete HTML document with default Bootstrap styling so that it's immediately printable. Requires the python libraries jinja2, markdown, and mdx_smartypants.
#!/usr/bin/env python
import argparse
import sys
import jinja2
import markdown
TEMPLATE = """<!DOCTYPE html>
<html>
@jiffyclub
jiffyclub / jdutil.py
Created October 18, 2011 02:03
Functions for converting dates to/from JD and MJD
"""
Functions for converting dates to/from JD and MJD. Assumes dates are historical
dates, including the transition from the Julian calendar to the Gregorian
calendar in 1582. No support for proleptic Gregorian/Julian calendars.
:Author: Matt Davis
:Website: http://github.com/jiffyclub
"""