Skip to content

Instantly share code, notes, and snippets.


Manuel Strehl Boldewyn

View GitHub Profile
deebloo / shadow-element.ts
Last active January 25, 2023 22:04
Small utility for apply html template and construct-able stylesheets to custom elements.
View shadow-element.ts
import { shadow, ShadowTemplate, html, css } from './shadow.js';
const template: ShadowTemplate = {
css: css`
:host {
display: contents;
html: html`
barryosull / index.php
Created February 28, 2020 10:32
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 December 18, 2020 08:51
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>.
claytonrcarter /
Last active January 5, 2023 10:17
Bash script to check GitLab pipeline status

A super simple bash script to check the status of a GitLab CI pipeline.

$ git push
$ git pipeline-status
Status of last pipeline for user/project on gitlab/master:
$ git pipeline-status
sirbrillig / functions.php
Last active January 2, 2023 14:45 — 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 January 4, 2017 15:16
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 January 26, 2023 22:58
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.