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
module M | |
def self.included(base) | |
self.instance_methods.each do |method| | |
alias_method "#{self.to_s}_#{method}".to_sym, method.to_sym | |
end | |
end | |
def hello | |
1 | |
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
# muzang.rb | |
require 'muzang' | |
require 'muzang-plugins' | |
class Bshellz | |
include Muzang::Plugins::Helpers | |
def initialize(bot) | |
@bot = bot | |
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
class TestUser | |
def is_ok? | |
true | |
end | |
def receive_message | |
yield("user", "message") | |
end | |
def &(other) |
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 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 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 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 'benchmark' | |
s1 = Struct.new(:login, :password).new("login", "password") | |
class S | |
attr_accessor :login, :password | |
def initialize(login, password) | |
@login = login | |
@password = password | |
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
class EventFeed: Hashable, Equatable { | |
var eventId = 0 | |
var hashValue : Int { return eventId } | |
func equals(another: EventFeed) -> Bool { | |
return self.eventId === another.eventId | |
} | |
} | |
func ==(lhs: EventFeed, rhs: EventFeed) -> Bool { |
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
from typing import Iterator | |
def fib(n: int) -> Iterator[int]: | |
a, b = 0, 1 | |
while a < n: | |
yield a | |
a, b = b, a + b | |