Skip to content

Instantly share code, notes, and snippets.

@branneman
branneman / task-runner.js
Created April 21, 2016 08:32
Streaming task-runner (how gulp works, simplified)
'use strict';
const fs = require('fs');
const glob = require('glob').sync;
const mkdirp = require('mkdirp').sync;
const sass = require('node-sass');
const path = require('path');
const streams = require('stream');
const runner = {};
@btroncone
btroncone / ngrxintro.md
Last active February 9, 2024 15:37
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@amenuor
amenuor / gist:e7d1508a0bde196758b8
Created November 11, 2015 21:21
CORS on GraphQL Server from relay-starter-kit
import express from 'express';
import cors from 'cors';
import graphQLHTTP from 'express-graphql';
import path from 'path';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import {Schema} from './data/schema';
const APP_PORT = 3000;
const GRAPHQL_PORT = 8080;
@branneman
branneman / composition.js
Last active April 15, 2018 19:51
OO JavaScript: Inheritance vs. Composition
//
// hasPosition trait
//
const hasPosition = state => ({
setPosition: function(x, y) {
this.x = x;
this.y = y;
}.bind(state)
});
@Gaya
Gaya / responsive-svg-sprite-template.scss
Last active September 15, 2017 14:19
Responsive SVG Sprite Mixin
/*
* Generate a SVG-sprite mixin for Sass
* ====================================
*
* Gaya Kessler - http://gaya.ninja - http://twitter.com/GayaNinja
*
* SVGSprite is a wonderful package, but doesn't enable responsive sprites out of the box.
* This moustache template generates a sass file with a mixin for the generated SVG-sprite.
* Calculates the position and size of the background by filename.
* Included SVG image scales to width and height.
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@branneman
branneman / call-apply-bind-proxy.js
Last active February 22, 2024 21:06
JavaScript call() vs apply() vs bind() vs $.proxy()
var fn = function(arg1, arg2) {
var str = '<p>aap ' + this.noot + ' ' + arg1 + ' ' + arg2 + '</p>';
document.body.innerHTML += str;
};
var context = {
'noot': 'noot'
};
var args = ['mies', 'wim'];
// Calls a function with a given 'this' value and arguments provided individually.
@paulirish
paulirish / performance.now()-polyfill.js
Last active August 1, 2023 15:42
performance.now() polyfill (aka perf.now())
// @license http://opensource.org/licenses/MIT
// copyright Paul Irish 2015
// Date.now() is supported everywhere except IE8. For IE8 we use the Date.now polyfill
// github.com/Financial-Times/polyfill-service/blob/master/polyfills/Date.now/polyfill.js
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
// if you want values similar to what you'd get with real perf.now, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@paulirish
paulirish / rAF.js
Last active March 22, 2024 00:00
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];