Skip to content

Instantly share code, notes, and snippets.

@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 / Twitter.gs
Created Apr 27, 2016
Google Docs script to automate Twitter posting
View Twitter.gs
// source: https://ctrlq.org/code/19702-twitter-image-upload
function autoTweet() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("schedule"); // This must match the sheet name!
var rows = sheet.getRange("A:D").getValues();
var titleList = [], newValues = [],
response, doc, title;
var twitterCallback = function(rowIndex, err, result) {
@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 / 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 / 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 / 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 / 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>