Skip to content

Instantly share code, notes, and snippets.

View exogen's full-sized avatar

Brian Beck exogen

View GitHub Profile
@exogen
exogen / chart.jsx
Created October 22, 2015 05:54
Current per-datum style
<VictoryChart
interpolation="basis"
axisLabels={{x: "x axis", y: "y axis"}}
x={[
[1, 2, 3, 4],
[-2, -1, 0, 1, 3],
[3, 4, 6]
]}
y={[
[1, 2, 10, 4],
import React from 'react';
import ReactDOM from 'react-dom';
import Playground from 'component-playground';
const examples = {
block: require('raw!./examples/block.example')
}
class Demo extends React.Component {
render() {
@exogen
exogen / script.js
Last active October 8, 2015 21:49
Correct atomic-callback-on-execute async script loading
/**
* Script loading is difficult thanks to IE. We need callbacks to fire
* immediately following the script's execution, with no other scripts
* running in between. If other scripts on the page are able to run
* between our script and its callback, bad things can happen, such as
* `jQuery.noConflict` not being called in time, resulting in plugins
* latching onto our version of jQuery, etc.
*
* For IE<10 we use a relatively well-documented 'preloading' strategy,
* which ensures that the script is ready to execute *before* appending
@exogen
exogen / DefaultKeyBinding.dict
Last active June 7, 2016 21:00
Fix Mac smart quote shortcuts
// Put this file at ~/Library/KeyBindings/DefaultKeyBinding.dict
// You may need to run: mkdir ~/Library/KeyBindings
{
"~[" = (insertText:, "\U2018"); // Option-[ inserts left single quote
"~]" = (insertText:, "\U2019"); // Option-] inserts right single quote
"~{" = (insertText:, "\U201c"); // Option-Shift-[ inserts left double quote
"~}" = (insertText:, "\U201d"); // Option-Shift-] inserts right double quote
}
@exogen
exogen / play
Last active August 29, 2015 14:13
Instantly play the first result from YouTube
#!/bin/bash
# Usage: play bizarre love triangle
# Arguments are joined so no quotes are needed.
# NOTE: $TMPDIR (on Mac at least) already ends in a slash.
youtube-dl --default-search "ytsearch" \
--restrict-filenames \
--output "${TMPDIR:-/tmp/}%(title)s-%(id)s.%(ext)s" \
--exec afplay "$*"
// Default mixin settings
@spinner-default-color: #000;
@spinner-default-size: 16px;
// Opacity, spacing, speed
@spinner-opacity: 70%; // Opacity of the brightest dot
@spinner-decay: 0.7; // Opacity of each dot compared to the previous
@spinner-spacing: 1; // Distance multiplier between dots
@spinner-duration: 1s; // Time it takes for one revolution
@exogen
exogen / drive
Last active August 29, 2015 13:57
#!/bin/bash -e
# Google Drive file selector by Brian Beck.
# Latest version: https://gist.github.com/exogen/9817479
command -v selecta >/dev/null 2>&1 || {
echo >&2 "This utility requires selecta to be installed:"
echo >&2
echo >&2 " https://github.com/garybernhardt/selecta"
echo >&2
@exogen
exogen / rgb2hex
Created October 13, 2011 21:23
Convert RGB values to hex and copy the result to the clipboard (Mac)
#!/bin/bash
# rgb2hex -- Convert RGB values to hex and copy the result to the clipboard (Mac)
# usage: rgb2hex [r] [g] [b]
hex=$(python -c "print '#%02x%02x%02x' % (${1:-0}, ${2:-0}, ${3:-0})")
echo -n $hex | pbcopy
echo $hex
@exogen
exogen / test.coffee
Created September 23, 2011 17:46
Bug in coffee.vim
# Go to the #{lol} line and press 'o'.
rofl = """
#{lol}
"""
@exogen
exogen / TemplateEngine.coffee
Created September 22, 2011 23:03
Milk (Mustache) template engine for Knockout
ko = require 'knockout'
Milk = require 'milk'
class Template
constructor: (@string) ->
render: (data, options) =>
# Knockout expects an Array-like object of Nodes.
# We could just use createElement and set innerHTML,
# but apparently jQuery's append does some kind of cleanup.