Skip to content

Instantly share code, notes, and snippets.

View hepplerj's full-sized avatar
building the history web

Jason Heppler hepplerj

building the history web
View GitHub Profile
hepplerj /
Created May 23, 2018 14:45
An evolving set of pandas snippets I find useful
# Unique values in a dataframe column
# Grab dataframe rows where column = value
df = df.loc[df.column == 'some_value']
# Grab dataframe rows where column value is present in a list
value_list = ['value1', 'value2', 'value3']
df = df.loc[:,df.columns.isin(valuelist)]
# or grab rows where a value is not present in a list
hepplerj /
Last active May 10, 2018 20:12
Add leaflet points on click

Click on the map to add points. See the console for lat/long output.

hepplerj / index.html
Created March 25, 2018 02:30
WebGL Mapping
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<script src=""></script>
<script src=""></script>
function map() {
var options = { zoom: 1.5, position: [47.19537,8.524404] };
var earth = new'earth_div', options);
hepplerj /
Created October 20, 2017 17:09
Batch compress PDFs for Omeka
# This requires the use of GhostScript
# On macOS, the easiest way to get started is install with Homebrew
# brew install ghostscript
# This file should live in the directory that contains the PDFs. From
# the command line, just running `bash` will compress the PDFs
# and fix any issues that might be present with JPEG2000 images. The
# compression process should preserve the OCR and will likely reduce the
# size of the PDF as well.
hepplerj /
Created October 20, 2017 15:33
Using tweepy to crawl for archives, special collections, and library users.
import tweepy
# OAuth is the preferred method for authenticating to Twitter
# Consumer keys are under the application's Details page at
consumer_key = ""
consumer_secret = ""
# Access tokens are found on your applications' Details page
# at
hepplerj / multiserver.js
Last active September 19, 2017 17:40
Checking server connections
View multiserver.js
var http = require('http');
function handler(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello world\n');
http.createServer(handler).listen(3000, '');
http.createServer(handler).listen(3001, 'localhost');
http.createServer(handler).listen(3002, ''); // ifconfig
http.createServer(handler).listen(3003, ''); // echo $HOSTNAME
hepplerj /
Created May 26, 2017 13:25
A script for setting up GDAL on Ubuntu 12.04
# Install subversion
sudo apt-get -y install subversion
# Install g++
sudo apt-get -y install g++
# Install Hierarchical Data Format library
sudo apt-get -y install libhdf4-alt-dev
# Get trunk of gdal
hepplerj /
Created May 10, 2017 14:44
Bulk convert shapefiles to geojson
# Bulk convert shapefiles to geojson
function shp2geojson() {
ogr2ogr -f GeoJSON -t_srs crs:84 "$1.geojson" "$1.shp"
for var in *.shp; do shp2geojson ${var%\.*}; done

Keybase proof

I hereby claim:

  • I am hepplerj on github.
  • I am jaheppler ( on keybase.
  • I have a public key ASDXbDTSmWJiyDZ6URLp6rKUdG-84IRsPjYEJWYog7YOcgo

To claim this, I am signing this object:

hepplerj / scc-tracts.geojson
Created March 28, 2017 20:27
Census tracts
View scc-tracts.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.