Skip to content

Instantly share code, notes, and snippets.

View johnjreiser's full-sized avatar

John Reiser johnjreiser

View GitHub Profile
@johnjreiser
johnjreiser / keybase.md
Created September 24, 2014 20:32
keybase.md

Keybase proof

I hereby claim:

  • I am johnjreiser on github.
  • I am johnjreiser (https://keybase.io/johnjreiser) on keybase.
  • I have a public key whose fingerprint is E152 5F50 2A5E 4044 B7B2 1C9A 5660 B872 03D7 B097

To claim this, I am signing this object:

@johnjreiser
johnjreiser / xapi_parser.py
Created May 9, 2012 03:22
Script to merge and convert a series of OpenStreetMap XAPI results into a single tab-delimited file. Keys are retained as additional fields. OSM id, latitude, and longitude are always exported.
#!/usr/bin/env python
# ---------------------------------------------------------------------------
# xapi_parser.py
# Created on: 8 May 2012
# Created by: John Reiser <reiser@rowan.edu>
#
# Script to merge and convert a series of OpenStreetMap XAPI results into a
# single tab-delimited file. Keys are retained as additional fields. OSM id,
# latitude, and longitude are always exported.
#
@johnjreiser
johnjreiser / lucode_crosswalk.pgsql
Created July 24, 2013 13:25
PostgreSQL of the Land Use crosswalk table. Useful if you need a complete list of all of the Anderson Level 4 codes and their descriptions used in the State of New Jersey land use data.
CREATE TABLE lucode_crosswalk (
lucode integer NOT NULL PRIMARY KEY,
ludesc varchar(100) NOT NULL,
hltype varchar(30) NOT NULL
);
COMMENT ON TABLE lucode_crosswalk IS 'All available Land Use/Land Cover codes used in the NJ LULC data.';
COMMENT ON COLUMN lucode_crosswalk.lucode IS 'Anderson Level IV Code';
COMMENT ON COLUMN lucode_crosswalk.ludesc IS 'Land use type description';
COMMENT ON COLUMN lucode_crosswalk.hltype IS 'Hasse-Lathrop code classification';
@johnjreiser
johnjreiser / csv2json.py
Last active December 22, 2015 22:49
script to convert a CSV file to JSON
#!/usr/bin/env python
import csv
import simplejson as json
import sys, os
rows = {}
csvkey = "mun_code"
# csvkey is the CSV column that contains a unique ID
@johnjreiser
johnjreiser / dbfschemacompare.py
Last active January 2, 2016 16:09
Generates a simple report showing matching schemas from a list of DBF files. Useful for seeing if a directory of shapefiles have similar attribute tables.
#!/usr/bin/env python
"""
Generates a simple report showing matching schemas from a list of DBF files.
"""
import sys, os, glob
from dbfpy import dbf
files = []
####
# Stupid Shell Tricks
####
# find the largest files within a subdirectory (mac os x)
find . -type f -print0 | xargs -0 stat -f '%z %N' | sort -n | tail
@johnjreiser
johnjreiser / buildPAMS.py
Created March 26, 2012 16:29
buildPAMS - a function to return a NJ PAMS pin for GIS parcels. Python code for use in ArcGIS.
def buildPAMS(mun, blk, lot, qua=None):
"""Returns a PAMS Pin from three or four cadastre fields."""
if (qua == None) or (qua == ''):
return "%s_%s_%s" % (mun, blk, lot)
else:
return "%s_%s_%s_%s" % (mun, blk, lot, qua)
colorscheme solarized
syntax on
filetype indent plugin on
set tabstop=4
set expandtab
set shiftwidth=4
set softtabstop=4
@johnjreiser
johnjreiser / redate.sh
Created November 12, 2017 20:27
Rename files from MM-DD-YYYY to YYYY-MM-DD
#!/bin/bash
for file in `ls -1 | grep -e "[0-9]\{2\}-[0-9]\{2\}-[0-9]\{4\}" ` ; do
if [[ $file =~ ([0-9]{2})-([0-9]{2})-([0-9]{4})(.*)$ ]] ; then
newname=${BASH_REMATCH[3]}-${BASH_REMATCH[1]}-${BASH_REMATCH[2]}${BASH_REMATCH[4]}
echo "$file -> $newname "
mv -i $file $newname
else
echo Skipping $file...
fi
@johnjreiser
johnjreiser / movefiles.sh
Created May 5, 2019 13:52
Sort extensionless files by type
#!/bin/bash
TXT="text/plain; charset=us-ascii"
PNG="image/png; charset=binary"
JPEG="image/jpeg; charset=binary"
MOV="video/quicktime; charset=binary"
MP4="video/mp4; charset=binary"
GPP="video/3gpp; charset=binary"
for file in *; do
currfile=`file -b -i $file`