Skip to content

Instantly share code, notes, and snippets.

View ianstormtaylor's full-sized avatar
🖖

Ian Storm Taylor ianstormtaylor

🖖
View GitHub Profile
@ianstormtaylor
ianstormtaylor / .bashrc
Created August 28, 2019 13:21
Aliases for nicer branching output from Git.
alias gb="git branch --sort=-committerdate --verbose --format='%(HEAD) %(color:red)%(objectname:short)%(color:reset) - %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) - %(color:green)(%(committerdate:relative))%(color:reset) %(color:blue)<%(authorname)>%(color:reset)'"
alias gba="gb -a"
@ianstormtaylor
ianstormtaylor / collapse-regex.js
Created March 8, 2019 02:41
A script that takes in a regex with lots of character ranges in it and prints out a "minified" version of the regex.
const regexes = {
'camel-case-regexp-1': /[a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u037

In REST you might do a basic filter like...

GET /books?status=published

Which in GraphQL could be...

import { createMatcher } from '../slate-plugin-utils'
/**
* A Slate plugin to reset empty blocks to a default type when the user presses
* backspace at the start of a block.
*
* @param {Object} opts
* @property {String} defaultType
* @property {Function || Array || String} ignoreIn
@ianstormtaylor
ianstormtaylor / css.js
Last active December 20, 2016 21:06
A simple wrapper around Glamor and Classnames that gives you everything you need for simple styling.
import classnames from 'classnames'
import { css as glamor } from 'glamor'
/**
* A thin wrapper around `glamor` to make it return class names.
*
* @param {Object} object
* @return {String}
*/
import React from 'react'
import css from 'glamor'
import { UI } from '../constants'
const styles = {
wrapper: css`
display: table;
width: 650px;
`,
@ianstormtaylor
ianstormtaylor / slate-node-portal.js
Created September 13, 2016 18:21
A React component example that makes it simple to position an element relative to a Slate node.
import React from 'react'
import Portal from 'react-portal'
import getOffsets from 'positions'
import { findDOMNode } from 'slate'
/**
* No-op.
*
* @type {Function}
@ianstormtaylor
ianstormtaylor / 0_reuse_code.js
Created August 10, 2016 16:39
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import { getDefaultKeyBinding } from 'draft-js'
/**
* Handle default key bindings.
*
* @param {Event} event
* @return {String} defaultCommand
*/