Skip to content

Instantly share code, notes, and snippets.

Avatar

Calvin Metcalf calvinmetcalf

View GitHub Profile
@calvinmetcalf
calvinmetcalf / footprint.py
Created Dec 7, 2012
grab all the new footprint shapefiles
View footprint.py
import urllib,os,zipfile,glob
base = "http://wsgw.mass.gov/data/gispub/shape/structures/structures_poly_"
def download():
for i in range(1,352):
i=str(i)
n = i+".zip"
b=base+n
urllib.urlretrieve(b,n)
@calvinmetcalf
calvinmetcalf / types.json
Created Dec 8, 2012
voter records street abreviations
View types.json
{"rows":[
{"key":"Aly","value":53},
{"key":"Anx","value":42},
{"key":"Ave","value":443940},
{"key":"Bch","value":60},
{"key":"Blf","value":73},
{"key":"Blfs","value":1},
{"key":"Blvd","value":13851},
{"key":"Bnd","value":176},
{"key":"Br","value":59},
@calvinmetcalf
calvinmetcalf / readme.md
Last active Mar 3, 2016
town pronounciations
View readme.md

Massachusetts Pronunciation Guide

From the Massachusetts Travel Survey, pulled out of the appendix and cleaned up.

The following list of Massachusetts cities and towns have somewhat unusual pronunciations. In addition to the text below, audio samples will be used to help interviewers to understand the local dialect. Please note that each interviewer will need to pass a pronunciation test demonstrating a general knowledge of the local dialect before being allowed to dial.

Note: Many, but not all, Massachusetts residents “drop their Rs” – meaning the vowel before the R is all that is heard. It often comes across as an “h” sound at the end of words. In most cases, it is not critical that you pronounce it this way, but the guide below is provided to help you understand the respondent. There are a few towns and cities to which you should pay particular attention, and they are marked with an asterisk (*):

Abington

@calvinmetcalf
calvinmetcalf / pouch.js
Created Jan 3, 2013
connect to a CouchDB that syncs locally to indexDB if available, if not tries webSQL, finally just follow the CouchDB directly.
View pouch.js
function pouchSync(dbURL,cb){
var dbName = dbURL.split("/").pop();
Pouch(dbName,function(err1,db1){
Pouch(dbUrl,function(err2,db2){
if (db1 && db2){
db1.replicate.from(db2,{continuous:true});
db1.replicate.to(db2,{continuous:true});
cb(null, db1);
}else if (db2){
cb(null, db2);
@calvinmetcalf
calvinmetcalf / pouch.basic.js
Last active Dec 10, 2015
pouchdb in javascript
View pouch.basic.js
var db,
cb = function(err,database){
if(err){
console.error("Bad Stuff happend");
}else{
console.log("good news!")
db=database;
}
};
Pouch("http://url.to.couchdb/dbname",cb);
View pouch.advanced.js
var db,
callback = function(err,database){
if(err){
console.error("Bad Stuff happend");
}else{
console.log("good news!")
db=database;
}
};
var makePouch = function(url,cb){
View pouch.idb.js
//GOOD NEWS, YOU CAN NOW OPEN POUCH SYNCRONOUSLY (god damn lack of spell checking in code pages)
/*var db,
cb = function(err,database){
if(err){
console.error("Bad Stuff happend");
}else{
console.log("good news!")
db=database;
}
View sync.js
var returnValue = function(a, b){return doStuff(a,b);}
//the program waits here until this finishes and then
//continues.
View async.js
var asyncExample = function(a,b,callback){
var returnValue,returnError;//define stuff
try { //do the stuff
returnValue = doStuff(a,b);
} catch(err) { //if there is an err catch it
returnError = err;
} finally { //send it back
callback(returnError, returnValue);
}
}//program will not have to wait
View callback.js
//if this is your callback
var callback = function(error,response){
if(error){
//code here would only run if error is truthy
}else{
//this only runs if !error ==- true
}
}
//you can also write that as