This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
NewerOlder