Skip to content

Instantly share code, notes, and snippets.

View dingsdax's full-sized avatar
🐢
slow coding

Joesi D. dingsdax

🐢
slow coding
View GitHub Profile
@dingsdax
dingsdax / gist:1080272
Created July 13, 2011 13:13
Jaro–Winkler distance in Ruby
# extension for array class
class Array
# select array items with index
# give a block both the item with index of array
# filtered by a select statement
def select_with_index
index = -1
select { |x| index += 1; yield(x, index) }
end
# return indices array of array item
@dingsdax
dingsdax / damerau_levenshtein.rb
Created January 9, 2011 19:42
string similarity metrics in ruby
# extension for string class
class String
# return character array of string with indices
def each_char_with_index
i = 0
split(//).each do |c|
yield i, c
i += 1
end
end