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
def luhn10?(number) | |
return false unless number.to_s =~ /\A\d+\z/ | |
digits = number.scan(/\d/).map(&:to_i).reverse | |
digits.each_with_index do |digit, index| | |
if index.odd? | |
digits[index] = (digit >= 5 ? digit * 2 - 9 : digit * 2) | |
end | |
end | |
digits.sum % 10 == 0 | |
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 "rubygems" | |
gem "mixology", "0.2.0" | |
require "mixology" | |
Mixology.class_eval do | |
def mixin_with_hook(mod) | |
result = mixin_without_hook(mod) | |
if mod.respond_to?(:mixed_into) | |
mod.mixed_into(self) | |
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 "rubygems" | |
gem "ezcrypto", "0.7" | |
require "ezcrypto" | |
key = EzCrypto::Key.new("x" * 32, :algorithm => "aes-256-cbc") | |
encrypted = key.encrypt("foo") | |
decrypted = key.decrypt(encrypted) | |
p decrypted |
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
unless ARGV.size == 1 | |
$stderr.puts "Usage: #{$0} 1password_text_export" | |
exit 1 | |
end | |
def escape(text) | |
text.to_s.gsub("&", "&").gsub("<", "<").gsub(">", ">").gsub("\"", """) | |
end | |
puts <<-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
::FixtureReplacement.class_eval do | |
def self.insert_defaults | |
return if @inserted_fixture_replacement_defaults | |
@inserted_fixture_replacement_defaults = true | |
@_defaults = {} | |
FixtureReplacementController::AttributeCollection.instances.map(&:fixture_name).each do |name| | |
insert_default name | |
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
#!/usr/bin/env ruby | |
def output_config | |
puts <<-END | |
graph_category App | |
graph_title bj queue | |
graph_vlabel count | |
jobs.label pending jobs | |
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
#!/usr/bin/env ruby | |
def output_config | |
puts <<-END | |
graph_category App | |
graph_title passenger status | |
graph_vlabel count | |
sessions.label sessions | |
max.label max processes |
NewerOlder