Skip to content

Instantly share code, notes, and snippets.

+static inline gboolean
+is_domain_valid (const char *str)
+{
+ return (str && (strlen(str) >= 1) && (strlen(str) <= 255));
+}
+
[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/
[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
*.pyc
@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:~]$
@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
/* 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
package main
import "log"
func main() {
var a [128]byte
log.Printf("len(a) = %d", len(a))
log.Printf("cap(a) = %d", cap(a))
log.Printf("len(a[:10]) = %d", len(a[:10]))
log.Printf("cap(a[:10]) = %d", cap(a[:10]))
@nelhage
nelhage / char.tex
Last active December 25, 2015 01:19
char.tex
\PRESETS{Char}{
\FD\MYdesc {} %% badge description
\FD\MYstats {} %% use \newstat to add stats
% \newstat\MYcr {Combat Rating}{CR}{2} %% for DarkWater-style combat
\newstat\MYpsi {$\psi$}{$\psi$}{$7,9,11,13$}
\newstat\MYdrunk {$\iota$}{$\iota$}{0}
\newstat\MYdelta {$\delta$}{$\delta$}{}
\newstat\MYtau {$\tau$}{$\tau$}{10}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%% datatypes.sty %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Commands Provided:
%%
%% \DECLARETYPE{Foo}
%% \DECLARESUBTYPE{Foobar}{Foo}
%%
%% \PRESETS{Foobar}{STUFF}