Skip to content

Instantly share code, notes, and snippets.

@grrowl
grrowl / consolefix.js
Last active Aug 29, 2015
<IE8 JS Console fixer
View consolefix.js
if (typeof window.console === "undefined") {
var methods = ['log', 'info', 'error', 'debug', 'warn', 'assert', 'clear', 'dir', 'trace', 'time', 'timeEnd'];
console = {};
for (var key in methods)
console[methods[key]] = function () {};
}
@grrowl
grrowl / awesomecss.md
Last active Aug 29, 2015
Awesome CSS (and other front-end goodies)
View awesomecss.md

Awesome CSS

A starting point for awesome CSS (and Sass, and Less) resources, inspired by Awesome Awesomeness everywhere. Still fleshing this out as I go, feel free to fork/contribute.

Structure

Tools

@grrowl
grrowl / host-matching-proposal.md
Last active Aug 29, 2015
Subdomain/host matching in react-router
View host-matching-proposal.md

We have a rapidly growing React application which renders on both the server- and client-sides. Some sections of the app are on separate subdomains. The same app uses the same assets across many subdomains, so we control it all through the one runtime. This mean react-router needs to be able to distinguish which host or subdomain it's on.

Proposal

  • HostRoute which subclasses Route and is aware of the host via a static method HostRoute.setHost(url.parse(res.url).hostname)
  • Static method called before Router.run() (on init of app) i.e. HostRoute.setHost(url.parse(req.url).hostname) and/or HostRoute.setHost(window.location.hostname)
  • Makes sense, since host will never change during the lifetime of the application, a significantly lighter approach and "opt-in" for those who require it.
  • Will require addition to modules/Match to ask the Route itself if it might be a match (if host matc
@grrowl
grrowl / forward80.sh
Created Sep 23, 2015
Forwards port 80 to another port (*nix, OSX up to 10.11)
View forward80.sh
#!/usr/bin/env sh
sudo ssh -L 0.0.0.0:80:127.0.0.1:9000 -N tom@localhost
@grrowl
grrowl / fetchDataComponent.jsx
Last active Oct 19, 2015
redux and react-router helper to provide (dispatch, storeState) to a static fetchData method
View fetchDataComponent.jsx
'use strict';
/*
# FetchData
If property callback `if(storeState)` return true, calls property callback
`fetchData(dispatch, storeState)` so it may dispatch FETCH actions.
## Usage:
@grrowl
grrowl / flattenjson.html
Last active Jan 2, 2016
Flattens multi-level JSON objects (useful for converting complex JSON to CSV format)
View flattenjson.html
<style>
textarea { height: 400px; width: 100%; }
</style>
<h1>flatten json</h1>
<textarea id="data">[]</textarea>
<button id="goByLine">line-by-line</button>
<button id="goWhole">as whole object</button>
<textarea id="result"></textarea>
@grrowl
grrowl / code-review.sh
Created Jun 2, 2016
code-review.sh <branch to review> [<base branch>]
View code-review.sh
#!/bin/bash
DEFAULT_BASE="develop"
if [ -z "$*" ]; then echo "Usage: code-review.sh [review branch] [case compare branch]"; exit 0; fi
REVIEW_BRANCH=$1
BASE_BRANCH=${2-$DEFAULT_BASE}
echo "Checking out $REVIEW_BRANCH"
@grrowl
grrowl / githubDelayedMerge.user.js
Created May 10, 2016
GitHub: click anywhere on the "merge message" (with disabled button) and it'll wait until the button enables and click it for you.
View githubDelayedMerge.user.js
(function () {
function handleLoaded() {
var butan = document.querySelector('.merge-message .btn[disabled]')
var checkTimer;
if (butan) {
butan.parentElement.addEventListener('click', function handleClick(event) {
if (checkTimer) {
@grrowl
grrowl / README.md
Last active Nov 20, 2016 — forked from christophermanning/README.md
Voronoi Diagram with Force Directed Nodes and Delaunay Links
View README.md

Created by Christopher Manning

Summary

Nodes are linked to nodes in neighboring cells. The cell's color is a function of its area.

The white lines are the Delaunay triangulation and the purple cells are the Voronoi diagram.

Controls

View scuttlebutt-compact.md
  • when should this compacter run?
    • every n actions added (compactEvery)
    • when history is at n length (highWaterMark, compactAtLength)
  • can the function signal when it should?
    • run the compacter every time
    • needs a private state (below) or
    • getCompacter({ n, highwater }) => compactingDispatcher()

we can compactingReducer, basically searches the last 50 actions for "stop" or