Skip to content

Instantly share code, notes, and snippets.

🔥
making stuff faster

Vladimir Agafonkin mourner

🔥
making stuff faster
Block or report user

Report or block mourner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mourner
mourner / geobuf2.proto
Last active Aug 29, 2015
A new take on Geobuf compact geospatial encoding format
View geobuf2.proto
option optimize_for = LITE_RUNTIME;
message Data {
message FeatureCollection {
repeated Feature features = 1;
}
message Feature {
@mourner
mourner / vector_tile.js
Last active Aug 29, 2015
How a generated pbf encoding/decoding code should look
View vector_tile.js
'use strict';
exports.Tile = {read: readTile, write: writeTile};
exports.Layer = {read: readLayer, write: writeLayer};
exports.Feature = {read: readFeature, write: writeFeature};
exports.Value = {read: readValue, write: writeValue};
// decoding vector tile
function readTile(pbf, end) {
@mourner
mourner / test.js
Last active Aug 29, 2015
simple benchmarking snippet for v8 & node
View test.js
function test() {
for (var i = 0, array = []; i < 1000; i++) array.push(i, i);
}
var start = Date.now(), ops = 0;
do { test(); ops++; } while (Date.now() - start < 1000);
(typeof console !== 'undefined' ? console.log : print)(ops + ' ops/s');
@mourner
mourner / bench-node.js
Last active Aug 29, 2015
A simple benchmark snippet for Node; simple alternative to benchmark.js
View bench-node.js
var start = now(),
ops = 0;
while (now() - start < 1) {
// [...] routine to bench goes here
ops++;
}
console.log(Math.round(ops / (now() - start)) + ' ops/s');
@mourner
mourner / earcut.d.ts
Last active Aug 29, 2015
mapbox/earcut type definitions
View earcut.d.ts
// TypeScript type definitions to use for reference when porting Earcut to other languages
declare module 'earcut' {
interface Point extends Array<number> {}
interface Ring extends Array<Point> {}
interface Polygon extends Array<Ring> {}
interface Triangles extends Array<Point> {}
View touchzoom-fix.diff
diff --git a/src/layer/tile/GridLayer.js b/src/layer/tile/GridLayer.js
index d98994f..596d47f 100644
--- a/src/layer/tile/GridLayer.js
+++ b/src/layer/tile/GridLayer.js
@@ -301,26 +301,29 @@ L.GridLayer = L.Layer.extend({
},
_viewReset: function (e) {
- var map = this._map;
- this._reset(map.getCenter(), map.getZoom(), e && e.hard);
@mourner
mourner / index.html
Last active Aug 29, 2015
reqAnimFrame animation vs CSS transition performance
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Animation Test</title>
<style>
html, body {
height: 100%;
}
button {
View docs.js
/*
@class Control.Attribution
@aka L.Control.Attribution; @inherits Control
The attribution control allows you to display attribution data in a small text box on a map.
It is put on the map by default unless you set its [`attributionControl` option](#map-attributioncontrol) to `false`,
and it fetches attribution texts from layers with the [`getAttribution` method](#layer-getattribution) automatically.
Extends Control.
*/
@mourner
mourner / equation.html
Created Jul 7, 2011
Brute-force JS solution for Xopus task (see http://goo.gl/Zy0a9)
View equation.html
<!DOCTYPE html>
<head>
<title>Test</title>
</head>
<body>
<button onclick="displayResult()">Search</button>
<script>
var numEvals;
function displayResult() {
@mourner
mourner / convert.js
Created Sep 30, 2015
A proof of concept for efficient point encoding in vector tiles
View convert.js
var tile = require('./points.json');
tile.layers.forEach(function (layer) {
layer.id = [];
layer.geometry = [];
layer.tags = [];
var x0 = 0;
You can’t perform that action at this time.