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 Duration | |
attr_accessor :from, :till | |
def initialize(from: nil, till: nil) | |
@from = from || Time.now | |
@till = till || Time.now | |
end | |
def seconds | |
(till - from).round |
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 Schmutz | |
Types = { | |
feinstaub: ["\u0323", "\u0307", "\u0312"], | |
mettwurst: ["\u0314", "\u031C", "\u0358", "\u0353", "\u0335"], | |
nein_nein: ["\u0337", "\u0338", "\u0336", "\u0335", "\u20d2", "\u20d3", "\u20e5", "\u20e6", "\u20eb"] | |
}.freeze | |
Types.each do |name, runes| | |
define_singleton_method name do |input, prop = 0.25| | |
mangle(input, runes, prop) |
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 "securerandom" | |
module Haikunator | |
Adjectives = %w( | |
autumn hidden bitter misty silent empty dry dark summer | |
icy delicate quiet white cool spring winter patient | |
twilight dawn crimson wispy weathered blue billowing | |
broken cold damp falling frosty green long late lingering | |
bold little morning muddy old red rough still small | |
sparkling throbbing shy wandering withered wild black |
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 RomanConverter | |
Dictionary = { | |
1000 => 'M', | |
900 => 'CM', | |
500 => 'D', | |
400 => 'CD', | |
100 => 'C', | |
90 => 'XC', | |
50 => 'L', | |
40 => 'XL', |
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
Gem::Specification.new do |s| | |
s.name = 'disco' | |
s.version = '0.0.1' | |
s.platform = Gem::Platform::RUBY | |
s.author = 'Kevin Melchert' | |
s.email = 'kevin.melchert@gmail.com' | |
s.summary = 'MongoDB + Omniauth = Guestlist + Doorkeeper.' | |
s.description = 'MongoDB + Omniauth = Guestlist + Doorkeeper.' | |
s.files = ['disco.rb'] |
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" | |
require "mongo" | |
require "json" | |
class SimpleMongoApi < Sinatra::Base | |
set :mongo, Mongo::Client.new("mongodb://my.mongo.host/database") | |
def collection | |
settings.mongo["things"] | |
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
%w(pathname json openssl net/http digest/sha1 zip).each { |lib| require lib } | |
module Passbook | |
def self.wwdr_certificate | |
OpenSSL::X509::Certificate.new <<-EOF.gsub /^\s+/, "" | |
-----BEGIN CERTIFICATE----- | |
MIIEIzCCAwugAwIBAgIBGTANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQGEwJVUzET | |
MBEGA1UEChMKQXBwbGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlv | |
biBBdXRob3JpdHkxFjAUBgNVBAMTDUFwcGxlIFJvb3QgQ0EwHhcNMDgwMjE0MTg1 | |
NjM1WhcNMTYwMjE0MTg1NjM1WjCBljELMAkGA1UEBhMCVVMxEzARBgNVBAoMCkFw |
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
Gem::Specification.new do |s| | |
s.name = 'cptn-log' | |
s.version = '0.0.2' | |
s.platform = Gem::Platform::RUBY | |
s.author = 'Kevin Melchert' | |
s.email = 'kevin.melchert@gmail.com' | |
s.summary = 'MongoDB Logger.' | |
s.description = 'MongoDB Logger.' | |
s.files = ['cptn-log.rb'] |
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 Color < Struct.new(:r, :g, :b) | |
def self.hex(value) | |
new(*value.to_s.delete('#').scan(/../).map(&:hex)) | |
end | |
def hex | |
"%.2X%.2X%.2X" % values | |
end | |
def to_s |