Skip to content

Instantly share code, notes, and snippets.

View andykingking's full-sized avatar
🙊

Andrew King andykingking

🙊
View GitHub Profile
@andykingking
andykingking / first.rb
Last active December 27, 2015 04:09
Rough implementation of the Sørensen index of two strings
def sørensen_index(string_a, string_b)
matches_a = get_bigrams string_a.dup
matches_b = get_bigrams string_b.dup
similarities = matches_a & matches_b
sum_bigrams = matches_a.count + matches_b.count
2 * similarities.count / sum_bigrams.to_f
end
def get_bigrams(str)
bigrams = []
@andykingking
andykingking / gist:7117273
Created October 23, 2013 11:58
Accidentally `git reset --hard`? Get em all back
#!/bin/bash
# output all files in index that haven't been garbage collected
git fsck --cache --unreachable $(git for-each-ref --format="%(objectname)") > badfiles
# output all files by showing them via sub-hash
FILENUM=1
cat badfiles | cut -c 18-24 | while read cur
do
git show $cur > $FILENUM