Skip to content

Instantly share code, notes, and snippets.

@fitnr
fitnr / Gruntfile.js
Created January 9, 2014 19:48
Reduced test case for assemble variable scope bug
module.exports = function(grunt) {
grunt.initConfig({
// Build HTML from templates and data
assemble: {
options: {
layoutdir: 'layouts',
layout: 'default.hbs',
},
example: {
@fitnr
fitnr / dist_functions.sql
Created January 23, 2014 21:24
MySQL distance function. Yes, just use PostGIS. Whatever.
CREATE FUNCTION DISTANCE_MI( start_lat DOUBLE, start_lon DOUBLE, end_lat DOUBLE, end_lon DOUBLE )
RETURNS DOUBLE DETERMINISTIC
RETURN 3959 *
acos(
cos( radians(start_lat) )
* cos( radians( end_lat ) )
* cos(
radians(end_lon) - radians(start_lon)
)
+ sin( radians(start_lat) )
@fitnr
fitnr / filter.handlebars
Last active March 24, 2020 18:43
Example of the filter helper in handlebars
---
animal: cat
mylist:
- dog
- bear
- cat
myprop: species
@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 / d3.geo.voronoi.js
Last active June 10, 2017 05:41
US Urban Areas Voronoi
(function() {
var π = Math.PI,
degrees = 180 / π,
radians = π / 180,
ε = 1e-15,
circle = d3.geo.circle().angle(90);
d3.geo.voronoi = function(points, triangles) {
if (arguments.length < 2) triangles = d3.geo.delaunay(points);
@fitnr
fitnr / county-epsg.csv
Last active April 10, 2024 21:33
List of State Plane coordinate systems and their various ID codes.
COUNTYFIPS NAME STATEPLANEFIPS EPSG
16079 Shoshone County 1103 26970
16073 Owyhee County 1103 26970
16071 Oneida County 1101 26968
16077 Power County 1101 26968
16075 Payette County 1103 26970
06115 Yuba County 0402 26942
06111 Ventura County 0405 26945
06113 Yolo County 0402 26942
31177 Washington County 2600 32104
@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 / websetup.md
Last active October 3, 2015 17:46
Setting up a local LAMP web server on OS X

Spinning up a local web server on OS X shouldn't be difficult, but it's a little fussy. This is a reminder list.

MySQL

Install MySQL

Update the path of the mysql socket. This fixes an OS X bug.

If you have a file at /tmp/mysql.sock but none at /var/mysql/mysql.sock, then: