Skip to content

Instantly share code, notes, and snippets.

/* Excerpted from https://github.com/mongodb/mongo/blob/ea83ad3103fef1664e9385d48537c4163344ce8a/src/mongo/util/debug_util.h#L37 */
// The following declare one unique counter per enclosing function.
// NOTE The implementation double-increments on a match, but we don't really care.
#define MONGO_SOMETIMES( occasion, howOften ) for( static unsigned occasion = 0; ++occasion % howOften == 0; )
#define SOMETIMES MONGO_SOMETIMES
#define MONGO_OCCASIONALLY SOMETIMES( occasionally, 16 )
#define OCCASIONALLY MONGO_OCCASIONALLY
@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