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
# | |
# This method allows requiring dependencies with some flexibility. | |
# | |
# Implemented algorithm makes greedy choices about the environment: | |
# 1. It first attempts a simple <code>Kernel.require(name)</code> before | |
# anything else (even bypassing version requirement) | |
# 2. If step 1 fails with a LoadError then it falls back requiring the | |
# gem with specified version (defaults to >= 0) and retries step 1. | |
# 3. If step 2 fails with a NameError, 'rubygems' are required and step | |
# 2 is retried. |
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
require 'veritas/physical/logs' | |
file = File.expand_path('../access.log', __FILE__) | |
LOGS = Veritas::Physical::Logs.new(file, [:apache, :combined]) | |
# How many hits per page ?? | |
(debug (summarize LOGS, :path, :count => (count '*'))) | |
# What pages have not been found ?? | |
NOT_FOUND = (restrict LOGS, ->(t){ t[:http_status].eq(404) }) |
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
class Hello extends Brick | |
constructor: -> | |
# Cell for the current view | |
@current = new Cell | |
# View handler for #content | |
@content = new View | |
selector: |
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
# A benchmark pioneered by @tenderlove | |
# @see https://gist.github.com/1170106 | |
class Sloppy | |
def sloppy; @sloppy; end | |
end | |
class Tidy | |
def initialize; @tidy = nil; end | |
def tidy; @tidy; 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
require 'wlang' | |
$vars = [] | |
dialect = WLang::dialect do | |
rule "#" do |parser, offset| | |
varname, reached = parser.parse(offset) | |
$vars << varname | |
["#{varname}", reached] |
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
gem "grit", :git => "[email protected]:blambeau/grit.git" |
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
class Hash | |
def with(&block) | |
block.call *block.parameters.map{|x| self[x.last]} | |
end | |
end | |
# Example | |
h = {:name => "blambeau", :hobby => "ruby"} |
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
require 'http' | |
NB = 5 | |
times = [] | |
threads = (0..NB).map do |i| | |
Thread.new(i) {|nb| | |
t1 = Time.now | |
puts Http.get("http://127.0.0.1:3000") | |
t2 = Time.now | |
times[nb] = (t2-t1) |
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
source "http://rubygems.org/" | |
gem "sinatra", "~> 1.3.0" | |
gem "thin" |
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
source :rubygems | |
gem "citrus" | |
gem "rspec" |
OlderNewer