Skip to content

Instantly share code, notes, and snippets.


Manuel Strehl Boldewyn

View GitHub Profile
barryosull / index.php
Created Feb 28, 2020
PHPUnit Code Coverage Report of Web App
View index.php
How to run a code coverage report on a web page:
Simply put this code after the vendor require and before the rest of the calling logic.
(Assumes you have PHPUnit installed)
require_once __DIR__ . "/../vendor/autoload.php";
View inputmode-detect-and-track.js
(function () {
var previousInputMode = false;
var inputMode = (function() {
try {
var inputMode = window.sessionStorage.getItem('inputMode');
if (!inputMode) {
return undefined;
if ( {'set', 'dimension1', inputMode);
veltman /
Last active Dec 18, 2020
Centerline label placement

Implementing a variation of Joachim Ungar's curved label placement method described here. The basic process is:

  1. Turn the shape into a polygon of evenly-spaced points.
  2. Generate a Voronoi diagram of those points.
  3. Clip the edges.
  4. Turn the edges into a graph.
  5. Find the "longest shortest path" between any pair of perimeter nodes.
  6. Smooth/simplify that path a bit.
  7. Place text along the smoothed centerline with a <textPath>.
sirbrillig / functions.php
Last active Sep 28, 2022 — forked from UmeshSingla/functions.php
Post file using wp_remote_post in WordPress
View functions.php
$local_file = 'file_path'; //path to a local file on your server
$post_fields = array(
'name' => 'value',
$boundary = wp_generate_password( 24 );
$headers = array(
'content-type' => 'multipart/form-data; boundary=' . $boundary,
View zip-vs-array-from.js
// Lazy (=on-demand) zip()
for (const [i, x] of zip(naturalNumbers(), naturalNumbers())) {
console.log(i, x);
if (i >= 2) break;
// Output:
// 0 0
// 1 1
// 2 2
bloodyowl / Component.js
Created Jan 4, 2017
Component library in less than 140 bytes
View Component.js
b=0;$=x=>(p,i="_"+b++,u=($[i]=q=>eval(i).innerHTML=x(p,$[q],u),z=>($[++b]=z,`$.${i}(${b})`)))=>`<c id=${i}>${x(p,[]._,u)}</c>`
Rich-Harris /
Last active Sep 12, 2022
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

gwillem / ansible-bootstrap-ubuntu-16.04.yml
Created Jun 16, 2016
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
View ansible-bootstrap-ubuntu-16.04.yml
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
- hosts: all
gather_facts: False
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
View AWS, ELB, CF and Let's Encrypt
Elastic Load Balancer, CloudFront and Let's Encrypt