Skip to content

Instantly share code, notes, and snippets.

View jelmervdl's full-sized avatar

Jelmer jelmervdl

View GitHub Profile
@jelmervdl
jelmervdl / getlayeratpoint.js
Created March 12, 2017 23:00
Leaflet function to get a layer at a certain point. Supports polygons and multipolygons with holes.
function pointInRing(point, vs)
{
var x = point[0], y = point[1];
var inside = false;
for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
var xi = vs[i][0], yi = vs[i][1];
var xj = vs[j][0], yj = vs[j][1];
var intersect = ((yi > y) != (yj > y))
@jelmervdl
jelmervdl / README.md
Last active March 22, 2017 16:42
ibood announcer

iBOOD Hunt Announcer

Na de bel hoor je voortaan wat de volgende hunt is!

Installeren

  1. Installeer eerst de Tampermonkey plugin in Chrome.
  2. Ga daarna naar deze pagina (hey!) en klink op het 'RAW' knopje bij het script hierboven.
  3. Als het goed is opent Tampermonkey nu en installeert hij het script
  4. Ga naar http://iboodhunt.1dagskoopjes.nl/ en laat de pagina open staan. Direct na de bel hoor je wat de nieuwe hunt is :)
@jelmervdl
jelmervdl / seed-cache.html
Created April 15, 2017 14:05
Geoserver Tile Cache seeding tool
<!DOCTYPE html>
<html>
<head>
<title>Seed tool</title>
<style>
.seed-status {
display: inline-block;
padding; 2px;
background: #ccc;
}
@jelmervdl
jelmervdl / convert.sh
Created July 31, 2017 11:32
iPhone ringtone
ffmpeg -i "$INPUT" -ac 1 -ab 128000 -acodec aac -f mp4 "$OUTPUT"
@jelmervdl
jelmervdl / parser.py
Created August 23, 2017 11:49
Small (and inefficient) parser in Python that can deal with ambiguity
from pprint import pprint
class l(object):
__slots__ = ('word',)
def __init__(self, word):
self.word = word
def __repr__(self):
return 'l({})'.format(self.word)
@jelmervdl
jelmervdl / array_path.php
Created October 17, 2017 10:16
Traverse a nested PHP array/object structure using a path
<?php
function array_path($array, $path, $default_value = null)
{
// Construct the path
if (!preg_match('/^(?P<head>\w+)(?P<rest>(\[\w+\]|->\w+)*)$/', $path, $match))
throw new InvalidArgumentException("The path '$path' is malformed");
$steps = [['index' => $match['head']]];
@jelmervdl
jelmervdl / led-sf-00297.conf
Last active January 21, 2018 17:21
LIRC remote configuration for Aldi RGB-LED Flex Band Set light strip (LED-SF-00297) http://woodsgood.ca/projects/2015/02/13/rgb-led-strip-controllers-ir-codes/
begin remote
name LED-SF-00297
flags SPACE_ENC|CONST_LENGTH
eps 20
aeps 200
bits 32
header 9000 4500
one 560 1690
zero 560 560
var PDOKGeocoder = L.Class.extend({
options: {
suggestUrl: 'https://geodata.nationaalgeoregister.nl/locatieserver/v3/suggest',
lookupUrl: 'https://geodata.nationaalgeoregister.nl/locatieserver/v3/lookup',
geocodingQueryParams: {
wt: 'json'
}
},
initialize: function(options) {
@jelmervdl
jelmervdl / natsort.py
Created February 8, 2018 12:43
Natural sorting in python (i.e. treat numbers as numbers)
items = [
'a.5.b.1',
'a.1.b.4',
'a.1.b.14',
]
def natcast(item):
if item.isdigit():
return int(item)
else:
#!/usr/bin/env python3
import site
site.addsitedir('env/src/tmxutil')
import sys
import re
from datetime import datetime
from tmxutil import make_reader, TMXWriter
from collections import defaultdict
from logging import getLogger, ERROR