Skip to content

Instantly share code, notes, and snippets.

View boosty's full-sized avatar

Sebastian Röbke boosty

View GitHub Profile
@boosty
boosty / bm_serialization.rb
Last active May 3, 2017 13:03
Benchmarking Oj, MessagePack and Protobuf (in Ruby)
#!/usr/bin/env ruby
require 'bundler/inline'
$gem_versions = {
"oj" => "3.0.5",
"msgpack" => "1.1.0",
"google-protobuf" => "3.2.0.2"
}
gemfile do
require 'rubygems'
require 'bundler/setup'
require 'ffi-rzmq'
context = ZMQ::Context.new
puts "Starting Listener..."
listener = context.socket(ZMQ::SUB)
listener.setsockopt(ZMQ::SUBSCRIBE, '')
@boosty
boosty / Gemfile
Created June 16, 2011 21:39
Non-blocking system call using goliath
source "http://rubygems.org"
gem "goliath"
@boosty
boosty / cweek.rb
Created October 23, 2009 08:46
Get the commercial week of the current year
#!/usr/bin/env ruby
#
# Get the commercial week of the current year.
#
require 'date'
puts Date.today.cweek
@boosty
boosty / psgrep.sh
Created September 4, 2009 09:22 — forked from mojombo/psg.sh
function psgrep {
ps wwwaux | egrep "($1|%CPU)" | grep -v grep
}
# Include me in your ActiveRecord model and get string attributes
# trimmed/stripped before validation.
module TrimStringAttributes
def self.included(base)
base.class_eval <<-EOF
before_validation :trim_string_attributes
EOF
end
protected
@boosty
boosty / staging.rb
Created June 30, 2009 20:55
Send all ActionMailer emails to a specific email adress
# Want your Rails app to send all ActionMailer emails
# to a specific email adress instead of sending it
# to the world (e.g. in the staging environment)?
#
# Put this into e.g. config/environments/staging.rb
config.after_initialize do
module ::ActionMailer
class Base
class_eval do
@boosty
boosty / git_status.sh
Created January 15, 2009 09:54 — forked from henrik/.bashrc
git dirty prompt with a flash!
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
#
# boosty likes it like that:
# ~/dev/dir[master]$ # clean working directory
# ~/dev/dir[master⚡]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "⚡"
}