Apply a patch on the clipboard to the current Git/Hg repo:
pbpaste | patch -p1
Or, if the trailing "\n" is missing:
pbpaste | xargs -0 echo | patch -p1
#!/usr/bin/env ruby | |
# Publish documents on the internets! | |
# ----------------------------------- | |
# Copyright (c) 2011, David Chambers. | |
# * * * * * * * * * * * * * * * * * * | |
require 'base64' | |
require 'net/http' |
to_hash = (pairs) -> | |
hash = {} | |
hash[key] = value for [key, value] in pairs | |
hash | |
# usage: | |
to_hash ([n, n * n] for n in [0..5]) # {0:0, 1:1, 2:4, 3:9, 4:16, 5:25} |
escapeRegExpChars = (string) -> | |
# Copied from https://github.com/slevithan/XRegExp. | |
string.replace /[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&' | |
deconstructRegExp = (regexp) -> | |
/// ^/(.+)[/]([gimy]*)$ ///.exec regexp | |
# Create a pattern like the one provided, but with a start of string | |
# anchor: | |
# |
Action | |
------------------------------------ | |
Release Publish Configure | |
Project name on GitHub on npm Travis CI | |
------------------------------------------------------------ | |
airwaves (*) (*) (*) | |
an.hour.ago (*) (*) (*) | |
Base64.js (*) (*) (*) | |
CANON (*) (*) (*) | |
doctest (*) (*) ( ) |
#!/usr/bin/env python | |
import subprocess | |
import sys | |
args = sys.argv[1:] | |
if args in (['-h'], ['--help'], []): | |
print ''' |
(req, res) -> | |
# Attach language codes to request object. | |
h = req.headers['accept-language'] | |
req.languages = h and (/[^\s;-]+/.exec(l)[0] for l in h.split ',') or [] |
# Problem: Determine all the paths for a given node. | |
# | |
# A | |
# / \ | |
# / \ | |
# B C | |
# / \ \ | |
# / \ \ | |
# C D D | |
# \ |
Apply a patch on the clipboard to the current Git/Hg repo:
pbpaste | patch -p1
Or, if the trailing "\n" is missing:
pbpaste | xargs -0 echo | patch -p1
{abs, floor, round} = Math | |
# > @localize = (timestamp) -> | |
# . $.localize.format (new Date timestamp), new Date "1 Mar 2012 00:30:45" | |
# | |
# > localize "30 Jan 2012 23:59:59" | |
# "2012-01-30" | |
# > localize "31 Jan 2012 00:00:00" | |
# "30 days ago" | |
# > localize "28 Feb 2012 23:59:59" |
#!/usr/bin/env bash | |
echo | |
for filename in $(find $1); do | |
loc=$(sed /^\s*$/d $filename | wc -l) | |
printf %24s $(echo $filename | sed 's!.*/!!') | |
printf %8s $loc | |
echo -n ' ' | |
indent=$(seq -s ' ' 36 | sed s/[0-9]//g) | |
seq -s '+' $loc | sed -e s/[0-9]//g -e "s/.\{100\}/&,$indent/g" | tr , '\n' |