Skip to content

Instantly share code, notes, and snippets.

View edgar's full-sized avatar

Edgar Gonzalez edgar

View GitHub Profile
@edgar
edgar / gist:9900527
Created March 31, 2014 19:41
keybase.md
### Keybase proof
I hereby claim:
* I am edgar on github.
* I am edgar (https://keybase.io/edgar) on keybase.
* I have a public key whose fingerprint is 45A6 D897 81CD ABBC A678 8C57 4599 5010 176C F6BF
To claim this, I am signing this object:
# 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
@edgar
edgar / pry_console
Created February 6, 2014 17:20
Rails 2.3.* console using Pry
#!/usr/bin/env ruby
console = File.expand_path(File.dirname(__FILE__), '.') + "/script/console"
exec console, *ARGV, '--irb=pry'
@edgar
edgar / array_indeof.js
Created January 21, 2014 18:20
In IE8 arrays don't have the method indexOf defined. Implementation taken from MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf Other source could be: http://ecma262-5.com/ELS5_HTML.htm#Section_15.4.4.14
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (searchElement, fromIndex) {
if ( this === undefined || this === null ) {
throw new TypeError( '"this" is null or not defined' );
}
var length = this.length >>> 0; // Hack to convert object.length to a UInt32
fromIndex = +fromIndex || 0;
if (Math.abs(fromIndex) === Infinity) {
fromIndex = 0;
}
@edgar
edgar / gist:8227157
Created January 2, 2014 21:21
Happy New Year in Ruby in less than 140 chars / fork from @camilleroux
ruby -e 'def a;10.times{puts " "*rand(79)+"*"};end;99.times{a;puts " "*34+"Happy New Year 2014";a;sleep 0.1;puts "\e[2J"}'

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
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}