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
$ ruby -v | |
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux] | |
$ ab -n 1000 http://localhost:8080/ | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient) | |
Completed 100 requests | |
Completed 200 requests |
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
# | |
# A C Parser using the Parslet library. | |
# | |
# ANSI C Grammar: | |
# | |
# * http://www.lysator.liu.se/c/ANSI-C-grammar-l.html | |
# * http://www.lysator.liu.se/c/ANSI-C-grammar-y.html | |
# | |
require 'parslet' |
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 'parslet' | |
require 'pp' | |
class HTTPParser < Parslet::Parser | |
# | |
# Character Classes | |
# | |
rule(:digit) { match('[0-9]') } | |
rule(:digits) { digit.repeat(1) } | |
rule(:xdigit) { digit | match('[a-fA-F]') } |
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 } |
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 '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
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
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
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
require 'thread' | |
class AsyncConsole | |
# | |
# Creates a new Asynchronous Console, within the given context. | |
# | |
# @param [Module] context | |
# The context to evaluate code within. | |
# |