Skip to content

Instantly share code, notes, and snippets.

@nelhage
nelhage / gist:6545782
Created September 13, 2013 01:01
git-drunk
NAME
git-drunk - An alcoholic celebration of version control
SYNOPSIS
git drunk [-s | --shots] [-i | --iced] [--alcohol=<beverage>]
[--mixer=<mixer>] [--shaken | --stirred] [--girly]
[--garnish=<...>] [--class=bouncy|smashy]
git drunk [--drinking-game=gitionary|...]
DESCRIPTION
@nelhage
nelhage / gist:6042538
Created July 19, 2013 21:35
bash globbing
[nelhage@aeronautique:~]$ echo hello?
hello?
[nelhage@aeronautique:~]$ shopt -s failglob
[nelhage@aeronautique:~]$ echo hello?
bash: no match: hello?
[nelhage@aeronautique:~]$ shopt -s nullglob
[nelhage@aeronautique:~]$ shopt -u failglob
[nelhage@aeronautique:~]$ echo hello?
[nelhage@aeronautique:~]$
*.pyc
[nelhage@aeronautique:/tmp]$ curl -s 'http://pastebin.com/raw.php?i=dAybWC0C' -o urls.raw
[nelhage@aeronautique:/tmp]$ tr -d '\r' < urls.raw | sed 's,\?.*,,' | sort -u > urls.uniq
[nelhage@aeronautique:/tmp]$ wc -l urls.uniq
750 urls.uniq
[nelhage@aeronautique:/tmp]$ perl -lane 'print $1 if m{/(\d{4}/\d{2}/\d{2})/}' urls.uniq | sort | uniq -c | sort -rn | head
131 2013/06/11
116 2013/06/09
61 2013/06/12
45 2013/06/10
38 2013/06/06
[nelhage@aeronautique:/tmp/tmp.cF4Y5zMVY1]$ mkdir a b
[nelhage@aeronautique:/tmp/tmp.cF4Y5zMVY1]$ mkdir -p a/assets a/lib/assets
[nelhage@aeronautique:/tmp/tmp.cF4Y5zMVY1]$ touch a/assets/file
[nelhage@aeronautique:/tmp/tmp.cF4Y5zMVY1]$ touch a/lib/assets/file
[nelhage@aeronautique:/tmp/tmp.cF4Y5zMVY1]$ rsync -nPax --exclude='/assets/*' a/ b/
sending incremental file list
./
assets/
lib/
lib/assets/
+static inline gboolean
+is_domain_valid (const char *str)
+{
+ return (str && (strlen(str) >= 1) && (strlen(str) <= 255));
+}
+
[nelhage@aeronautique:~/stripe/simmer]$ cat test.in
top5:sum:merchant nelhage:1
top5:sum:merchant nelhage:2
top5:sum:merchant evan:1
sum:x 1
sum:x 2
sum:x 3
(GIT: master *=)
[nelhage@aeronautique:~/stripe/simmer]$ # bin/simmer -r localhost:6379 -f 0 < test.in
(GIT: master *=)
# The canonical version of this file lives at <https://gist.github.com/4507129>. Sorry for the redundant posts.
import sys
sys.path.append("/tmp/Numberjack.0.1.10-11-24/local_lib")
from Numberjack import *
import Mistral
class Puzzle(object):
def __init__(self, w, h):
self.model = Model()
self.width = w
self.height = h
@nelhage
nelhage / make_yaml_safe.rb
Last active December 10, 2015 23:08
Neuter YAML to help mitigate CVE-2013-0156-style attacks.
# The fact that YAML.load will instantiate arbitrary ruby objects
# means that calling `YAML.load` on untrusted data is virtually always
# equivalent to executing arbitrary code in a complex app.
# This code fragment globally neuters YAML to disable this behavior,
# which should (hopefully) cut off all such attacks from the start.
# I don't promise this closes all possible attacks, but this closes
# off the trivial case. You should audit and upgrade all your
# dependencies, as well.