Skip to content

Instantly share code, notes, and snippets.

@joebandenburg
joebandenburg / AppNav.js
Created July 24, 2015 08:46
Dockable LeftNav
class AppNav extends React.Component {
componentWillReceiveProps(nextProps) {
if (this.props.fixed !== nextProps.fixed) {
if (nextProps.fixed) {
this.refs.nav.open();
} else {
this.refs.nav.close();
}
}
}
@patmigliaccio
patmigliaccio / prettier-git-config.sh
Last active September 22, 2020 20:41
updates entire git repo history with prettier based on .prettierrc
#!/bin/sh
# Reference: https://medium.com/millennial-falcon-technology/reformatting-your-code-base-using-prettier-or-eslint-without-destroying-git-history-35052f3d853e
git filter-branch --tree-filter 'prettier --config ../../.prettierrc --write "src/{app,environments,assets}/**/*{.ts,.js,.json,.css,.scss}" || echo "formatting error"' -- --all
@ZogStriP
ZogStriP / ember.js-with-google-maps.html
Created May 31, 2013 13:32
How to use Google Maps with Ember.js
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.3/ember.js"></script>
<script src="//maps.googleapis.com/maps/api/js?sensor=false"></script>
</head>
<body>
<script>
@sibelius
sibelius / flow-redux.guideline.md
Created November 10, 2017 16:23
How to easily type Redux Props with Flow

How to easily type Redux Props with Flow

Add ExtractReturn helper

// https://hackernoon.com/redux-flow-type-getting-the-maximum-benefit-from-the-fewest-key-strokes-5c006c54ec87
// https://github.com/facebook/flow/issues/4002
// eslint-disable-next-line no-unused-vars
type _ExtractReturn<B, F: (...args: any[]) => B> = B;
export type ExtractReturn = _ExtractReturn&lt;*, F&gt;;
@JamieMason
JamieMason / deep-reduce.js
Last active June 14, 2021 05:20
Perform a deeply recursive reduce on a JSON-encodable JavaScript Object hierarchy.
/**
* Perform a deeply recursive reduce on a set of JSON, or a JSON-encodable Object hierarchy.
*
* @param {Array|Object} collection
* @param {Function} fn
* @param {*} memo
* @return {*}
*/
function deepReduce(collection, fn, memo) {
var gulp = require('gulp');
var path = require('path');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var reactify = require('reactify');
var watchify = require('watchify');
var util = require('gulp-util')
var less = require('gulp-less');
var clean = require('gulp-clean');
var plumber = require('gulp-plumber');
@FUT
FUT / install-redis.sh
Last active April 19, 2022 11:16
Install Redis on EC2
1. Install Linux updates, set time zones, followed by GCC and Make
sudo yum -y update
sudo ln -sf /usr/share/zoneinfo/America/Indianapolis \
/etc/localtime
sudo yum -y install gcc make
2. Download, Untar and Make Redis 2.8 (check here http://redis.io/download)
@sogko
sogko / app.js
Last active November 8, 2022 12:31
gulp + expressjs + nodemon + browser-sync
'use strict';
// simple express server
var express = require('express');
var app = express();
var router = express.Router();
app.use(express.static('public'));
app.get('/', function(req, res) {
res.sendfile('./public/index.html');
@victorquinn
victorquinn / promise_while_loop.js
Last active March 30, 2023 04:29
Promise "loop" using the Bluebird library
var Promise = require('bluebird');
var promiseWhile = function(condition, action) {
var resolver = Promise.defer();
var loop = function() {
if (!condition()) return resolver.resolve();
return Promise.cast(action())
.then(loop)
.catch(resolver.reject);
@jessefreeman
jessefreeman / layers_to_sprite_sheet.js
Created March 15, 2011 01:15
This is a PS script to make Sprite Sheets out of layers. Modified from http://www.garagegames.com/community/blogs/view/11527
// Put this file in Program Files\Adobe\Photoshop\Presets\Scripts\
// In PhotoShop menu File > Automate > Scripts: layersToSprite.js
// Arrange layers into a sprite sheet.
if (documents.length > 0)
{
// --------------------------
docRef = activeDocument;