Skip to content

Instantly share code, notes, and snippets.

View eduardo's full-sized avatar

Edu Fernández eduardo

View GitHub Profile
@eduardo
eduardo / httpdump
Created April 4, 2009 10:55 — forked from peterc/httpdump
# Monitor HTTP requests being made from your machine with a one-liner..
# Replace "en1" below with your network interface's name (usually en0 or en1)
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile:
# (again replace "en1" with correct network interface name)
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*""
# All the above tested only on OS X.
# urlmonitor - print out the URLs requested system wide on the main network interface
# Accept a network interface name as an optional argument
iface = ARGV.first
# No interface specified? Try to guess which one is king..
unless iface
`ifconfig -l`.split.each do |iface|
next if iface =~ /^lo/
break if `ifconfig #{iface}` =~ /inet (0|1|2)/
require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#
@eduardo
eduardo / gist:106431
Created May 4, 2009 11:29 — forked from ezmobius/gist:105680
Deploy recipe for chef
# JSON
{
"applications": [
{
"foobar": {
"migration_command": "rake db:migrate",
"branch": "HEAD",
"deploy_action": "deploy",
"framework_env": "production",
require 'rubygems'
require 'couchrest'
SERVER = CouchRest.new
DB = SERVER.database!('contact-manager')
class Contact < CouchRest::ExtendedDocument
use_database DB
property :first_name
require 'prawn'
require 'prawn/layout'
Prawn::Document.generate("table-test2.pdf") do
headers = ["Course", "Grade", "Comments"]
data = []
10.times { |i| data << ["Home Room", "A+", "Great work!"]}
def make_table(headers, data)
table(
class GitosisCofigGenerator
def initialize
@config = {}
end
def add_group(name, options = {})
@config.store(name, {:writable => options[:writable], :readonly => options[:readonly], :members => options[:members]})
end
require 'yaml'
def yacss(data)
YAML.load(data).map do |item|
item.map do |selector, properties|
"#{selector} {\n" +
properties.map do |property, value|
" #{property}: #{value};\n"
end.join +
"}\n"
@eduardo
eduardo / gist:192604
Created September 24, 2009 08:10 — forked from ddollar/gist:107308
* keep people working on internal projects, assign and schedule the work
* dont look desperate, dont have immediate availability
* can tell a client you can 'shuffle internal projects' to accomodate them
* online ads dont work well
* referrals instead
* do a great job every single time
* voice calls important
* when people call you call them back
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
# Switch to 1.9.1 and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.1@rails3