Skip to content

Instantly share code, notes, and snippets.

View seanpue's full-sized avatar

A. Sean Pue seanpue

View GitHub Profile
@seanpue
seanpue / google_drive_md5sum.py
Created May 20, 2020 00:29
Generate md5checksum of local file equivalent to Google Drive/Cloud Storage's
from hashlib import md5
def google_md5sum(filen):
"""Return Google Drive /Cloud Storage hexadecimal equivalent md5sum.
Updates md5 hashalg by reading 8k chunks. Adapted from gsutil."""
hashalg = md5()
with open(filen, "rb") as f:
f.seek(0)
while True:
@seanpue
seanpue / gist:55b239318ab8dd30c911bc844767d6a6
Created October 11, 2019 15:51
Generate sphinx source document in multiple themes (Python)
/*
Copyright (c) 2019, Michigan State University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
@seanpue
seanpue / index.html
Last active December 18, 2015 19:12
MSU Global DH Symposium graphic
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background: #fcfcfa;
}
.stroke {
fill: none;
@seanpue
seanpue / gist:4219e8885d62a26c716c
Last active August 29, 2015 14:27
concatenate sub indexes in pandas and select from parent
df
xdf = df[df.index.isin(adf.index.append([bdf.index, cdf.index]))]
@seanpue
seanpue / gist:e1cb846f676194ae77eb
Created August 6, 2015 01:01
Sort pandas dataframe using icu locale
import PyICU
# below from http://stackoverflow.com/questions/13838405/custom-sorting-in-pandas-dataframe
df = token_count
locale = 'UR.UTF-8'
collator = icu.Collator.createInstance(icu.Locale(locale))
def sort_pd(key=None,reverse=False,cmp=None):
def sorter(series):
#From http://stackoverflow.com/questions/11025123/how-to-convert-r-markdown-to-pdf
rmd2pdf.bash:
RMDFILE=`echo ${1%%.*}`
echo "PROCESSING $RMDFILE"
Rscript -e "require(knitr); require(markdown); knit('$RMDFILE.rmd', '$RMDFILE.md'); markdownToHTML('$RMDFILE.md', '$RMDFILE.html', options=c('use_xhml'))"
pandoc -s "$RMDFILE.html" -o "$RMDFILE.pdf"
for f in *Rmd;do ./rmd2pdf.bash $f;done