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
| # Country Code List: ISO 3166-1993 (E) | |
| module Countries | |
| Mexico = 'MX' | |
| GuineaBissau = 'GW' | |
| Afghanistan = 'AF' | |
| Ethiopia = 'ET' | |
| SyrianArabRepublic = 'SY' | |
| SvalbardJanMayenIslands = 'SJ' | |
| Tonga = 'TO' | |
| Pakistan = 'PK' |
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
| require 'dm-core' | |
| require 'dm-validations' | |
| require 'dm-predefined' | |
| class Country | |
| include DataMapper::Resource | |
| include DataMapper::Migrations | |
| include DataMapper::Predefined |
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 'rack' | |
| FILES = { | |
| '/index.html' => 'index.html' | |
| } | |
| Rack::Handler.get('Thin').run proc { |env| | |
| path = env['PATH_INFO'] |
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
| require 'thread' | |
| class AsyncConsole | |
| # | |
| # Creates a new Asynchronous Console, within the given context. | |
| # | |
| # @param [Module] context | |
| # The context to evaluate code within. | |
| # |
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
| require 'digest/sha2' | |
| module DataMapper | |
| module Types | |
| class APIKey < DataMapper::Type | |
| primitive String | |
| length 64 | |
| # |
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
| public class Fib { | |
| public static int fib(int n) { | |
| if (n == 0 || n == 1) | |
| return n; | |
| return (fib(n-1) + fib(n-2)); | |
| } | |
| public static void main(String[] args) { | |
| for (int i = 0; i < 36; i++) | |
| System.out.println("n=" + i + " => " + fib(i)); |
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
| class Array | |
| # | |
| # Iterates over each permutation of the enumerable values within the | |
| # {Array}. | |
| # | |
| # @yield [list] | |
| # The given block will be passed each permutation of the enumerable | |
| # values in the {Array}. | |
| # |
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 'rubygems' | |
| gem 'combinatorics', '~> 0.2.0' | |
| gem 'ffi-hunspell', '~> 0.2.0' | |
| require 'combinatorics/list_comprehension' | |
| require 'ffi/hunspell' |
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 'open-uri' | |
| require 'nokogiri' | |
| require 'raingrams' | |
| MODEL_FILE = 'youtube_corpora.ngrams' | |
| model = if File.file?(MODEL_FILE) | |
| Raingrams::BigramModel.open(MODEL_FILE) |
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 'parslet' | |
| class EmailParser < Parslet::Parser | |
| rule(:space) { match('\s').repeat(1) } | |
| rule(:space?) { space.maybe } | |
| rule(:dash?) { match('[_-]').maybe } |