Skip to content

Instantly share code, notes, and snippets.

edwinwright / parse_dotenv.bash
Created Mar 6, 2019 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
View parse_dotenv.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)
View loadScript.js
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;
edwinwright /
Last active May 16, 2018
Change git commit history - amend user name and email
git filter-branch --env-filter '
NEW_NAME="New Name"
edwinwright / mocha-test-promises.js
Created Dec 4, 2017
Testing functions that return Promises in Mocha
View mocha-test-promises.js
// 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 /
Last active Nov 22, 2017
git hooks install script
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..."
edwinwright / injectScript.js
Created Jun 13, 2017
Promise based script loader
View injectScript.js
const injectScript = (function() {
const scripts = {};
return (url) => {
if (scripts[url]) {
return scripts[url];
} else {
const promise = new Promise((resolve, reject) => {
const head = document.getElementsByTagName('head')[0];
const script = document.createElement('script');
script.type = 'text/javascript';
edwinwright / index.js
Last active Oct 10, 2016
RequireBin - Flattening Marvel API response with normalizr
View index.js
const response = {
"code": 200,
"status": "Ok",
"copyright": "© 2016 MARVEL",
"attributionText": "Data provided by Marvel. © 2016 MARVEL",
"attributionHTML": "<a href=\"\">Data provided by Marvel. © 2016 MARVEL</a>",
"etag": "2f08937547f5cbb41e1f5845f9b3adf36417e332",
"data": {
"offset": 0,
"limit": 20,
edwinwright /
Created Sep 6, 2016 — forked from cobyism/
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

edwinwright /
Last active May 29, 2018
Naming things in web development
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.