This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'hallo_ballo:bla'.replace(/([^a-z0-9][a-z0-9])/ig, function($0, $1) { | |
return $1[1].toUpperCase(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const q = location.search.replace('?', ''); | |
const params = {}; | |
q.replace(/([^&=]+)=([^&]*)/g, ($0, $1, $2) => { | |
params[$1] = $2; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
renderLeft(); | |
var canvasData1 = context.getImageData(0, 0, WIDTH, HEIGHT); | |
renderRight(); | |
var canvasData2 = context.getImageData(0, 0, WIDTH, HEIGHT); | |
var | |
dataRed = canvasData1.data, | |
dataCyan = canvasData2.data, | |
R, G, B; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generate unique IDs for use as pseudo-private/protected names. | |
// Similar in concept to | |
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>. | |
// | |
// The goals of this function are twofold: | |
// | |
// * Provide a way to generate a string guaranteed to be unique when compared | |
// to other strings generated by this function. | |
// * Make the string complex enough that it is highly unlikely to be | |
// accidentally duplicated by hand (this is key if you're using `ID` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(m,k){ | |
if(m=location.href.match(/@([+\d,.-]+)/)) { | |
k=m[1].split(','); | |
location.href='http://www.openstreetmap.org/#map=Z/Y/X'.replace('X',k[1]).replace('Y',k[0]).replace('Z',k[2]); | |
} | |
}()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var json = '...'; // your truncated json data here | |
var chunk = json; | |
var m, q = false; | |
var stack = []; | |
while (m = chunk.match(/[^\{\[\]\}"]*([\{\[\]\}"])/)) { | |
switch (m[1]) { | |
case '{': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pattern(str, param, callback) { | |
return str.replace(/\{([\w_]+)\}/g, function(tag, key) { | |
return param[key] || tag; | |
}); | |
} |
NewerOlder