Skip to content

Instantly share code, notes, and snippets.

@benjamw
benjamw / bc4trialreset.cmd
Created January 25, 2021 20:27 — forked from zsoumya/bc4trialreset.cmd
Beyond Compare 4 Trial Reset
reg delete "HKCU\Software\Scooter Software\Beyond Compare 4" /v CacheID /f
@benjamw
benjamw / visualize-stacking-contexts.js
Last active June 11, 2018 19:33 — forked from tlrobinson/visualize-stacking-contexts.js
Some console output to help you visualise stacking contexts on a page (no jquery)
/*
Usage:
* Paste this into your dev tools console (or even better as a snippet)
* It will parse the page and find all the things that create a new stacking context
and dump some info about them to the console. It will also outline them on the page.
* This is pretty rough and probably misses heaps of bugs and edge cases.
*/
function highlight(el) {
@benjamw
benjamw / visualize-stacking-contexts.js
Created June 11, 2018 19:29 — forked from eoinkelly/visualize-stacking-contexts.js
Some console output to help you visualise stacking contexts on a page
/*
Usage:
* Paste this into your dev tools console (or even better as a snippet)
* It will parse the page and find all the things that create a new stacking context
and dump some info about them to the console. It will also outline them on the page.
* This is pretty rough and probably misses heaps of bugs and edge cases.
*/
@benjamw
benjamw / main.go
Created November 2, 2017 21:01
Scan and sort
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
// See page 17.
//!+
// Fetchall fetches URLs in parallel and reports their times and sizes.
package main
import (
@benjamw
benjamw / safe.js
Last active March 21, 2017 05:09
JavaScript safe access of deeply nested objects
// https://medium.com/javascript-inside/safely-accessing-deeply-nested-values-in-javascript-99bf72a0855a#.wc89qfbqv
// get returns the element given by path p from object o, returning default d if not found
var get = function(p, o, d) {
return p.reduce( function(xs, x) {
return (xs && xs[x]) ? xs[x] : d;
}, o);
};
// usage:
@benjamw
benjamw / index.html
Last active September 22, 2016 16:18
Material Style Alternating Spinner
<div class="loader">
<svg width="2.4em" height="2.4em">
<!-- unit circle -->
<circle cx="1.2em" cy="1.2em" r="1em"/>
</svg>
</div>
@benjamw
benjamw / index.html
Last active September 22, 2016 15:55
Material Style Spinner
<div class="loader">
<svg width="2.4em" height="2.4em">
<!-- unit circle -->
<circle cx="1.2em" cy="1.2em" r="1em"/>
</svg>
</div>
@benjamw
benjamw / my_round.php
Last active September 25, 2015 04:51
<?php
/** function my_round
*
* rounds a value to the closest value
* starting at another value
* e.g.- my_round(6.28318, 5, 2) => 7
*
* To round to closest of:
* 2 6 10 14 18 22 ...
; // the thing
(function($) {
"use strict";
/**
* The Thing
*
* @constructor
*/