Skip to content

Instantly share code, notes, and snippets.

View gerred's full-sized avatar
:octocat:

Gerred Dillon gerred

:octocat:
View GitHub Profile
@gerred
gerred / utils.js
Created February 5, 2012 04:18
My window.requestAnimationFrame shim
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = (window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback) {
return window.setTimeout(callback, 1000/60);
});
}
@gerred
gerred / gist:1936251
Created February 28, 2012 23:44 — forked from rolo/gist:1481128
Install Postgres 9.1, PostGIS and create PostGIS template on Ubuntu 11.10 Oneiric Ocelot
#!/bin/bash
#
# Install Postgres 9.1, PostGIS and create PostGIS template on a clean Ubuntu 11.10 Oneiric Ocelot box
# http://wildfish.com
# add the ubuntu gis ppa
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
@gerred
gerred / gist:1951643
Created March 1, 2012 17:47 — forked from rolo/gist:1481128
Install Postgres 9.1, PostGIS and create PostGIS template on Ubuntu 11.10 Oneiric Ocelot
#!/bin/bash
#
# Install Postgres 9.1, PostGIS and create PostGIS template on a clean Ubuntu 11.10 Oneiric Ocelot box
# http://wildfish.com
# add the ubuntu gis ppa
sudo apt-get -y install python-software-properties
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
{
id: "163943",
factual_id: "a5c5daa8-44e6-40e1-8919-d2a35d4461d0",
name: "Leader's Challenge",
address: "1600 Broadway",
address_extended: "Ste 1460",
po_box: null,
locality: "Denver",
region: "CO",
country: "US",
[
{
id: "6",
altitude: null,
content: null,
vqr_type: null,
feed_type: null,
channel: null,
user_id: null,
place_id: "175278",
EXPLAIN ANALYZE SELECT places.*,
(SELECT COUNT(*) FROM vqrs WHERE vqrs.place_id = places.id) vqr_count,
ST_Distance(location, 'POINT(-104.987389 39.741727)')/1000/1.609344 d
FROM places
WHERE places.region = 'CO' AND
places.locality = 'Denver' AND
ST_DWithin(location, 'POINT(-104.987389 39.741727)', 845.344, false)
ORDER BY d ASC
LIMIT 20
;
EXPLAIN ANALYZE SELECT places.*,
(SELECT COUNT(*) FROM vqrs WHERE vqrs.place_id = places.id) vqr_count,
ST_Distance(location, 'POINT(-104.987389 39.741727)')/1000/1.609344 d,
rtrim(split_part(ST_AsText(places.location), ' ', 2), ')') lat,
ltrim(split_part(ST_AsText(places.location), ' ', 1), 'POINT(') long
FROM places
WHERE places.region = 'CO' AND
places.locality = 'Denver' AND
ST_DWithin(location, 'POINT(-104.987389 39.741727)', 845.344, false)
ORDER BY d ASC
@gerred
gerred / stream_server.js
Created April 3, 2012 03:23
Streaming image resizing down http
var http = require('http'),
fs = require('fs'),
gm = require('gm');
var server = http.createServer(function(req, res) {
var readStream = fs.createReadStream(__dirname + "/neckbeard.jpeg");
res.writeHead(200, {'Content-Type': 'image/jpeg'});
gm(readStream, 'neckbeard.jpeg')
.resize('200', '200')
@gerred
gerred / iosd
Created May 4, 2012 20:23 — forked from buritica/iosd
Enable Remote Inspector on Mobile Safari
#!/bin/bash
# Open iPhone Simulator on default location for XCode 4.3 if found
[[ -d /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/ ]] &&
open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
# Open iPhone Simulator on default location for XCode 4.2 if found
[[ -d /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/ ]] &&
open /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
@gerred
gerred / polyfill.js
Created May 29, 2012 15:34
Canvas Polyfill
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|| window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)