Skip to content

Instantly share code, notes, and snippets.

@LTe
LTe / gist:1627247
Created January 17, 2012 16:09 — forked from jasiek/gist:1627013
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
# muzang.rb
require 'muzang'
require 'muzang-plugins'
class Bshellz
include Muzang::Plugins::Helpers
def initialize(bot)
@bot = bot
end
@LTe
LTe / me_gusta.rb
Created February 13, 2012 11:27 — forked from paneq/me_gusta.rb
Challenge
class TestUser
def is_ok?
true
end
def receive_message
yield("user", "message")
end
def &(other)
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
@LTe
LTe / responder.rb
Created February 27, 2012 13:30 — forked from mati0090/gist:1923694
{ 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
@LTe
LTe / bm.rb
Created May 14, 2013 10:06 — forked from paneq/bm.rb
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
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 {
@LTe
LTe / main.py
Created December 20, 2019 07:29 — forked from mypy-play/main.py
Shared via mypy Playground
from typing import Iterator
def fib(n: int) -> Iterator[int]:
a, b = 0, 1
while a < n:
yield a
a, b = b, a + b