Skip to content

Instantly share code, notes, and snippets.

function mvim() {
if [ -d "$1" ]; then
local dir=$(printf %q "$1")
command mvim --cmd ":cd $dir" "$@"
else
command mvim "$@"
fi
}
class Range
def sample
b, e = self.begin, self.end
a = exclude_end? ? 1 : 0
case b
when Integer
rand(1 + e - b - a) + b
when Float
rand * (e - b) + b
else
From 8489ff9d81a806df12518e4606c0df5bb0fa8095 Mon Sep 17 00:00:00 2001
From: Magnus Holm <[email protected]>
Date: Tue, 29 Mar 2011 22:32:21 +0200
Subject: [PATCH] Add Tilt compilation to benchmarks
---
benchmarks/run.rb | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/benchmarks/run.rb b/benchmarks/run.rb
@judofyr
judofyr / tilt_test.sh
Created April 13, 2011 16:14
test_tilt.sh
### WARNING: This will install/uninstall gems, so please run it in a separate gemset.
echo "### SETUP"
ruby -v
rm -rf /tmp/tilt_tests
git clone git://github.com/rtomayko/tilt.git /tmp/tilt_tests
cd /tmp/tilt_tests
git show-ref HEAD
# Install development gems
## Genetic Hello World in Ruby
# Based on https://github.com/jsvazic/GAHelloWorld
class Chromosome
TARGET = "Hello World!"
attr_reader :gene, :fitness
def initialize(gene)
@gene = gene
e = ERB.new('views/index.erb')
get '/erb/:username' do
@var = "Hello #{params[:username]}"
e.result(binding)
end
require 'tilt'
require 'erb'
require 'benchmark'
# http://twitter.com/tiodante/status/60685349868929024
#
# "Sinatra doesn't make ERB slow, Tilt does (and for smaller templates). ERB in
# itself is fast if used properly."
# Testing with a small template:

Tilt's main features

All of these features work with each other.

# Helper method
def render(tmpl, scope = Object.new, locals = {}, &blk)
  Tilt['erb'].new { tmpl }.render(scope, locals, &blk)
end

Custom scope (without monkey patching of any kind)

require 'test/unit'
require 'tilt'
# See below for example of usage
module RenderTests
class Scope
String = 1
end
@judofyr
judofyr / nokogiri.txt
Created April 21, 2011 10:05
Gems that depends on Nokogiri
bbrowning-deltacloud-core
0.0.6.1 - nokogiri >=1.4.1
oa-enterprise
0.2.3 - nokogiri ~>1.4.2
xml_mapper
0.5.6 - nokogiri >=0
gotaku
0.3.0 - nokogiri ~>1.4.4
companies-house
0.1.0 - nokogiri >=0