Skip to content

Instantly share code, notes, and snippets.

#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|
options = Hash[*"name_1=param_1&name_2=param_2".split(/&|=/)]
#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
--colour
--format progress
--loadby mtime
--reverse
--backtrace
@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
%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")
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)
@da3mon
da3mon / gist:1077063
Created July 11, 2011 23:41
‽‽‽
ree:044 > 1800.seconds
=> 1800 seconds
ree:045 > 1800
=> 1800
ree:046 > 3 * 600.seconds
=> 1800
ree:047 > 1800.seconds.class
=> Fixnum
ree:048 > 1800.seconds.ago
=> Mon, 11 Jul 2011 23:07:01 UTC +00:00
@da3mon
da3mon / hack.sh
Created April 1, 2012 01:41 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@da3mon
da3mon / slapdash.rb
Created April 12, 2012 23:09
defiling science
class AttributeError < RuntimeError; end
def foo
return @foo if defined?(@foo)
raise AttributeError
end
foo
@foo = :foo