Skip to content

Instantly share code, notes, and snippets.

View kekscom's full-sized avatar

Jan Marsch kekscom

View GitHub Profile
function relax(callback, startIndex, dataLength, chunkSize, delay) {
chunkSize = chunkSize || 1000;
delay = delay || 1;
var endIndex = startIndex + Math.min((dataLength-startIndex), chunkSize);
if (startIndex === endIndex) {
return;
}
@kekscom
kekscom / gist:bd4e3d4e356f90050c77
Created November 9, 2015 13:16
Date() toISOString() incl. TZ offset
function formatLocalDate() {
var now = new Date(),
tzo = -now.getTimezoneOffset(),
dif = tzo >= 0 ? '+' : '-',
pad = function(num) {
var norm = Math.abs(Math.floor(num));
return (norm < 10 ? '0' : '') + norm;
};
return now.getFullYear()
+ '-' + pad(now.getMonth()+1)
@kekscom
kekscom / JS parse query string
Last active October 5, 2021 14:32
parse query string
const q = location.search.replace('?', '');
const params = {};
q.replace(/([^&=]+)=([^&]*)/g, ($0, $1, $2) => {
params[$1] = $2;
});
'hallo_ballo:bla'.replace(/([^a-z0-9][a-z0-9])/ig, function($0, $1) {
return $1[1].toUpperCase();
});
@kekscom
kekscom / gist:ac499df64c8d861776a61031d577d8bf
Created August 12, 2016 09:13
Split huge GeoJSON files into tiles
var tileSize = 256;
var zoom = 15;
var srcFile = 'huge.geojson';
var dstPath = 'tiles/';
var minX = Number.MAX_VALUE;
var maxX = 0;
var minY = Number.MAX_VALUE;
var maxY = 0;