Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
// With love from http://stackoverflow.com/a/13459454/447288
#define EVAL0(...) __VA_ARGS__
#define EVAL1(...) EVAL0 (EVAL0 (EVAL0 (__VA_ARGS__)))
#define EVAL2(...) EVAL1 (EVAL1 (EVAL1 (__VA_ARGS__)))
#define EVAL3(...) EVAL2 (EVAL2 (EVAL2 (__VA_ARGS__)))
#define EVAL4(...) EVAL3 (EVAL3 (EVAL3 (__VA_ARGS__)))
#define EVAL(...) EVAL4 (EVAL4 (EVAL4 (__VA_ARGS__)))
git log --shortstat --pretty="%cE" | sed 's/\(.*\)@.*/\1/' | grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' | sort | sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' | awk 'BEGIN {name=""; files=0; insertions=0; deletions=0; commits=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net, " commits " commits"; files=0; insertions=0; deletions=0; name=$1; commits=0;} name=$1; files+=$2; insertions+=$3; deletions+=$4; commits+=1} END {print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net, " commits " commits";}'
__ERROR__ Mon Dec 02 2013 10:45:37 GMT-0800 (PST) { [Error: ENOENT, open '/home/alex/interview/.floo'] errno: 34, code: 'ENOENT', path: '/home/alex/interview/.floo' }
__LOG__ Mon Dec 02 2013 10:45:37 GMT-0800 (PST) Reloading hooks.
__LOG__ Mon Dec 02 2013 10:45:37 GMT-0800 (PST) Didn't find any hooks in .floo.
__LOG__ Mon Dec 02 2013 10:45:37 GMT-0800 (PST) Watching /home/alex/interview/.floo for changes
__LOG__ Mon Dec 02 2013 10:45:37 GMT-0800 (PST) starting syncing
__LOG__ Mon Dec 02 2013 10:45:37 GMT-0800 (PST) all done syncing
# From another terminal, do "touch hello"
__LOG__ Mon Dec 02 2013 10:46:04 GMT-0800 (PST) rename hello
@awreece
awreece / verify.h
Last active December 29, 2015 06:38
#define CHECK(value, op, expected) \
do { \
__typeof__(value) _val = value; \
__typeof__(expected) _exp = expected; \
if (!(_val op _exp) { \
fprintf(stderr, "Assertion failure on %s:%d: " \
"expected " #value "(0x%x)" #op \
#expected "(0x%x)", \
__FILE__, __LINE__, _val, _exp); \
abort(); \
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void vulnerable_function() {
char buffer[100];
read(STDIN_FILENO, buffer, 200);
}
int main(int argc, char** argv) {
@awreece
awreece / x86.js
Last active December 21, 2015 00:18
registers = ["eax", "ebx", "ecx", "edx", "esi", "edi", "esp", "ebp"];
function hex(v) {
var parts = new Array(8);
for (var i = 0; i < 8; i++) {
parts[8 - i] = (v & 0xf).toString(16);
v >>= 4
}
return "0x" + parts.join("");
}
file=word.lst
sed -e ":s s/\([a]\)\(b\)/\2\1/g;s/\([a-b]\)\(c\)/\2\1/g;s/\([a-c]\)\(d\)/\2\1/g;s/\([a-d]\)\(e\)/\2\1/g;s/\([a-e]\)\(f\)/\2\1/g;s/\([a-f]\)\(g\)/\2\1/g;s/\([a-g]\)\(h\)/\2\1/g;s/\([a-h]\)\(i\)/\2\1/g;s/\([a-i]\)\(j\)/\2\1/g;s/\([a-j]\)\(k\)/\2\1/g;s/\([a-k]\)\(l\)/\2\1/g;s/\([a-l]\)\(m\)/\2\1/g;s/\([a-m]\)\(n\)/\2\1/g;s/\([a-n]\)\(o\)/\2\1/g;s/\([a-o]\)\(p\)/\2\1/g;s/\([a-p]\)\(q\)/\2\1/g;s/\([a-q]\)\(r\)/\2\1/g;s/\([a-r]\)\(s\)/\2\1/g;s/\([a-s]\)\(t\)/\2\1/g;s/\([a-t]\)\(u\)/\2\1/g;s/\([a-u]\)\(v\)/\2\1/g;s/\([a-v]\)\(w\)/\2\1/g;s/\([a-w]\)\(x\)/\2\1/g;s/\([a-x]\)\(y\)/\2\1/g;s/\([a-y]\)\(z\)/\2\1/g;t s;" < $file
@awreece
awreece / output
Last active December 20, 2015 08:39
Fun bash fact of the day: keep your variable names short - you can get a noticeable performance improvement! (don't actually do that, if you care about this kind of performance in bash pick a different language -.-)
Testing bash
It took an average of 8.765s to assign to the variable v
It took an average of 8.884s to assign to the variable vvvvv
It took an average of 8.973s to assign to the variable vvvvvvvvvv
It took an average of 9.040s to assign to the variable vvvvvvvvvvvvvvvvvvvv
@awreece
awreece / nc.zsh
Last active December 19, 2015 15:38
#!/bin/zsh
zmodload zsh/net/tcp
if [[ $# -ne 2 ]] || [[ $1 == '-l' ]]; then
echo "$0 <host> <port>:" >&2
echo " Sends stdin to <host>:<port>" >&2
exit 1
fi
(gdb) list
1 int main() {
2 #pragma omp parallel
3 {
4 int x = 0;
5 }
6 return 0;
7 }
(gdb) b temp.cpp:4
Breakpoint 1 at 0x400672: file temp.cpp, line 4.