Skip to content

Instantly share code, notes, and snippets.

@fitnr
fitnr / api.php
Last active August 29, 2015 13:57
The new Census Geocoding API (http://geocoding.geo.census.gov/geocoder/) is really great, but doesn't accept cross-site AJAX request. This is a simple PHP wrapper to passes javascript requests to the Census.
<?php
require 'census-geocoder-lib.php';
// Who doesn't want to send in coordinates or addresses, and get Census geography back?
try {
// try passing ?lat=36.54&lng=-86.5&returntype=geographies&searchtype=coordinates
$api = new census_geocode($_GET);
echo $api->run();
@fitnr
fitnr / formalize.py
Last active August 29, 2015 14:01
Formalize street names by spelling out abbreviations and regularizing ordinals.
import re
"""
Normalizes a street name with more formal street suffixes and directionals.
Caveats:
Intended for just the street name itself, not the street plus surrounding text.
Intended for US addresses.
For example, the "suffixes" regexes will strip the period off the end of 'St.' and
replace it with 'Street', even if it's at the end of a sentence.
@fitnr
fitnr / index.html
Created July 2, 2014 19:17
Tinymouse - a simple tinymce editor to have on hand
<html>
<head>
<title>TinyMouse</title>
<!-- TinyMCE -->
<script type="text/javascript" src="tinymce-dist/tinymce.min.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "exact",
elements: "elm1",
theme : "modern",
@fitnr
fitnr / index.html
Last active August 29, 2015 14:03
demo of styled gmap
<html>
<head>
<title>map test</title>
<script></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDa40kHQjrMVADweLvXIVaJUjXOUraG164"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="styled-map.js" type="text/javascript"></script>
</head>
<body>
@fitnr
fitnr / jquery-getelementbyid.js
Last active August 29, 2015 14:04
Tired of that extra '#' you need to specify an element's id in jQuery, compared to document.getElementById? Just add this to your code and use $.getElementById('foo')! Easy as pie!
// this is satire, do not use in real life
jQuery.getElementById = function(id) {
return jQuery('#' + id);
};
@fitnr
fitnr / setup
Last active August 29, 2015 14:07
Steps I just went through to set up a new CentOS 7 box, for possible future edification
# set up a non-root user
# below commands assume you're running from root
useradd <USER>
passwd <USER>
# install another python
yum -y update
yum groupinstall -y 'development tools'
yum install python-devel
# maybe don't need this?
@fitnr
fitnr / complete_graph.py
Last active August 29, 2015 14:08
Create a complete graph of lines between a set of points in QGIS
from itertools import combinations
# get the active layer
inlayer = iface.activeLayer()
# Get the index of the NAME field, then rewind the list
infeatures = inlayer.getFeatures()
eg = infeatures.next()
i = eg.fields().indexFromName('NAME')
infeatures.rewind()
@fitnr
fitnr / abs_filename.sh
Created January 8, 2015 17:14
Bash script to get an absolute filename from a relative filename
#!/bin/sh
# $1 : relative filename
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"

Keybase proof

I hereby claim:

  • I am fitnr on github.
  • I am fitnr (https://keybase.io/fitnr) on keybase.
  • I have a public key whose fingerprint is 74E5 F1EE 04D6 968C DA8A 3E81 3ABA FB3A 1D61 8BDC

To claim this, I am signing this object:

@fitnr
fitnr / 1-quads-15min-no-flickr.geojson
Last active August 29, 2015 14:25
The set of USGS 15 minute quads with no geotagged Flickr pictures as of 7/2015.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.