Skip to content

Instantly share code, notes, and snippets.

Mathias Bynens mathiasbynens

View GitHub Profile
mathiasbynens / .gitignore
Last active Mar 5, 2019
Unicode version diff for ECMAScript
View .gitignore
View find-new-Lo-code-points.js
const compare = (versionA, versionB) => {
// TODO: Does there exist a path for which every single Unicode version
// gets new entries? If so, use that instead.
const path = 'General_Category/Other_Letter';
const before = new Set(require(
`unicode-${ versionA }/${ path }/code-points.js`
const after = require(
`unicode-${ versionB }/${ path }/code-points.js`
#!/usr/bin/env bash
curl -#s "${url}" | \
base64 --decode | \
sed '/^ *\/\// d' | \
sed '/^\s*$/d' > hsts.json;
mathiasbynens / bf.js
Created Jul 17, 2015
How many hex-formatted Unicode code points can be mistaken for a number in scientific notation? Which ones are those?
View bf.js
'use strict';
const pad = function(string) {
const totalCharacters = 4;
return string.length < totalCharacters ?
(Array(totalCharacters + 1).join('0') + string).slice(-totalCharacters) :
const UNICODE_MIN = 0x0;
mathiasbynens /
Last active Jun 20, 2017
Superfish certificate
View output.txt

Someone tried to exploit the Shellshock vulnerability in Bash on, likely as part of a mass-exploit attempt.

In this case, the exploit attempted to download a modified version of @schierlm’s pseudo-terminal Perl script that would connect to on port 23. The download URL contains the targeted host name (? which gives the attacker an indication of which hosts might have the /tmp/ backdoor in place.

mathiasbynens / regex-lone-surrogates.js
Created May 26, 2014
A regular expression to match lone surrogates only
View regex-lone-surrogates.js
var assert = require('assert');
// The goal is to match lone surrogates, i.e. any high surrogates
// (`[\uD800-\uDBFF]`) that are not directly followed by a low surrogate
// (`[\uDC00-\uDFFF]`), and any low surrogates (`[\uDC00-\uDFFF]`) that are not
// directly preceded by a high surrogate (`[\uD800-\uDBFF]`).
var regex = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
assert.equal(regex.test('foo\uDC00bar'), true);
You can’t perform that action at this time.