Skip to content

Instantly share code, notes, and snippets.

View edgar's full-sized avatar

Edgar Gonzalez edgar

View GitHub Profile
@edgar
edgar / net-http-debug.rb
Created January 13, 2016 01:13 — forked from ahoward/net-http-debug.rb
a simple way to debug tons of libs that use ruby's net/http
BEGIN {
require 'net/http'
Net::HTTP.module_eval do
alias_method '__initialize__', 'initialize'
def initialize(*args,&block)
__initialize__(*args, &block)
@edgar
edgar / cpu.rb
Created October 23, 2015 19:47 — forked from jimweirich/cpu.rb
Can people run this script and see if it gives accurate count of CPUs on their system. Report results in the comments please. Thanks! Oh! And don't forget to report what kind of system you are running this on (linux, windows, mac, etc.). UPDATE: Revised version that uses the Java runtime if running under JRuby.
require 'rbconfig'
# Based on a script at:
# http://stackoverflow.com/questions/891537/ruby-detect-number-of-cpus-installed
class CpuCounter
def self.count
new.count
end
def count
@edgar
edgar / polycorn.md
Last active August 29, 2015 14:26 — forked from octplane/polycorn.md
Life and Death of Unicorns The introduction of our Unicorn management tool, Polycorn. This gists contains the original article about Polycorn plus the source code of Polycorn.

Life and death of Unicorns

The introduction of our Unicorn management tool, Polycorn.

jump into our train!

Photo by Protohiro from Flickr

At Fotopedia, we use Unicorn to serve our main Rails application. Every day, we restart our application several times, spawning and killing hundred of Unicorns. Managing graceful restarts is a complex task, and requires careful monitoring and command. This article introduces our tool Polycorn, a Unicorn management program.

[[MORE]]

@edgar
edgar / ruby_gc.sh
Last active August 29, 2015 14:23 — forked from mikhailov/ruby_gc.sh
- http://www.coffeepowered.net/2009/06/13/fine-tuning-your-garbage-collector/
- http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration
article’s settings: ("spec spec" took 17-23!sec)
export RUBY_HEAP_MIN_SLOTS=1250000
export RUBY_HEAP_SLOTS_INCREMENT=100000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=30000000
export RUBY_HEAP_FREE_MIN=12500
#!/bin/sh
# Some things taken from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
green='\033[0;32m'
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key

Granny's Carúpano Style Egg Nog (Ponche Crema Carupanero)

Ingredients

  • 1 bottle of Whistle Pig whiskey, 1 bottle of Bruichladdich whisky
  • 30 egg yolks
  • 4 Cans of condensed milk (14 oz / 397g per can)
  • 1 Bottle of rum (750 ml)

Receta del Ponche Crema casero de mi abuela carupanera

Ingredientes

  • Un cartón de huevos (30 huevos)
  • Cuatro latas grandes de leche condensada (397 gr/14 onzas por lata)
  • Una botella de ron (750 ml)
  • Ralladura fina de la concha de dos limones pequeños.
require 'action_mailer'
require 'mail'
module ActionMailer
class TestCase
def set_expected_mail
@expected = Mail.new
@expected.content_type = "text/plain; charset=#{charset}"
@expected.mime_version = '1.0'
require 'action_mailer'
require 'mail'
module ActionMailer
class Base
def clean_address(str)
EmailAddress.parse(str, :no_default_name => true).quoted rescue str
end