Skip to content

Instantly share code, notes, and snippets.

Matt Davis jiffyclub

Block or report user

Report or block jiffyclub

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
@jiffyclub
jiffyclub / jdutil.py
Created Oct 18, 2011
Functions for converting dates to/from JD and MJD
View jdutil.py
"""
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
"""
@jiffyclub
jiffyclub / .gitconfig
Last active Oct 7, 2019
My git aliases
View .gitconfig
[core]
editor = code -nw
[alias]
st = status
ls = log --oneline --decorate
lg = log --oneline --decorate --graph
ff = merge --ff-only
mrg = merge --no-ff
ffpull = pull --ff-only
co = checkout
@jiffyclub
jiffyclub / tserv
Last active Sep 30, 2019
Start a Tornado static file server in a given directory. To start the server in the current directory: `tserv .`. Then go to `http://localhost:8000` to browse the directory.
View tserv
#!/usr/bin/env python
"""
Starts a Tornado static file server in a given directory.
To start the server in the current directory:
tserv .
Then go to http://localhost:8000 to browse the directory.
Use the --prefix option to add a prefix to the served URL,
@jiffyclub
jiffyclub / markdown_doc
Last active Sep 7, 2019
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.
View markdown_doc
#!/usr/bin/env python
import argparse
import sys
import jinja2
import markdown
TEMPLATE = """<!DOCTYPE html>
<html>
@jiffyclub
jiffyclub / hdf_to_parquet.py
Last active Aug 8, 2019
Do the same thing in Spark and Pandas
View hdf_to_parquet.py
"""
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 / conda.fish
Last active Jul 5, 2019
Activate and deactivate commands for working with conda environments in the fish shell. Currently assumes you are switching to a named environment, not specifying a directory.
View conda.fish
function condalist -d 'List conda environments.'
for dir in (ls $HOME/miniconda3/envs)
echo $dir
end
end
function condactivate -d 'Activate a conda environment' -a cenv
if test -z $cenv
echo 'Usage: condactivate <env name>'
return 1
@jiffyclub
jiffyclub / game_of_life.ipynb
Created Sep 24, 2012
Conway's Game of Life in an IPython Notebook
View game_of_life.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / Excel to Pandas.ipynb
Created Jul 15, 2017
Using pandas and xlrd to concatenate multiple excel sheets into a single dataframe. In answer to this Stack Overflow question: https://stackoverflow.com/questions/45113070/how-do-i-make-this-function-for-concatenating-excel-sheets-from-a-single-file-mo#
View Excel to Pandas.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiffyclub
jiffyclub / svstatic
Last active Mar 7, 2019
Convert a SnakeViz HTML file into a self-contained static file that can be hosted anywhere. This script replaces instances of static files being loaded from the local server by having them come from the rawgit CDN.
View svstatic
#!/usr/bin/env python
"""
Prepare an HTML file from SnakeViz for use as a static page.
This makes it so all static files are loaded from a CDN instead
of from the local server.
To get the SnakeViz HTML file run the snakeviz CLI to load a profile
in your browser, than save that page as an HTML file to your computer.
Finally, run this script on that HTML file.
@jiffyclub
jiffyclub / assert_frames_equal.ipynb
Last active Feb 27, 2019
Example of a function to compare two DataFrames independent of row/column ordering and with handling of null values.
View assert_frames_equal.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.