This file contains hidden or 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 BasicObject | |
| def class | |
| classes = [] | |
| ::ObjectSpace.each_object(::Class).each do |x| | |
| case self | |
| when x then classes << x | |
| end rescue nil | |
| end | |
| classes.reject! { |k| classes.any? { |c| c < k } }.first | |
| end |
This file contains hidden or 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
| def self.normalize(name) | |
| if name =~ /^#?<3/ | |
| # Special case for love, because the world needs more love. | |
| '<3' | |
| elsif name | |
| name.gsub(/[^#{self.tag_text_regexp}]/, '').downcase | |
| end | |
| end |
This file contains hidden or 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 'muzang' | |
| require 'muzang-plugins' | |
| require 'muzang-plugins/muzang-soupirc' | |
| require 'muzang-plugins/muzang-google' | |
| EM.run do | |
| @bot = Muzang::Bot.new(irc_host: "irc.freenode.net", channels: ["#drug.pl"]) | |
| @bot.register_plugin(PlusOne) | |
| @bot.register_plugin(LiveReload) | |
| @bot.register_plugin(Motd) |
This file contains hidden or 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 Rake::Task | |
| def overwrite(&block) | |
| @actions.clear | |
| enhance(&block) | |
| end | |
| end | |
| Rake::Task['db:migrate'].overwrite do | |
| puts "Without migration, srsly?" | |
| end |
This file contains hidden or 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
| DATA.rewind | |
| puts DATA.read | |
| __END__ | |
| # http://en.wikipedia.org/wiki/Quine_(computing) |
This file contains hidden or 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
| { send_for_approval: "sent for approval", | |
| deactivate: "deactivated", | |
| reactivate: "reactivated", | |
| }.each do |status, desc| | |
| define_method status do | |
| if @offer.send(status) | |
| redirect_to @offer, :notice => "Offer was #{desc}." | |
| else | |
| render :action => "edit" | |
| end |
This file contains hidden or 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 File.expand_path(File.dirname(__FILE__) + '/spec_helper') | |
| # waiting for mr Lte... :) | |
| describe "Soup Agent" do | |
| before do | |
| @agent = Faraday.new(url: 'http://www.soup.io/') do |builder| | |
| builder.use Faraday::Request::UrlEncoded | |
| builder.use Faraday::Response::Logger | |
| builder.use Faraday::Adapter::NetHttp | |
| end | |
| end |
This file contains hidden or 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 TestUser | |
| def is_ok? | |
| true | |
| end | |
| def receive_message | |
| yield("user", "message") | |
| end | |
| def &(other) |
This file contains hidden or 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
| @cache = {} | |
| @cache["test"] = "resource" | |
| def my_method | |
| return value=value if value = @cache["test"] | |
| end | |
| puts my_method # => resource |
This file contains hidden or 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
| module RSpec | |
| module Matchers | |
| module Extensions | |
| module InstanceEvalWithArgs | |
| def instance_eval_with_args(*args, &block) | |
| return instance_exec(*args, &block) if respond_to?(:instance_exec) | |
| # If there are no args and the block doesn't expect any, there's no | |
| # need to fake instance_exec with our hack below. | |
| # Notes: |