Skip to content

Instantly share code, notes, and snippets.

@edwinwright
edwinwright / D3 Scatterplot Chart.md
Last active March 11, 2022 13:24
Population by City (+100k)

A scatterplot chart representing the following variables:

  • x: longitude (quantitive)
  • y: latitude (quantitive)
  • area: population (quantitive)
  • color: population (quantitive)
const unordered = {
b: "foo",
c: "bar",
a: "baz",
};
console.log(JSON.stringify(unordered));
// → '{"b":"foo","c":"bar","a":"baz"}'
const ordered = Object.keys(unordered)
@edwinwright
edwinwright / circ-dep-plugin-config.js
Created November 30, 2021 10:53 — forked from sfrieson/circ-dep-plugin-config.js
Custom configuration around the circular-dependency-plugin to help avoid new ones.
const CircularDependencyPlugin = require('circular-dependency-plugin');
const CIRC_DEP_MAX = 238;
const defaultConfig = {
aggregateDirDepth: 2,
exclude: /node_modules/,
include: /.*/,
logWarnings: true,
logErrors: true,
@edwinwright
edwinwright / macos-app-icon.md
Created August 22, 2019 19:17 — forked from jamieweavis/macos-app-icon.md
How to make an app icon for macOS using iconset & iconutil

How to create a .icns macOS app icon

How to make an app icon for macOS using iconset & iconutil

Saving images

Save your app icon with the following names & dimensions:

Name Dimensions
icon_16x16.png 16x16
@edwinwright
edwinwright / parse_dotenv.bash
Created March 6, 2019 10:50 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
function loadScript(url, callback) {
var script = document.createElement("script")
script.type = "text/javascript";
if (script.readyState) {
script.onreadystatechange = function () {
if (script.readyState === "loaded" || script.readyState === "complete") {
script.onreadystatechange = null;
callback();
}
};
@edwinwright
edwinwright / README.md
Last active May 29, 2018 08:22
Naming things in web development
@edwinwright
edwinwright / amend-git-commit-user.sh
Last active May 16, 2018 14:11
Change git commit history - amend user name and email
git filter-branch --env-filter '
OLD_EMAIL="old@email.com"
NEW_NAME="New Name"
NEW_EMAIL="new@email.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
@edwinwright
edwinwright / mocha-test-promises.js
Created December 4, 2017 17:44
Testing functions that return Promises in Mocha
// Basic verification
// Returns the promise from somethingAsync()
// The test passes if resolved, fails if rejected
it('does something async with promises', function() {
return somethingAsync();
});
// Verify a fulfilled promise
// Returns the promise from somethingAsync() and runs assertions in the onFulfilled callback
@edwinwright
edwinwright / install-hooks.sh
Last active November 22, 2017 14:27
git hooks install script
#!/bin/bash
HOOK_NAMES="pre-commit"
HOOK_DIR=$(git rev-parse --show-toplevel)/.git/hooks
INSTALL_DIR=$(git rev-parse --show-toplevel)/hooks
COLOR_GREEN=`tput setaf 2`
COLOR_RESET=`tput sgr0`
for hook in $HOOK_NAMES; do
echo "Installing $hook hook..."