I hereby claim:
- I am tomharris on github.
- I am tomharris (https://keybase.io/tomharris) on keybase.
- I have a public key whose fingerprint is 4EE9 2C56 96E3 3A36 82F0 F7C4 3DE7 4993 F0A5 47A9
To claim this, I am signing this object:
require "net/http" | |
require "uri" | |
module Google | |
class Geocode | |
attr_accessor :address | |
attr_reader :key, :latutude, :longitude | |
def initialize( key, address ) | |
@key = key |
class WordDictionary | |
def initialize(dictionary_filename = '/usr/share/dict/words') | |
@words = File.readlines(dictionary_filename) | |
@words = @words.collect { |word| word.strip } # File.readlines preserves the newlines at the end of the line | |
end | |
def words_with_five_vowels_in_ascending_order | |
@words.select { |word| word.count('aeiou') == 5 && word =~ /.*?[aA].*?[eE].*?[iI].*?[oO].*?[uU].*?/ } | |
end |
class SomeModel | |
after_save :queue_a_task, unless: lambda { !!@callbacks_disabled } | |
def do_something_without_queuing_a_task | |
disable_callbacks! | |
do_something_that_triggers_callbacks | |
enable_callbacks! | |
end | |
private |
Date::DATE_FORMATS[:custom_format] = '%m/%d/%Y' | |
# ... | |
user.created_at.to_s(:custom_format) |
def upload | |
# ... | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => aws_access_key_id, | |
:secret_access_key => aws_secret_access_key | |
) | |
File.open(file_path) do |file| |
module DataLoad | |
class Thing1 | |
def reload_all | |
connection = ActiveRecord::Base.connection | |
sql = <<-SQL | |
create temporary table tmp_thing1 ( | |
-- ... | |
) |
module DataLoad | |
class Thing1 | |
include DatabaseConnectionHelper | |
def reload_all | |
with_master_connection do |connection| | |
sql = <<-SQL | |
create temporary table tmp_thing1 ( | |
-- ... | |
) |
class Thing < ActiveRecord::Base | |
def self.sort_by_column(column, direction) | |
if column_names.include?(column) and %w(asc desc).include?(direction) | |
order("#{column} #{direction}") | |
else | |
self | |
end | |
end | |
end |
I hereby claim:
To claim this, I am signing this object:
Implement a Ruby program that outputs the validity of a number by applying the Luhn Checksum.
http://en.wikipedia.org/wiki/Luhn_algorithm
Please treat this as you would any other task you'd encounter during your daily work. This will show us how currently code, and not how you coded 6, 12 or 18 months ago. Your code should also be suitably tested. Also, please do not feel that you need to spend a great deal of time working on a solution.
There are many solutions and code snippets online to do a Luhn Checksum. Please resist using those.