Skip to content

Instantly share code, notes, and snippets.

View OliverJAsh's full-sized avatar

Oliver Joseph Ash OliverJAsh

View GitHub Profile
@domenic
domenic / combinators.js
Last active May 18, 2019 01:15
Promise combinators
Promise.all = iterable => {
return new this((resolve, reject) => {
const values = [];
let countdown = 0;
let index = 0;
for (let nextValue of iterable) {
const nextPromise = this.resolve(nextValue);
const countdownFunction = makeCountdownFunction(index);
/**
* Create an array with `len` elements.
*
* @param [initFunc] Optional: a function that returns
* the elements with which to fill the array.
* If the function is omitted, all elements are `undefined`.
* `initFunc` receives a single parameter: the index of an element.
*/
function initArray(len, initFunc) {
if (typeof initFunc !== 'function') {
var _ = require('lodash')
module.exports = function (actual, expected, ignoreObjectLength, ignoreFunctions) {
/* jshint maxcomplexity: 7 */
if (arguments.length < 2) {
throw new Error('Not enough arguments')
}
@ryanflorence
ryanflorence / angular.js
Last active October 30, 2019 01:42
Comparing an avatar implementation with angular and ember. http://www.angularails.com/articles/creating_simple_directive_in_angular
// Because people can't seem to find the gist description, here is the source
// of this code, a post found in last weeks JS Weekly, it is not my code
// http://www.angularails.com/articles/creating_simple_directive_in_angular
angular.module('ui-multi-gravatar', [])
.directive('multiAvatar', ['md5', function (md5) {
return {
restrict: 'E',
link:function(scope, element, attrs) {

Bower Import

Goal

To be able to install a package from bower and require it into your application with AMD (or ES6 module syntax if using and ES6 to AMD transpiler). For now it is a separate library to be used as a bower postintall script but the hope is to get it into bower by default.

@sindresorhus
sindresorhus / post-merge
Created September 6, 2013 15:46
Git hook to install npm dependencies after a `git pull`. Run `chmod +x post-merge` and put it in `.git/hooks/`. Though could really do whatever.
#!/bin/sh
npm install
@searls
searls / git-unpull
Created August 29, 2013 11:15
a handy way to unpull a pull that bit off more than you could chew.
#!/bin/bash
git reset --hard HEAD@{1}
@stuartsierra
stuartsierra / fresh-chrome.sh
Last active September 12, 2024 19:01
Launch new instances of Google Chrome on OS X with isolated cache, cookies, and user config
#!/usr/bin/env bash
# fresh-chrome
#
# Use this script on OS X to launch a new instance of Google Chrome
# with its own empty cache, cookies, and user configuration.
#
# The first time you run this script, it will launch a new Google
# Chrome instance with a permanent user-data directory, which you can
# customize below. Perform any initial setup you want to keep on every
@getify
getify / only-gate.js
Last active July 10, 2018 12:42
asynquence: sequences & gates at a glance. https://github.com/getify/asynquence
ASQ()
.all( // or .gate(..)
// these 3 run "in parallel"
function(done){ setTimeout(done,100); },
function(done){ setTimeout(done,200); },
function(done){ setTimeout(done,300); }
)
.then(function(){
alert("All tasks are complete, and that only took ~300ms, not 600ms!");
});