Skip to content

Instantly share code, notes, and snippets.

View Scarysize's full-sized avatar

Franz Scarysize

View GitHub Profile
-- enable CSV import mode
.mode csv
-- define the CSV separator
.separator ','
-- import & create tables, this will not insert the header line of a CSV file as a row
.import input/shapes.txt shapes
.import input/stops.txt stops
.import input/stop_times.txt stop_times
@Scarysize
Scarysize / line-reader.js
Created November 2, 2017 21:23
Like Node.js 'readline' for HTML5 File API.
const DEFAULT_CHUNK_SIZE = 1024;
class LineReader {
constructor(options) {
this.chunkSize = options.chunkSize || DEFAULT_CHUNK_SIZE;
this.onLine = options.onLine;
this.onEnd = options.onEnd;
this.reader = new FileReader();
{
"start": 1496503113090,
"end": 1496509113090,
"line": {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
@Scarysize
Scarysize / parse.py
Created April 5, 2017 09:56
Handle (Geo-)JSON with python
import json
with open('path/to/json/file') as data_file:
# a python dictionary, similar to a JS object
data = json.load(data_file)
# iterate over features, 'features' is a python list
for feature in data['features']:
# access everything via brackets, no dot notation
properties = feature['properties']
@Scarysize
Scarysize / scrape-delicious.js
Last active February 18, 2017 11:47
Scrape delicious bookmarks as JSON
/*
1. install jsdom
2. Usage:
$ node scrape-delicious.js https://del.icio.us/<username>
3. writes data to "bookmarks.json"
*/
const jsdom = require('jsdom');
const fs = require('fs');
uniform float u_fade_t;
uniform float u_opacity;
uniform sampler2D u_image0;
uniform sampler2D u_image1;
varying vec2 v_pos0;
varying vec2 v_pos1;
uniform float u_brightness_low;
uniform float u_brightness_high;
populate(features, options) {
const layout = this.layers[0].layout;
const iconImage = layout['sdficon-image'];
const hasIcon = iconImage;
this.features = [];
if (!hasIcon) {
return;

Build the docker image and start the container.

Start Xvfb in the container via

$ /etc/init.d/xvfb start

Run Chrome with working WebGL in kiosk mode

import intersect from './intersect';
export default function createTileIntersect() {
let tileCache = {};
let lastBbox = null;
return (boundingBox, tile) => {
if (!boundingBox) {
return true;
}
function convert(lngLatBounds) {
return {
topLeft: {
lng: lngLatBounds.sw.lng,
lat: lngLatBounds.ne.lat
},
bottomRight: {
lng: lngLatBounds.ne.lng,
lat: lngLatBounds.sw.lat
}