Skip to content

Instantly share code, notes, and snippets.

View JulesWang's full-sized avatar

juleswang JulesWang

View GitHub Profile
@JulesWang
JulesWang / levenshtein.rb
Created July 30, 2012 05:10 — forked from abangratz/levenshtein.rb
Quick implementation of the Levenshtein (Edit Distance) Algorithm
#!/usr/bin/env ruby
class String
def levenshtein(other)
range_self_end = self.size
range_other_end = other.size
data =
(0..range_self_end).map {|s|
(0..range_other_end).map {|t|
t + s unless t>0 && s>0
function pretty_date($time) {
$diff = time() - $time;
$day_diff = floor($diff / 86400);
if(is_nan($day_diff)) return '';
if ($day_diff == 0) {
if ($diff < 60) {
return $diff . "second ago";
} else if ($diff < 120) {