Skip to content

Instantly share code, notes, and snippets.

View leobessa's full-sized avatar

Leonardo Bessa leobessa

View GitHub Profile
# Used to graph results from autobench
#
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv
#
# This will generate three svg & png graphs
require "rubygems"
require "scruffy"
require 'csv'
require 'yaml'
require 'rubygems'
require 'irb'
def consolize &block
yield
IRB.setup(nil)
irb = IRB::Irb.new
IRB.conf[:MAIN_CONTEXT] = irb.context
@wamberg
wamberg / fab_ejabberd.py
Created May 1, 2010 18:47
Python Fabric ejabberd installation script
"""
Automated installation of ejabberd with a postgresql backend inspired by this
article: http://www.planeterlang.org/en/planet/article/How_to_install_ejabberd_2.0.0_with_PostgreSQL_support/
"""
from fabric.api import run, sudo
EJABBERD_VERSION = '2.0.5'
EJABBERD_SOURCE_HOME = '~/dev/xmpp/oss'
POSTGRES_PSQL_PASSWORD = 'user'
@gertig
gertig / peepcode.rb
Created August 18, 2011 20:40 — forked from jmazzi/peepcode.rb
A script to download all Peepcode screencasts with ruby & wget (supports resume)
require 'mechanize'
@username = 'user@domain.com'
@password = 'hi2u'
@download_path = File.expand_path 'downloads'
@wget_cookie = File.expand_path(File.dirname(__FILE__)) + '/wget-cookies.txt'
unless File.directory? @download_path
puts "@{download_path} doesn't exist!"
exit
@jswanner
jswanner / .gitignore.diff
Created October 7, 2011 17:50
Differences between Rails 3.1.0.beta1 & Rails 3.1.1 generated apps
diff -U 0 -r rails-3.1.0.beta1/.gitignore rails-3.1.1/.gitignore
--- rails-3.1.0.beta1/.gitignore 2011-10-07 11:56:15.000000000 -0400
+++ rails-3.1.1/.gitignore 2011-10-07 12:59:12.000000000 -0400
@@ -4,0 +5 @@
+.sass-cache/
@bernardeli
bernardeli / .zshrc
Created October 20, 2011 17:03
highlighting code for keynote with highlight
first: brew install highlight
second: add to your .zshrc (or .bashrc)
function hlr {
filename=`echo $1 | cut -d . -f 1`
highlight --syntax ruby -k Menlo -K 20 -O rtf -s edit-xcode $1 > $filename.rtf
}
third: it will generate a .rtf file. just open and copy the highlighted code and add to your Keynote talk.
@hito-asa
hito-asa / agent_fluentd.conf
Created March 29, 2012 06:45
fluentd agent
<source>
type tail
path path_to_file1
pos_file path_to_pos_file1
tag app.file1
format /^(?<ip>[^ ]+) [^ ]+ [^ ]+ \[(?<time>[^\]]+)\] "(?<method>\S+) /(?<country>[A-Z0-9]{0,3})_(?<domain>[^/]+)/(?<module>[^/]+)/(?<controller>[^/]+)/(?<action>[^/]+)/(?<record>\S*)" (?<code>\d+) (?<res_time>\d+) "(?<referer>[^\"]*)" "(?<old_device>[^_\" ]*)_(?<device>[^_\" ]*)_(?<browser>[^_\" ]*) ?(?<guid>[^\"]*)" "(?<vuid>\d*) ?(?<option>[^\"]*)"$/
time_format %d/%b/%Y:%H:%M:%S %z
rotate_wait = 5s
</source>
@jordandm
jordandm / amazon-linux-gems-19.erb
Created April 5, 2012 03:16
Chef Amazon Linux Boostrap File for Ruby 1.9.3 on AmazonLinux 2012.03
bash -c '
<%= "export http_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
if [ ! -f /usr/bin/chef-client ]; then
yum groupinstall -y 'Development tools'
yum install -y libxml2-devel libxslt-devel
yum install -y ruby19 ruby19-devel rubygems19 rubygem19-rdoc rubygem19-rake rubygem19-bigdecimal
ln -sf /usr/bin/ruby1.9 /usr/bin/ruby
ln -sf /usr/bin/gem1.9 /usr/bin/gem
ln -sf /usr/bin/irb1.9 /usr/bin/irb
@chetan
chetan / batch_em_http_example.rb
Created May 2, 2012 02:00
Example of batching requests using em-http-request
#!/usr/bin/env ruby
# This is an alternative to using EM::Iterator. It allows us to use
# MultiRequest but still limit the number of concurrent requests that
# are created.
require 'rubygems'
require 'eventmachine'
require 'em-http-request'
@stonegao
stonegao / gist:2657252
Created May 11, 2012 03:06 — forked from mardambey/gist:2654382
Reset Kafka offsets in ZooKeeper by deleting the corresponding nodes.
/**
* Notes: This code uses AsyncValue[T], a custom class that uses actors
* to allow concurrent operations on the provided type. It can be replaced
* by an Atomic object from the java.util.concurrent package or something
* that provides similar functionality.
*/
/**
* Resets the offsets for the given group / topic pair.