Skip to content

Instantly share code, notes, and snippets.

@perliedman
perliedman / gist:9528322
Created March 13, 2014 13:21
Console logging to page
var _log = console.log;
console.log = function() {
var e = document.getElementById('log'),
i;
for (i = 0; i < arguments.length; i++) {
e.innerHTML = e.innerHTML + arguments[i] + '\n';
}
@perliedman
perliedman / keybase.md
Created April 7, 2014 07:06
keybase.md

Keybase proof

I hereby claim:

  • I am perliedman on github.
  • I am liedman (https://keybase.io/liedman) on keybase.
  • I have a public key whose fingerprint is 555C 82CE 057A 1598 9580 BD5A 95EE 964B 2EA9 FB22

To claim this, I am signing this object:

def unhash(h):
s = ''
letters = 'acdegilmnoprstuw'
while h > 7:
v = h % 37
s = letters[v] + s
h /= 37
return s
@perliedman
perliedman / index.js
Created August 8, 2014 13:39
requirebin sketch
var fs = require('fs');
var svg = require('svg-sketch')();
var size = [400, 400];
var concat = require('concat-stream');
var Pdf = require('svg-sketch-pdf');
var controls = require('svg-sketch-controls');
controls.control.setPaperSize(size);
var iframe = document.createElement('iframe');
iframe.setAttribute('style', 'width: 400px; height: 400px; border: solid 2px #888; border-radius: 5px; position: fixed; top: 0; left: 0');
@perliedman
perliedman / log-object.js
Created October 6, 2014 13:34
Explode an object to the console
function logObject(o, indent) {
var keys;
indent = indent || '';
try {
keys = Object.keys(o);
} catch (e) {
console.log(indent + '=' + o.toString());
return;
@perliedman
perliedman / distance-matrix.js
Created September 4, 2015 14:40
OSRM Distance Matrix
var request = require('simple-get'),
extend = require('extend');
function DistanceMatrix(features, options) {
this.options = extend({}, { serviceUrl: 'http://router.project-osrm.org/table'}, options);
this._features = features.features.reduce(function(fs, f, i) {
if (f.geometry.type !== 'Point') {
throw 'Feature geometries must be Points.';
}
@perliedman
perliedman / README.markdown
Created March 26, 2012 12:17 — forked from jrust/README.markdown
Bootstrap's Typeahead plugin extended (AJAX functionality, comma-separated values, autowidth, and autoselect)

This is a fork of a fork of Bootstrap Typeahead that adds minimal but powerful extensions.

  • Support for delaying the lookup (good for preventing too many AJAX requests)
  • Some fixes regarding the data fed to the onselect callback

For the proper source, and other examples, please see the original gist and the extended version

Example showing off all the above features

@perliedman
perliedman / gist:3665685
Created September 7, 2012 12:12
Markers with Leaflet.iconlabel plugin (https://github.com/jacobtoye/Leaflet.iconlabel), which at least for me appear with an increasing offset. I believe this is a bug.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Gypsum</title>
<link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet-0.4.4/leaflet.css"/>
<link rel="stylesheet" type="text/css" href='https://raw.github.com/jacobtoye/Leaflet.iconlabel/master/dist/leaflet.iconlabel.css'/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src='http://cdn.leafletjs.com/leaflet-0.4.4/leaflet.js'></script>
@perliedman
perliedman / import_gsd.sh
Created November 22, 2012 08:33
Import Lantmäteriverket's GSD shape files into a PostGIS database
# Imports all GSD shape data to a database.
# NOTE: If the db exists, it is *dropped* before importing any data
DB=lmv
GSD_PATH=/media/local/MapData/lmv-shape
SQL_LOG=/dev/null
ERROR_LOG=gsd_import.log
# Create a clean slate
rm $SQL_LOG
@perliedman
perliedman / osm-test.js
Created October 28, 2015 21:59
node-osmium area test
var osmium = require('osmium');
var bboxPolygon = require('turf-bbox-polygon');
var path = process.argv[2];
var reader = new osmium.BasicReader(path);
var handler = new osmium.Handler();
var locHandler = new osmium.LocationHandler();
var header = reader.header();
var bound = header.bounds[0],
extent = [bound.left(),bound.bottom(),bound.right(),bound.top()],
extentPolygon = bboxPolygon(extent);