Skip to content

Instantly share code, notes, and snippets.

paullewis / requestIdleCallback.js
Last active Nov 25, 2020
Shims rIC in case a browser doesn't support it.
View requestIdleCallback.js
* Copyright 2015 Google Inc. All rights reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
ha404 /
Last active Jan 18, 2018
Airbnb JavaScript Style Guide() {

Quick start guide to using Airbnb's style with ESLint.

  1. Navigate to your project directory and run this:
npx install-peerdeps --dev eslint-config-airbnb
  1. Save an .eslintrc file in your project directory:
maisano / RouteTransition.jsx
Last active Jan 21, 2019
Using react-motion with react-router
View RouteTransition.jsx
import React, { PropTypes } from 'react';
import { TransitionMotion, spring } from 'react-motion';
* One example of using react-motion (0.3.0) within react-router (v1.0.0-rc3).
* Usage is simple, and really only requires two things–both of which are
* injected into your app via react-router–pathname and children:
* <RouteTransition pathname={this.props.pathname}>

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

DanHerbert /
Last active Dec 27, 2020
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

READ THIS Very Important Update

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

octocat / .gitignore
Created Feb 27, 2014
Some common .gitignore configurations
View .gitignore
# Compiled source #
# Packages #
dergachev /
Last active Jan 14, 2021
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF


To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

fortybillion / _css3.scss
Created May 14, 2012
Common CSS3 mixins for SASS
View _css3.scss
/* Commonly used mixins for CSS3 in SASS
by Ben Sargent (2012)
/* generically prefix any property name */
@mixin prefix($name, $value) {
-webkit-#{$name}: $value;
-moz-#{$name}: $value;
mikebucks / jq_check.js
Created Apr 2, 2012
Check for jQuery and add it if needed
View jq_check.js
var hasjQuery = false;
jQueryCheck = function() {
if (! window.jQuery) {
if (! hasjQuery) {
hasjQuery = true;
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '';
efedorenko / gist:2028193
Created Mar 13, 2012
Function for alpha blending
View gist:2028193
// Turns out this function already exists in Sass: mix(fg, bg, %) (
// Alpha blending
@function blend($bg, $fg) {
$r: red($fg) * alpha($fg) + red($bg) * (1 - alpha($fg));
$g: green($fg) * alpha($fg) + green($bg) * (1 - alpha($fg));
$b: blue($fg) * alpha($fg) + blue($bg) * (1 - alpha($fg));
You can’t perform that action at this time.