Skip to content

Instantly share code, notes, and snippets.

@JerrySievert
JerrySievert / gist:6286832
Created August 20, 2013 20:28
index logic
/*
"crime":
{
"equals": "arson"
}
index -> specific index that references the property keyword
query -> object containing the specific queries for the index
set -> object containing keys of all of the id's matching currently
@JerrySievert
JerrySievert / gist:6189314
Created August 8, 2013 22:16
building footprint processing for downtown portland
var JSONStream = require('JSONStream'),
fs = require('fs'),
Terraformer = require('Terraformer');
var incoming = fs.createReadStream("./buildings.json", { encoding: "utf8" });
var outgoing = fs.createWriteStream("./processed.json", { encoding: "utf8" });
var stream = JSONStream.parse(['features', true]);
var downtown = new Terraformer.Polygon(
@JerrySievert
JerrySievert / gist:5686043
Created May 31, 2013 16:08
geojson to esri json
work=# select geoJSONToEsri('{ "type": "Polygon",
"coordinates": [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
]
}', '{ "wkid": 4326 }');
geojsontoesri
--------------------------------------------------------------------------------
--------
{"rings":[[[100,0],[101,0],[101,1],[100,1],[100,0]]],"spatialReference":{"wkid"
@JerrySievert
JerrySievert / gist:5686037
Created May 31, 2013 16:06
esri json to geojson
work=# select esriToGeoJSON('{"rings":[[[100,0],[101,0],[101,1],[100,1],[100,0]]],"spatialReference":{"wkid":4326}}');
esritogeojson
------------------------------------------------------------------------------
{"type":"Polygon","coordinates":[[[100,0],[101,0],[101,1],[100,1],[100,0]]]}

How to use a PS3 controller on Mac OS X 10.7 (Lion)

  1. Open Apple menu -> System Preferences -> Bluetooth and disable Bluetooth on Mac as well as any other nearby Macs or devices which will try to pair with and confuse the controller.

  2. Reset PS3 controller by inserting paperclip into pinhole near L2 button.

  3. Connect PS3 controller to Mac with USB cable.

  4. Enable Bluetooth.

{"type":"MultiPolygon","coordinates":[[[[-123.00111,37.772053],[-122.997538,37.770784],[-122.99509,37.769131],[-122.987414,37.76387],[-122.981429,37.758916],[-122.977596,37.754976],[-122.975448,37.752585],[-122.974061,37.749929],[-122.973256,37.748652],[-122.970449,37.747818],[-122.967271,37.746303],[-122.964099,37.744281],[-122.961057,37.741955],[-122.958391,37.739734],[-122.95464,37.736827],[-122.949985,37.732187],[-122.945523,37.725314],[-122.942294,37.721057],[-122.939711,37.71535],[-122.937917,37.709956],[-122.937679,37.709241],[-122.935865,37.702459],[-122.93571,37.697618],[-122.937339,37.69093],[-122.939026,37.686544],[-122.939661,37.682353],[-122.941364,37.67658],[-122.945009,37.669773],[-122.949068,37.663377],[-122.954876,37.658348],[-122.963006,37.651984],[-122.973012,37.646581],[-122.980513,37.6439],[-122.986747,37.641783],[-122.992589,37.641016],[-123.000912,37.63993],[-123.00111,37.63983],[-123.00111,37.641775],[-123.011605,37.641506],[-123.027153,37.645221],[-123.040696,37.650328],[-123.05358,37
@JerrySievert
JerrySievert / gist:4247487
Created December 9, 2012 23:27
temperature from raspberry pi
#!/usr/bin/env node
var fs = require('fs');
function getTemperature (device) {
fs.readFile('/sys/bus/w1/devices/' + device + '/w1_slave', 'utf8', function (err, data) {
var output = data.match(/t=(\d+)/);
var calc = output[1] / 1000;
@JerrySievert
JerrySievert / triggers
Created November 14, 2012 00:24
trigger issue
DROP TABLE test_table CASCADE;
CREATE TABLE test_table (
id SERIAL PRIMARY KEY,
data VARCHAR
);
CREATE TABLE test_table_part () INHERITS (test_table);
CREATE OR REPLACE FUNCTION test_trigger_pre () RETURNS TRIGGER AS $$
@JerrySievert
JerrySievert / gist:3659672
Created September 6, 2012 19:19
incorrect safari try/catch behavior?
var err = function (m) {
throw {
m: m
};
};
try {
err("foo");
} catch (e) {
console.dir(e);
function(msg) {
if(/^taps/.test(msg.message)) {
var match = msg.message.match(/^taps\s+(.+)/);
var tap;
var taps = [ ];
json = http.get("http://visualizeapi.com/api/baileys");
feed = JSON.parse(json);
var tap_list = "Bailey's Taps: ";