This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person < Struct.new(:name, :email) | |
def info | |
"#{self.name} #{self.email}" | |
end | |
def first_name | |
clean_name.first | |
end | |
def middle_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'forwardable' | |
class WeleStack | |
extend Forwardable | |
def initialize(obj=[]) | |
@queue = obj | |
end | |
def_delegator :@queue, :push, :empuja |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'irb/completion' | |
require 'irb/ext/save-history' | |
IRB.conf[:PROMPT_MODE] = :SIMPLE | |
IRB.conf[:SAVE_HISTORY] = 1000 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history" | |
def y(obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_pry_.print = lambda { |o, v| o.print "\e[1A\e[18C # => "; o.puts v.inspect } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomAuth | |
def initialize(secret) | |
@secret = secret | |
end | |
def encrypt(key) | |
@secret.crypt(key) | |
end | |
def decrypt(key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Original | |
class Spammer | |
def initialize | |
@random_telephones = Proc.new { "787-#{rand(000..999)}-#{rand(0000..9999)}" } | |
@sms_telephones = Proc.new { "787#{rand(000..999)}#{rand(0000..9999)}" } | |
end | |
def telephone | |
@random_telephones.call | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Original | |
# If you were down with this you are a code martyr waiting for a stab. | |
# Ruby was born so that code could be drier than your Grandma. | |
# The first any? method is as useless as a PHP Senior Developer so I ain't worried! | |
# The @offenders hash always get saved using the store method so cut that bitch off! | |
if @offenders.any? && @offenders.key?(nick) | |
@offenders.store(nick, @offenders.fetch(nick).next) | |
else | |
@offenders.store(nick, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra/base' | |
class App < Sinatra::Base | |
before do | |
@images = [ | |
{ title: "matrix", url: "http://i0.kym-cdn.com/entries/icons/original/000/009/889/Morpheus2.jpg" }, | |
{ title: "google", url: "http://i0.kym-cdn.com/news_feeds/icons/original/000/006/501/google-search.jpg" }, | |
{ title: "skywalking", url: "http://i2.kym-cdn.com/photos/images/newsfeed/000/295/090/9de.jpg" } | |
] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'geocoder' | |
class Locator | |
def search(address) | |
Geocoder::coordinates(address) | |
end | |
end | |
#Locator.new.search('san juan, pr') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HeadlinesController < ApplicationController | |
before_action :set_headline, only: [:show, :edit, :update, :destroy] | |
# GET /headlines | |
# GET /headlines.json | |
def index | |
@headlines = Headline.all | |
respond_to do |format| | |
format.html # index.html.erb |
NewerOlder