Skip to content

Instantly share code, notes, and snippets.

class Rake::Task
def overwrite(&block)
abandon
enhance(&block)
end
def abandon
@actions.clear
prerequisites.clear
#!/usr/bin/ruby
%w(rubygems socket yaml).each { |lib| require lib }
class Bot
attr_reader :nick, :server, :port, :options, :server_info, :server_message
def initialize(nick, server, port, options = {}, &block)
@nick = nick
@server = server
@port = port
# [ Fixnum, Float ].each{ |klass| klass.send :include, Extensions::NetAndGross }
#
# Examples:
# 1.net # => 1
# 1.gross # => 1.19
# 1.gross.gross # => 1.19
# 1.gross.gross.net # => 1.0
#
module Extensions
@stephanschubert
stephanschubert / RGB to CMYK with caching
Last active August 30, 2015 14:24
Convert CMYK to RGB with automatic caching
cmyk = Hash.new do |cache, rgb|
cmy = rgb.map { |color| 255 - color }
k = cmy.min
cache[rgb] = cmy.map { |color| color - k } + [k]
end
# Usage
cmyk[ [128, 42, 23] ] # => [0, 86, 105, 127]