This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import itertools | |
key_re = re.compile(r'(.*?)(\d*)$') | |
def string_key(s): | |
name, number = key_re.match(s).groups() | |
return (name, number and int(number)) | |
def group_key((i, (name, number))): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
class Meta(type): | |
def __init__(cls, name, bases, attrs): | |
for attr, value in attrs.items(): | |
if inspect.isfunction(value): | |
setattr(cls, attr, decorate(value)) | |
for base in bases: | |
for attr in dir(base): | |
value = getattr(base, attr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko = {}; | |
ko.Observable = function(value) { | |
this.value = value; | |
this.subscribers = []; | |
}; | |
ko.Observable.prototype.get = function() { | |
return this.value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Author: Brian Beck <[email protected]> | |
# Usage: watch PATH COMMAND... | |
# | |
# This script watches PATH and runs COMMAND whenever PATH or a descendent | |
# of PATH is modified. COMMAND is everything after the first argument. | |
# | |
# If PATH is "-", then the list of paths comes from standard input. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Go to the #{lol} line and press 'o'. | |
rofl = """ | |
#{lol} | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "$*" |
OlderNewer