Skip to content

Instantly share code, notes, and snippets.

module Enumerable
def exactly?(percentage, &block)
matching(percentage, &block) == percentage.to_f
end
def more?(percentage, &block)
matching(percentage, &block) >= percentage.to_f
end
def less?(percentage, &block)
%w(rake/clean rubygems colored).each { |f| require f }
INCLUDE = "include"
ERLC_FLAGS = "-I#{INCLUDE} +warn_unused_vars +warn_unused_import"
SRC = FileList['src/*.erl']
TEST = FileList['test/*.erl']
OBJ = SRC.pathmap("%{^src$,ebin}X.beam")
TESTS = TEST.pathmap("%{^test$,ebin}X.beam")
CLEAN.include("ebin/*.beam", "tests/*.beam", "erl_crash.dump")
@da3mon
da3mon / fu+.c
Created December 5, 2008 18:08 — forked from nakajima/leet c codes.c
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#define M 7
#define m malloc
#define r rand
#define e exit
#define f free
#define g signal
#define t printf
--colour
--format progress
--loadby mtime
--reverse
--backtrace
#detect duplicates across columns in really large tables
psql -d database -c 'select col_1, col_2, col_3 from table order by col_1, col_2, col_3'|tr -ds '|' ' '|awk '{print $1 " " $2 " " $3}'|uniq -d
options = Hash[*"name_1=param_1&name_2=param_2".split(/&|=/)]
#usage: zsr _m_ _n_ : sowest _n_ requests from gzipped log file _m_
function zsr () {
zgrep ' (0 reqs/sec) ' $1|
awk '{ print $8 " - Mongrel:" $13", " $14 " DB:" $17", "$18 " " $22 }' |
sort -nr|head -n $2;
}
#usage: sr _m_ _n_ : sowest _n_ requests from log file _m_
function sr () {
grep ' (0 reqs/sec) ' $1|