Skip to content

Instantly share code, notes, and snippets.

View billspat's full-sized avatar

Pat Bills billspat

View GitHub Profile
@billspat
billspat / import_authors_for_wowchemy.py
Created February 2, 2021 20:00
simple script to read a TSV file and creaate author pages for Hugo/Wowchemy/Academic theme
#!/usr/bin/env python
#### import_authors.py
# python 3.7+
# create author pages for a Hugo/Wowchemy site ( https://wowchemy.com/ )
# from a TSV file (e.g. download from google sheets) with very specific headers
# import_authors.py <tsv file> <../path/to/site>
# requires a TSV with the following field header row:
# Name ProjectRole Photo InstitutioneRole/Title URL Org1Name Org1URL Org2Name Org2URL one_line_bio interests PhD PhDInstitution PhDYear MS MSInstitution MSYear BS/BA BS/BAInstitution BS/BAYear emailaddress twitterid githuburl googlescholarurl paragraph_bio
# clunky but works for now!
@billspat
billspat / nsfbadger.R
Last active May 13, 2021 14:27
NSF badge maker!
# Make NSF award badges for your github readme or Markdown-based website!
nsf_badges <- function(award_id) {
nsf_button_template="[![NSF-{award_id}](https://img.shields.io/badge/NSF-{award_id}-blue.svg)](https://nsf.gov/awardsearch/showAward?AWD_ID={award_id})]"
badges<- stringr::str_glue(nsf_button_template)
return(paste(badges, collapse = ' ') )
}
@billspat
billspat / Readme.md
Created April 27, 2017 15:34 — forked from vicapow/Readme.md
WebGL + d3.layout.force

This demo uses d3.layout.force() to calculate the node positions and then passes those to webGL to render them on the GPU.

@billspat
billspat / arma.R
Created April 13, 2017 12:55
example R code
# Goals: ARMA modeling - estimation, diagnostics, forecasting.
# 0. SETUP DATA
rawdata <- c(-0.21,-2.28,-2.71,2.26,-1.11,1.71,2.63,-0.45,-0.11,4.79,5.07,-2.24,6.46,3.82,4.29,-1.47,2.69,7.95,4.46,7.28,3.43,-3.19,-3.14,-1.25,-0.50,2.25,2.77,6.72,9.17,3.73,6.72,6.04,10.62,9.89,8.23,5.37,-0.10,1.40,1.60,3.40,3.80,3.60,4.90,9.60,18.20,20.60,15.20,27.00,15.42,13.31,11.22,12.77,12.43,15.83,11.44,12.32,12.10,12.02,14.41,13.54,11.36,12.97,10.00,7.20,8.74,3.92,8.73,2.19,3.85,1.48,2.28,2.98,4.21,3.85,6.52,8.16,5.36,8.58,7.00,10.57,7.12,7.95,7.05,3.84,4.93,4.30,5.44,3.77,4.71,3.18,0.00,5.25,4.27,5.14,3.53,4.54,4.70,7.40,4.80,6.20,7.29,7.30,8.38,3.83,8.07,4.88,8.17,8.25,6.46,5.96,5.88,5.03,4.99,5.87,6.78,7.43,3.61,4.29,2.97,2.35,2.49,1.56,2.65,2.49,2.85,1.89,3.05,2.27,2.91,3.94,2.34,3.14,4.11,4.12,4.53,7.11,6.17,6.25,7.03,4.13,6.15,6.73,6.99,5.86,4.19,6.38,6.68,6.58,5.75,7.51,6.22,8.22,7.45,8.00,8.29,8.05,8.91,6.83,7.33,8.52,8.62,9.80,10.63,7.70,8.91,7.50,5.88,9.82,8.44,10.92,11.67)
# Make a R timeseries out of the raw
@billspat
billspat / GitHub-Forking.md
Created March 24, 2017 18:31 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@billspat
billspat / zoomToMousePosition.js
Created March 7, 2017 13:10 — forked from KarolAltamirano/zoomToMousePosition.js
D3 custom zoom to mouse position
// viewport dimensions
const WIDTH = 300;
const HEIGHT = 400;
// initial values
var tx = 0,
ty = 0,
scale = 1;
/**
@billspat
billspat / graph.json
Created March 2, 2017 19:16 — forked from eyaler/graph.json
Force-Directed Graph with Drag/Zoom/Pan/Center/Resize/Labels/Shapes/Filter/Highlight
{
"graph": [],
"links": [
{"source": 0, "target": 1},
{"source": 0, "target": 2},
{"source": 0, "target": 3},
{"source": 0, "target": 4},
{"source": 0, "target": 5},
{"source": 0, "target": 6},
{"source": 1, "target": 3},
@billspat
billspat / mysql2sqlite.sh
Created January 31, 2017 18:21 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
#!/usr/bin/env python
import sys
import urllib2
from xml.etree import ElementTree as ET
def getforecast(zipcode):
"""gets current forecast from wunderground"""
url='http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query={}'
forecastxml = urllib2.urlopen(url.format(zipcode)).read()
@billspat
billspat / fixnames.py
Created January 23, 2016 13:54
make os x files windows friendly
# fix names
# toy program that looks for non-windows-friendly file names on an OS X system and emits "mv" commands to rename them.
# checks that files are uniquely named. Does not check for length of file path
# run the mv commands to make the changes
# TEST before using; no guarantees; in Public domain
import re
import os, sys
#
# illegal chars