Skip to content

Instantly share code, notes, and snippets.

@matthijsln
matthijsln / .bashrc
Last active January 4, 2022 16:13
Bash prompt with Git and Docker context
source ~/docker-context-ps1.sh
PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\]$(__git_ps1)$(docker-context)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] '
@matthijsln
matthijsln / ol2-wmts-nl.html
Created February 24, 2021 12:36
OpenLayers 2 WMTS KVP/REST PDOK OpenBasiskaart
<!DOCTYPE html>
<html>
<head>
<title>OpenLayers 2 WMTS</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta charset="utf-8" />
<style type="text/css">
html, body {
height: 100%;
padding: 0;
@matthijsln
matthijsln / compare-brt-new.js
Created February 19, 2021 16:46
node: maak gifs om oude en nieuwe brtachtergrondkaart tiles te vergelijken
// Requires ImageMagicks' 'convert' executable in path
const http = require('https');
const fs = require('fs');
const { execSync } = require('child_process');
const tileMatrixSet = 'EPSG:28992';
const testLocations = [
[6, 30, 29],
[9,224,234],
@matthijsln
matthijsln / gist:ddcbb44cc7dc12202f6251135c9f91f8
Last active January 24, 2020 10:15
git prune local branches gone on remote
git config --global alias.prune-branches '!git remote prune origin && git branch -vv | grep '"'"': gone]'"'"' | awk '"'"'{print $1}'"'"' | xargs -r git branch -d'
git config --global alias.prune-branches-force '!git remote prune origin && git branch -vv | grep '"'"': gone]'"'"' | awk '"'"'{print $1}'"'"' | xargs -r git branch -D'
git config --global alias.prune-tags '!git fetch --prune origin +refs/tags/*:refs/tags/*'
@matthijsln
matthijsln / gist:3302366
Created August 9, 2012 08:38
Find the indexes before or after a specified index in a sparse array
/**
* Finds the index in the (sparse) array with the greatest index that is
* smaller than the given search index.
* If no indexes are smaller than search, -Number.MAX_VALUE is returned.
* If all indexes are smaller than search, null is returned.
* If the array is empty, null is returned.
*/
function findElementBefore(a, search) {
if(!(a instanceof Array)) {
throw "findElementBefore only works on arrays";
@matthijsln
matthijsln / wfs_get.sh
Created July 27, 2012 09:40
Simple script to retrieve all features from a WFS
#!/bin/bash
# wfs_get.sh by <matthijsln@gmail.com>
WFS_URL=$1
TYPENAME_REGEXP=$2
if [ -z $WFS_URL ]; then
echo Simple script to retrieve all features from a WFS
echo usage: wfs_get.sh wfs_url [typename_regexp]
exit 1