Skip to content

Instantly share code, notes, and snippets.

Avatar

Gregory Brown practicingruby

View GitHub Profile
View time_prog.rb
duration,time,difference
1,20.367,3.367
2,23.967,3.600
3,27.167,3.200
4,32.833,5.666
5,37.933,5.100
6,40.333,2.400
7,42.600,2.267
8,45.767,3.167
9,47.333,1.566
View temperature_test.rb
require 'test/unit'
require 'rubygems'
require 'mocha'
class TemperatureSampler
def initialize(sensor)
@sensor = sensor
end
def average_temp
View FAIL
Prawn specs: Running on Ruby Version: 1.9.0
..............................................................................................FFF.............................................F..
1)
ArgumentError in 'adobe font metrics should calculate string width taking into account accented characters'
malformed UTF-8 character (expected 3 bytes, given 1 bytes)
/Users/sandal/devel/prawn/spec/metrics_spec.rb:13:in `block (2 levels) in <top (required)>'
2)
ArgumentError in 'adobe font metrics should calculate string width taking into account kerning pairs'
View blaag.rb
["rubygems","builder","yaml", "fileutils", "redcloth", "erb"].each { |l| require l }
class Blaag
TITLE = "Majestic Sea Creature"
DOMAIN = "blog.majesticseacreature.com"
AUTHOR = "Gregory Brown"
DESCRIPTION = "Technical Ramblings from #{AUTHOR}"
BASEDIR = File.dirname(File.expand_path(__FILE__)) + "/../"
def self.generate
@practicingruby
practicingruby / rss.rb
Created Aug 6, 2008
RSS parsing for Blaag
View rss.rb
def to_rss
xml = Builder::XmlMarkup.new
xml.instruct!
xml.rss :version => "2.0" do
xml.channel do
xml.title TITLE
xml.link "http://#{DOMAIN}/"
xml.description DESCRIPTION
xml.language "en-us"
View sample
=title
A Sample Post
=description
This is how I want posts in Blaag to look,
making things feel a whole lot like an ordinary text file
=entry
The main body of the entry begins here,
and I am free to use _Textile_
View blaag.rb
class Entry
def self.registry
@registry ||= YAML.load_file("#{Blaag::BASEDIR}/data/registry.yml")
end
def self.update_registry(filename,mtime)
registry[filename] ||= mtime
File.open("#{Blaag::BASEDIR}/data/registry.yml","w") do |f|
f << @registry.to_yaml
View blaag.rb
def self.generate
entries = Dir["#{Blaag::BASEDIR}/entries/**/*"].
reject { |f| File.directory?(f) }
entries.map! { |e| Entry.load(e) }
@blaag = Blaag.new(entries)
File.open("#{Blaag::BASEDIR}/www/index.html","w") { |f|
f << layout { @blaag.to_html }
View blaag.rb
["rubygems","builder","yaml", "fileutils", "redcloth", "erb","uri"].each { |l| require l }
class Blaag
TITLE = "Majestic Sea Creature"
DOMAIN = "blog.majesticseacreature.com"
AUTHOR = "Gregory Brown"
DESCRIPTION = "Technical Ramblings from #{AUTHOR}"
BASEDIR = File.dirname(File.expand_path(__FILE__)) + "/../"
def self.generate
View contexts_fail.rb
describe "A context" do
describe "With nesting" do
it "won't run in 1.9.0_3"
end
end
#####
$ ruby -v
ruby 1.9.0 (2008-07-25 revision 18217) [i686-darwin8.11.1]
$ spec foo.rb
You can’t perform that action at this time.