Skip to content

Instantly share code, notes, and snippets.

@grrowl
grrowl / README.md
Last active November 20, 2016 08:27 — forked from christophermanning/README.md
Voronoi Diagram with Force Directed Nodes and Delaunay Links

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

@grrowl
grrowl / githubDelayedMerge.user.js
Created May 10, 2016 07:46
GitHub: click anywhere on the "merge message" (with disabled button) and it'll wait until the button enables and click it for you.
(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 / code-review.sh
Created June 2, 2016 00:10
code-review.sh <branch to review> [<base branch>]
#!/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 / flattenjson.html
Last active January 2, 2016 08:29
Flattens multi-level JSON objects (useful for converting complex JSON to CSV format)
<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 / fetchDataComponent.jsx
Last active October 19, 2015 20:33
redux and react-router helper to provide (dispatch, storeState) to a static fetchData method
'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 / forward80.sh
Created September 23, 2015 00:30
Forwards port 80 to another port (*nix, OSX up to 10.11)
#!/usr/bin/env sh
sudo ssh -L 0.0.0.0:80:127.0.0.1:9000 -N tom@localhost
@grrowl
grrowl / host-matching-proposal.md
Last active August 29, 2015 14:16
Subdomain/host matching in react-router

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 / awesomecss.md
Last active August 29, 2015 14:05
Awesome CSS (and other front-end goodies)

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 / consolefix.js
Last active August 29, 2015 13:56
<IE8 JS Console fixer
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 () {};
}