Skip to content

Instantly share code, notes, and snippets.

View arbovm's full-sized avatar

Arbo von Monkiewitsch arbovm

View GitHub Profile
# poor mans debugger
#
# if you want to know whats the value of an object just add .why?
# and you will see what it is and why your program behaves like it does.
#
Object.class_eval {def why?; raise "Because it is #{inspect}" ; end}
#!/usr/bin/ruby
# to count the words of "The Complete Works of William Shakespeare", type
# $ curl http://www.gutenberg.org/cache/epub/100/pg100.txt | ./wordcount_map_reduce.rb
def map line
line.split(' ').each do |word|
emit(word, 1)
end
end
function(head, req) {
var row
var rows=[]
while(row = getRow()) {
rows.push(row)
}
rows.sort(function(a,b) {
return b.value-a.value
})
send(JSON.stringify({"rows" : rows}))
@arbovm
arbovm / finder.rb
Created July 4, 2011 10:00
finds boundaries of a range of special items in a sequence
class Finder
attr_reader :right, :left
def initialize attrs
@fetch = attrs[:fetch]
@test = attrs[:inside_test]
@index = attrs[:inside_index]
@step = attrs[:step]
@arbovm
arbovm / logmon.sh
Created July 21, 2011 10:35
oh no! progress monitoring in bash!
#!/bin/bash
total_percent=3649.39
for i in {0..9}; do
last_ten_line_counts[$i]=0
done
idx=0
while [ 1 ]; do
@arbovm
arbovm / server_setup.md
Created July 27, 2011 16:05 — forked from erotte/server_setup.md
Server Setup Ubuntu 10.4/rvm/nginx/passenger Hosteurope VM

Server Setup

Unsere Setup-Routine für eine Rails-App mit Nginx, Passenger, rvm auf einen Host Europe-VPS mit Ubuntu 10.4.

Installation der benötigten Pakete

apt-get update

apt-get install -y build-essential bison openssl libreadline5 libreadline5-dev curl \

@arbovm
arbovm / gozk_static.patch
Created August 29, 2011 13:45
gozk static patch
--- gozk.go 2011-08-29 09:44:44.193098000 +0000
+++ gozk_static.go 2011-08-29 13:38:18.059167567 +0000
@@ -10,7 +10,6 @@
/*
#cgo CFLAGS: -I/usr/include/c-client-src
-#cgo LDFLAGS: -lzookeeper_mt
#include <zookeeper.h>
#include "helpers.h"
@arbovm
arbovm / create_all_data_bags.sh
Created August 31, 2011 08:27
opscode chef scripts
#!/bin/bash
for dir in `find . -type d -depth 1`; do
# remove ./
bag=`echo $dir | sed 's/^..//'`
knife data bag create $bag;
done
@arbovm
arbovm / .zshrc
Created April 19, 2012 17:58
zshrc
# Set up the prompt
autoload -Uz promptinit
promptinit
prompt walters
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
@arbovm
arbovm / vi-wrapper.sh
Created November 14, 2012 14:39
vi wrapper to parse colon line number adressing in path ( e.g. ~/.ssh/known_hosts:511 )
#!/bin/bash
# put this in your $PATH before /usr/bin, name it vi, chmod +x and enjoy
ARGS=$(echo $@ | sed 's/:/ +/g')
exec /usr/bin/vi $ARGS