This file contains 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
/** | |
This little helper creates bulk SQL insert queries like this: | |
INSERT INTO mytable (id, col1, col2) VALUES | |
(1, "col1value", "col2value"), | |
(2, "col1value", "col2value"), | |
(3, "col1value", "col2value"), | |
: | |
: | |
(4999, "col1value", "col2value"), |
This file contains 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
/** | |
* @author Jan Marsch (@kekscom) | |
* @example see http://jsfiddle.net/osmbuildings/2e5KX/5/ | |
* @example thickLineToPolygon([{x:50,y:155}, {x:75,y:150}, {x:100,y:100}, {x:50,y:100}], 20) | |
* @param polyline {array} a list of point objects in format {x:75,y:150} | |
* @param thickness {int} line thickness | |
*/ | |
var thickLineToPolygon = (function () { | |
function getOffsets(a, b, thickness) { |
This file contains 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 toLocalISOString(d) { | |
var off = d.getTimezoneOffset(); | |
return new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes() - off, d.getSeconds(), d.getMilliseconds()).toISOString(); | |
} |
This file contains 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
// <canvas> | |
var w = 600, h = 300; | |
var canvas = document.getElementsByTagName('CANVAS')[0]; | |
canvas.width = w; | |
canvas.height = h; | |
var context = canvas.getContext('2d'); |
This file contains 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 proj = require("proj4"); | |
proj.defs("EPSG:3068", "+proj=cass +lat_0=52.41864827777778 +lon_0=13.62720366666667 +x_0=40000 +y_0=10000 +ellps=bessel +datum=potsdam +units=m +no_defs"); | |
console.log(proj("EPSG:3068", "WGS84", [26197,19294])); |
This file contains 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; | |
}); | |
} |
This file contains 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 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 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 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; |
OlderNewer