Skip to content

Instantly share code, notes, and snippets.


Per Liedman perliedman

View GitHub Profile
perliedman / gist:9528322
Created Mar 13, 2014
Console logging to page
View gist:9528322
var _log = console.log;
console.log = function() {
var e = document.getElementById('log'),
for (i = 0; i < arguments.length; i++) {
e.innerHTML = e.innerHTML + arguments[i] + '\n';

Keybase proof

I hereby claim:

  • I am perliedman on github.
  • I am 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 / index.js
Created Aug 8, 2014
requirebin sketch
View index.js
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');
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 / log-object.js
Created Oct 6, 2014
Explode an object to the console
View log-object.js
function logObject(o, indent) {
var keys;
indent = indent || '';
try {
keys = Object.keys(o);
} catch (e) {
console.log(indent + '=' + o.toString());
View distance-matrix.js
var request = require('simple-get'),
extend = require('extend');
function DistanceMatrix(features, options) {
this.options = extend({}, { serviceUrl: ''}, options);
this._features = features.features.reduce(function(fs, f, i) {
if (f.geometry.type !== 'Point') {
throw 'Feature geometries must be Points.';
perliedman / README.markdown
Created Mar 26, 2012 — forked from jrust/README.markdown
Bootstrap's Typeahead plugin extended (AJAX functionality, comma-separated values, autowidth, and autoselect)
View README.markdown

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 / gist:3665685
Created Sep 7, 2012
Markers with Leaflet.iconlabel plugin (, which at least for me appear with an increasing offset. I believe this is a bug.
View gist:3665685
<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" type="text/css" href=""/>
<link rel="stylesheet" type="text/css" href=''/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script src=''></script>
perliedman /
Created Nov 22, 2012
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
# Create a clean slate
perliedman / osm-test.js
Created Oct 28, 2015
node-osmium area test
View osm-test.js
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(),],
extentPolygon = bboxPolygon(extent);