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
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' |
decorate = (klass, methodName, fn) -> | |
method = klass::[methodName] | |
klass::[methodName] = (args...) -> | |
method.apply this, args | |
fn.apply this, args | |
# Example | |
decorate Array, 'push', (args...) -> |
#!/usr/bin/env python | |
import json | |
import re | |
import subprocess | |
import sys | |
if len(sys.argv) > 1: | |
lsregister = sys.argv[1] | |
else: |
A woman has two children, (at least) one of whom is a boy. What's the probability that she has two boys?
B B-B 1/4
/
/
B
/ \
/ \
/ G B-G 1/4
/
cheerio = require 'cheerio' | |
request = require 'request' | |
tutor = require 'tutor' | |
request 'http://www.wizards.com/magic/tcg/events.aspx?x=mtg/event/playerschamp/2012/cubepool', | |
(err, res, body) -> | |
throw err if err? | |
$ = cheerio.load body | |
names = $('a.nodec').map -> @text() |
# Takes a box (an array) and a function, f, which takes a continuation. | |
# A sentinel is placed in the box, then f is invoked. When f calls its | |
# continuation, c, the box is inspected. Only if the sentinel is still | |
# in the box will c in turn call its continuation. | |
# | |
# If several asynchronous requests are made in quick succession, the | |
# responses may not be received in the order in which they were sent. | |
# This function makes it possible to define a function to be invoked | |
# *unless the request has been superseded by the time it completes*. | |
skip_continuation_if_superseded = (box, f) -> |