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 ruby1.9 | |
# encoding: UTF-8 | |
require 'rubygems' | |
require 'inline' | |
require 'time' | |
class DamerauLevenshtein | |
def distance(str1, str2, block_size=2, max_distance=10) | |
res = distance_utf(str1.unpack("U*"), str2.unpack("U*"), block_size, max_distance) | |
(res > max_distance) ? nil : res |
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
APP_ROOT = File.expand_path('.') | |
require 'sinatra' | |
get '*' do | |
mimetype = `file -ib #{File.join(APP_ROOT, params[:splat].join)}`.gsub(/\n/,"") | |
content_type mimetype | |
send_file File.join(APP_ROOT, params[:splat].join) | |
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
module Abilities | |
def self.ability_for(user) | |
if user.admin? | |
AdminAbility.new(user) | |
else user | |
MemberAbility.new(user) | |
else | |
GuestAbility.new | |
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
function! FoldAllBut( foldminlines ) | |
folddoclosed | |
\ if ( (foldclosed(".") >= 0 ) && ( foldclosedend(".") - foldclosed(".") + 1 < a:foldminlines )) | |
\ exe "normal! zO" | |
\ endif | |
endfunction |
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
function Describe(title, testFunc, parent) { | |
this._title = title; | |
this._parent = parent; | |
this._testFunc = testFunc; | |
if ( ! this._parent ) { // root | |
this.run(); | |
} | |
} |
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 | |
require 'uri' | |
require 'json' | |
require 'net/http' | |
if ARGV.length > 0 | |
query = ARGV[0] | |
else | |
print 'Input word: ' |
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
(function (f) { | |
return (function (g) { | |
return g(g); | |
})(function(h) { | |
return f(function () { | |
return (h(h)).apply(this, arguments); | |
}); | |
}); | |
})(function(f) { | |
return function (n) { |
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
(defn prime-nth [n] | |
(take n | |
(filter | |
(fn [x] | |
(nil? (some #(zero? (mod x %)) (range 2 (inc (int (/ x 2))))))) | |
(iterate inc 2)))) |
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
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCZH/9G6dnwQRu0Rtij382bIIjIE7Eb/1Ja1w9kBN3DwPXMZsfY22XYNJHCspcoyhHpwUR1ZxMoCs4cmh3PVv1Gq9PHX9ogsO0ufeoZdHeoFv53L2yU9nRVtPAqZfkQxrlXQWmDFFHWpld7i4tNZp9j0KW1SS91a9wvttnSo4FwWi8BrUprN9iECaYPgPwwiRybQ37D4grTjbr3SdMev+vCYKVpTQftC7HzRvTJXTO/vHm+16sEOjM+LwqnGipGuBfQjHJnHVwlAT+aF8JxCseitI9TD+52e+5ZJ4oPzStRiccVdFJEkmGglo5n2ZVoN9Di6RL6PJ/SUzAKF8lbpxlf dhruvasagar@dhruvasagar |
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 bash | |
set -u | |
set -e | |
export GIT_WORK_TREE="/var/www/example.com" | |
export NODE_VERSION="0.10" | |
echo "--> Checking out..." | |
git checkout -f |
OlderNewer