Skip to content

Instantly share code, notes, and snippets.

@njwilson23
njwilson23 / voting-records.py
Created May 12, 2017 05:09
Quick scraping code for BC MLA voting records
import requests
import bs4
import json
import re
from concurrent.futures import ThreadPoolExecutor, as_completed
def parse_index():
""" Return a list of sub-pages with voting data """
response = requests.get("https://www.leg.bc.ca/content-hansard/Index/40th4th/2015votesmhds.htm")
if response.status_code != 200:
@njwilson23
njwilson23 / digitizer.py
Created March 8, 2016 03:12
particularly simple digitizer with matplotlib
#! /usr/bin/env python
#
# This is a particularly simple digitizer implemented with matplotlib. Intended
# for converting graphs and figures into pixel measurements that can be
# transformed into useful data.
#
# Requires Python 3.4+ because I was playing with asyncio coroutines.
#
# Nat Wilson
# March, 2015
@njwilson23
njwilson23 / landsat.py
Last active April 18, 2016 18:59
Tool for browsing landsat data in IPython
""" Tool for searching Landsat archives """
from urllib import request
from datetime import datetime
from xml.etree import ElementTree
from karta import Polygon
from karta.crs import LonLatWGS84
from IPython.display import Image, display
# NEGM 2015
## Ben Linhoff
Using radon-222 as a proxy for distributed drainage, measured from a proglacial stream in Greenland
## Mauri Pelto
**Using transient snowline migration to assess alpine glaciers**
@njwilson23
njwilson23 / gist:1f8e6dd937d1c8236d52
Created February 24, 2015 19:38
issm python include
case "${host_os}" in
*cygwin*)
PYTHONINCL=-I$PYTHON_ROOT/include
;;
*linux*|*darwin*)
PYTHONINCL=-I$PYTHON_ROOT/include/python$PYTHON_VERSION
;;
esac
@njwilson23
njwilson23 / gist:2a0192bf433d58cb6006
Last active August 29, 2015 14:15
ISSM configuration file creation
#!/bin/sh
./configure \
--prefix="$ISSM_DIR" \
--with-triangle-dir="$ISSM_DIR/externalpackages/triangle/install" \
--with-python-dir="$HOME/venv-issm" \
--with-python-numpy-dir="$HOME/venv-issm/lib/python2.7/site-packages/numpy/core/include/numpy" \
--with-mpi-include="$ISSM_DIR/externalpackages/mpich/install/include" \
--with-mpi-libflags="-L$ISSM_DIR/externalpackages/mpich/install/lib -lmpich -lmpl -ldl" \
--with-petsc-dir="$ISSM_DIR/externalpackages/petsc/install" \
--with-metis-dir="$ISSM_DIR/externalpackages/metis/install" \
@njwilson23
njwilson23 / world-files.py
Last active August 29, 2015 14:02
py3-world-files-test
import os
def world_files(fname):
"""
Determine potential world filename combinations, without checking
their existence.
For example, a '*.tif' file may have one of the following
popular conventions for world file extensions '*.tifw',
'*.tfw', '*.TIFW' or '*.TFW'.
@njwilson23
njwilson23 / HigherFuncs.jl
Created September 10, 2013 02:03
A few convenience functions to supplement those in Base
# Misc higher-level functions for Julia
function foldr(f::Function, xs::Number)
xs
end
function foldr(f::Function, xs::Vector)
L = length(xs)
if L == 0
return []