Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
require "open-uri"
loop do
puts( open("http://finance.google.com/finance?cid=983582").read.
match(/<span class="chr" id="ref_983582_c">(-?\d+\.\d+)/m)[1] )
sleep(10)
end
header margin_box.top_left do
text "Here's My Fancy Header", :size => 25, :align => :center
stroke_horizontal_rule
end
footer [margin_box.left, margin_box.bottom + 25] do
stroke_horizontal_rule
text "And here's a sexy footer", :size => 16
end
file = "lazy_bounding_boxes.pdf"
Prawn::Document.generate(file, :skip_page_creation => true) do
point = [bounds.right-50, bounds.bottom + 25]
page_counter = lazy_bounding_box(point, :width => 50) do
text "Page: #{page_count}"
end
10.times do
start_new_page
text "Some text"
Prawn::Document.generate("family_style.pdf") do
["Courier","Helvetica","Times-Roman"].each do |f|
[:bold,:bold_italic,:italic,:normal].each do |s|
font f, :style => s
text "I'm writing in #{f} (#{s})"
end
end
font "Helvetica"
pdf = Prawn::Document.new(:page_size => "LEGAL") do
text "Blahdiblah"
image "my_sexy_pic.png"
end
pdf.render
require "thought"
class Thought
class SafetyFirst
def analyze(map, rover)
return unless map.threat.nonzero?
if 2 * rover.speed > rover.max_sensor or
(rover.rotation_speed and rover.speed > rover.rotation_speed)
Vote.new("b*", 99)
04:27 < mindaugas> Hello, i've got problem with prawnto rails plugin, I followed carefully all the steps as described in http://cracklabs.com/prawnto/use but my controller actions still looking for erb templates... and all i get is "template is missing" error. I wonder, what i'm missing ?
04:33 < mindaugas> I'm on windows xp with rails 2.1
04:39 < yob> are you calling http://host/controller/action/id.pdf ?
04:49 < mindaugas> Thanks yob, your question just put me in the right direction, it works now, i'm still newb :)
04:51 < yob> no probs
04:51 < yob> the format stuff is black magic if you haven't used it before
$ spec spec/
Prawn specs: Running on Ruby Version: 1.9.0
.......................F.F.................................................................................................F.......................
1)
Spec::Mocks::MockExpectationError in 'When ending each page should execute the lambda specified by on_page_end'
Mock 'page_end_proc' expected :[] with (any args) 3 times, but received it 0 times
/Users/sandal/devel/prawn/spec/document_spec.rb:68:in `block (2 levels) in <top (required)>'
2)
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
["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