Skip to content

Instantly share code, notes, and snippets.

Avatar

Per Liedman perliedman

View GitHub Profile
View network.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View rankme-stats.txt
perl 0.60 2482
larchii 1.51 2988
Frog's Theme 1.02 2735
jntn 1.13 2617
vico 0.74 2395
arniestone 0.38 2002
ouilly_bob 0.64 2455
ulken 0.91 2512
wishpishh 1.19 2454
mikael.egner 0.25 1130
@perliedman
perliedman / click-through-layers.js
Created Mar 7, 2017
Click through multiple layers of Leaflet VectorGrid
View click-through-layers.js
// Since overlays are VectorGrid layers with canvas rendering,
// they don't support clicking through them (the topmost canvas
// swallows the event, lower layers will not see it).
// We workaround this by this hack (inspired by
// http://www.vinylfox.com/forwarding-mouse-events-through-layers/):
//
// All overlays are in their own Leaflet pane. When a click hits a
// layer in the pane, we first handle the event like normal, and then
// hit the event handler below this comment.
//
View round-robin-route-control.js
var RoundRobinPlan = L.Routing.Plan.extend({
initialize: function(waypoints, options) {
L.Routing.Plan.prototype.initialize.call(this, waypoints, options);
},
dragNewWaypoint: function(e) {
var nWps = this._waypoints.length,
insertionIndex = e.afterIndex > nWps - 1 ? 0 : e.afterIndex + 1,
i,
marker,
@perliedman
perliedman / secondsToTime.js
Created Oct 27, 2016
Convert a number of seconds as integer to a string of hours, minutes and seconds (HH:MM:SS)
View secondsToTime.js
var secondsToTime = function(s) {
var pad = function(v) {
return v < 10 ? '0' + v : v.toString();
}
var result = '';
for (var i = 0; i < 3; i++) {
result = pad(s % 60) + (i ? ':' : '') + result;
s = Math.floor(s / 60);
}
View proj-unproj.sh
#!/bin/bash
LL="31 70"
P0=`echo $LL | cs2cs +proj=longlat +datum=WGS84 +no_defs +to +proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs`
for I in `seq 1 10`;
do
P=`echo $LL | cs2cs +proj=longlat +datum=WGS84 +no_defs +to +proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs`
LL=`echo $P | cs2cs -I +proj=longlat +datum=WGS84 +no_defs +to +proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs`
done
@perliedman
perliedman / leaflet_1_0.svg
Last active Apr 18, 2016
Leaflet-1.0-verified
View leaflet_1_0.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View leaflet-plugins.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 6 columns, instead of 4. in line 8.
Name,Era,Last commit,URL,Maintainer,Maintainer URL
azgs-leaflet,really old,2012-05-02T00:22:23Z,https://github.com/azgs/azgs-leaflet,AZGS,https://github.com/azgs
RaphaelLayer,0.5,2013-01-17T12:42:48Z,http://dynmeth.github.com/RaphaelLayer/,Dynamic Methods,https://github.com/dynmeth
Leaflet.MultiTileLayer,0.5,2013-02-25T16:34:13Z,https://github.com/mattiasb/Leaflet.MultiTileLayer,Mattias Bengtsson,https://github.com/mattiasb
leaflet.pouch,0.5,2013-04-25T18:01:21Z,https://github.com/calvinmetcalf/leaflet.pouch,Calvin Metcalf,https://github.com/calvinmetcalf/
Leaflet.RevealOSM,0.5,2013-05-28T13:06:41Z,https://github.com/yohanboniface/Leaflet.RevealOSM,Yohan Boniface,http://yohanboniface.me
leaflet.zoomfs,0.6,2013-07-28T19:21:50Z,http://elidupuis.github.com/leaflet.zoomfs,Eli Dupuis,https://github.com/elidupuis
Leaflet.BorderPan,0.6,2013-08-09T01:49:26Z,https://github.com/slara/Leaflet.BorderPan,Sebastián Lara,https://github.com/slara
Leaflet.dbpediaLayer,0.6,2013-09-14T21:51:05Z,https://github.com/kr1/Leaflet.db
@perliedman
perliedman / extract_plugin_data.py
Last active Apr 18, 2016
Extract data about Leaflet Plugins
View extract_plugin_data.py
#!/usr/bin/python
import re
from bs4 import BeautifulSoup
import urllib2
import csv
from datetime import datetime
from agithub import Github
View leaflet-reveal-unzoom.js
L.Map.addInitHook(function() {
var slides = document.querySelector('.slides'),
zoom = Number(slides.style.zoom);
// Reveal.js sometimes use the zoom CSS property, but sometimes a scale
// transform instead. We handle both.
if (zoom) {
this._container.style.zoom = 1/zoom;
} else {
zoom = Number(slides.style.transform.replace(/.*scale\(([0-9\.]+)\).*/, '$1'));
You can’t perform that action at this time.