Skip to content

Instantly share code, notes, and snippets.

@tschaub
tschaub / use-chai.js
Last active June 24, 2026 19:21
Replace the use of expect.js with assert from chai.js
/**
* A transform for use with jscodeshift that replaces expect.js assertions with
* assert style assertions from Chai.
*
* Example use on a directory:
*
* git checkout -- test && npx jscodeshift --transform use-chai.js --extensions js test
*
*/
@tschaub
tschaub / tools-as-depdendencies.md
Last active September 29, 2024 14:00
Reproducible module builds with tools (commands) as dependencies

Tools as dependencies

This example is a slight tweak on the best-practices example for working with Go modules as development dependencies.

The downside of the existing example is that someone who git clones your module to make a contribution, would not be able to run go generate (without extra work).

$ go generate
painkiller.go:5: running "stringer": exec: "stringer": executable file not found in $PATH
/**
* 1. Go to http://labs.strava.com/gpx-to-route/
* 2. Enter a Strava activity URL
* 3. Run this snippet
*/
map.eachLayer(layer => {
if (layer.getLatLngs) {
const coordinates = layer.getLatLngs().map(latLng => {
return [latLng.lng, latLng.lat];
});
@tschaub
tschaub / index.html
Last active March 28, 2017 00:12
Test polyfill.io Promise in a Worker
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test Promise.resolve() in a Worker</title>
</head>
<body>
This is a simple smoke test for <code>Promise.resolve()</code> in a Worker.
You should see an alert telling you if things worked or not.
<script src="./main.js"></script>
@tschaub
tschaub / .gitignore
Last active January 20, 2023 14:23
OpenLayers + Webpack
/node_modules/
bundle.js
@tschaub
tschaub / .gitignore
Last active April 25, 2019 22:34
OpenLayers + Rollup
/node_modules/
bundle.js
@tschaub
tschaub / _.md
Last active December 15, 2025 13:58
TopoJSON Time Zones

TopoJSON Time Zones

The result is this 181 KB timezones.json (36 KB with gzip)

@tschaub
tschaub / git-tidy-alias.sh
Last active August 24, 2021 19:02
Prune all remotes and delete all branches that are already merged into the current branch
git config --global alias.tidy '!for r in `git remote`; do git remote prune $r; done && git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'
#!/bin/bash
set -o errexit
# This script gives you git bash completion and a minimal
# prompt displaying the branch name.
PROFILE=""
if [ -f "$HOME/.bashrc" ]; then
PROFILE="$HOME/.bashrc"
elif [ -f "$HOME/.bash_profile" ]; then
@tschaub
tschaub / 1-geoserver-scripting.md
Last active August 29, 2015 13:56
Build GeoServer with scripting support

Build GeoTools:

cd ~/projects/geotools
mvn clean install -DskipTests -T 4C

(Skip the -T 4C for Maven 2.)

Build GeoServer and prep Eclipse project:

cd ~/projects/geoserver/src