Skip to content

Instantly share code, notes, and snippets.


Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
paulirish /
Last active Oct 16, 2021
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
IanColdwater / twittermute.txt
Last active Oct 15, 2021
Here are some terms to mute on Twitter to clean your timeline up a bit.
View twittermute.txt
Mute these words in your settings here:
timo22345 / flatten.js
Last active Oct 9, 2021
Flatten.js, general SVG flattener. Flattens transformations of SVG shapes and paths. All shapes and path commands are supported.
View flatten.js
<!doctype html>
<title>Flatten.js, General SVG Flattener</title>
Random path and shape generator, flattener test base:
Basic usage example:
View ImprovedNoise.js
var ImprovedNoise = function () {
var p = [151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,
jashkenas /
Last active Sep 22, 2021
Why Semantic Versioning Isn't

Spurred by recent events (, this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

But Semantic Versioning (henceforth, SemVer), as specified at, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

SemVer tries to compress a huge amount of information — the nature of the change, the percentage of users that wil

fperez /
Created Jan 8, 2012
IPython 0.0.1, a simple script to be loaded as $PYTHONSTARTUP: of historical interest only...
#!/usr/bin/env python
Interactive execution with automatic history, tries to mimic Mathematica's
prompt system. This environment's main features are:
- Numbered prompts (In/Out) similar to Mathematica. Only actions that produce
output (NOT assingments, for example) affect the counter and cache.
- The following GLOBAL variables always exist (so don't overwrite them!):
_p: stores previous result which generated printable output.
gruber / Liberal Regex Pattern for All URLs
Last active Aug 27, 2021
Liberal, Accurate Regex Pattern for Matching All URLs
View Liberal Regex Pattern for All URLs
The regex patterns in this gist are intended to match any URLs,
including "", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
# Single-line version of pattern:
mzheng / venmo_csv.txt
Last active Aug 27, 2021
Download Venmo Transactions as CSV
View venmo_csv.txt
JQ: brew install jq
Chrome/Safari Inspector
Log in and open
Open Chrome/Safari Inspector
Go to Network Tab and filter for 'feed'
Right click and Save "feed" as "venmo_feed.json"
Run in Terminal:
cat venmo_feed.json | jq '.data[] | {actor:, target: .transactions[0], type: .type, message: .message, date: .created_time, amount: .transactions[0].amount}' | jq -s -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' > venmo_feed.csv
Miserlou / cities.json
Created Apr 30, 2015
1000 Largest US Cities By Population With Geographic Coordinates, in JSON
View cities.json
"city": "New York",
"growth_from_2000_to_2013": "4.8%",
"latitude": 40.7127837,
"longitude": -74.0059413,
"population": "8405837",
"rank": "1",
"state": "New York"