Skip to content

Instantly share code, notes, and snippets.

@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');
def unhash(h):
s = ''
letters = 'acdegilmnoprstuw'
while h > 7:
v = h % 37
s = letters[v] + s
h /= 37
return s
@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:

@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 / pouchdb-benchmark.js
Last active February 7, 2019 16:12
PouchDB Benchmark
var dbName = 'http://localhost:5984/couch-test',
nDocs = 10000,
batchSize = 1000,
scrapFactor = 0,
docs = [],
testQuery = 'entries/sumTime',
destroyDb = false,
_log = console.log,
db;
@perliedman
perliedman / number_tiles.py
Last active December 30, 2015 08:28
Calculate number of tiles in a tile set
from sys import argv
from math import ceil, floor
res = float(argv[1])
number_zoom_levels = int(argv[2])
tile_size = int(argv[3])
bbox = [float(v) for v in argv[4].split(',')]
total_tiles = 0
for z in xrange(0, number_zoom_levels + 1):
@perliedman
perliedman / geometrycollection.wkt
Created October 29, 2013 15:28
Problematic WKT
GEOMETRYCOLLECTION (LINESTRING (6308869.40378 356821.22669, 6308867.893 356822.41744, 6308852.75314 356830.22159, 6308869.92754 356844.26638), LINESTRING (6308755.07971 356674.51686, 6308784.81355 356719.16757, 6308815.20022 356765.46178, 6308829.63774 356763.22832, 6308852.87023 356759.82402, 6308867.19982 356771.06823, 6308875.40631 356796.20162, 6308872.51907 356815.17242), LINESTRING (6308874.12086 356813.73392, 6308876.83028 356795.77697, 6308868.23871 356770.06254, 6308853.09618 356758.29456, 6308815.86529 356763.89689, 6308799.76731 356739.37835, 6308747.77971 356662.11613, 6308746.55411 356661.61702, 6308744.06545 356657.72563, 6308731.77184 356668.45076, 6308699.45221 356683.15463, 6308682.44689 356684.63193, 6308654.96629 356683.66846, 6308636.13879 356680.0482, 6308618.19888 356671.76352, 6308608.41685 356661.79428, 6308578.7973 356592.35062, 6308545.33908 356542.14886, 6308517.52088 356509.38474, 6308505.40266 356506.84141, 6308493.59689 356506.98067, 6308375.07918 356520.46209), LINESTRING (63088
@perliedman
perliedman / map-design-cc.md
Created June 18, 2013 10:30
Map Design Crash Course

Map Design Crash Course

Overview

  • Spatial "raw" data is usually in vector form.
  • Nodes (sometimes called coordinates or vertices), sometimes connected to form lines, linestrings or polygons.

Some concepts in spatial geometry

@perliedman
perliedman / bin-grep.py
Created April 16, 2013 12:30
Simple utility to grep/find a byte pattern in a file. I can only assume you can use grep or some other utility to do this as well.
#!/usr/bin/python
from sys import argv
path = argv[1]
hex_pattern = argv[2]
str_pattern = "".join([chr(int(hex_pattern[x:x+2], 16)) for x in range(0,len(hex_pattern), 2)])
with open(path, 'r') as f:
@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