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
module PatientHelpers | |
include ActionController::Base.helpers | |
include Haml::Helpers | |
init_haml_helpers | |
end | |
def h | |
h ||= Object.new.extend(PatientHelpers) | |
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
(defn make-registry [] | |
(doto (carbonite.api/default-registry) | |
(.setClassLoader (clojure.lang.DynamicClassLoader.)))) |
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 'formula' | |
class Carbon < Formula | |
homepage 'http://graphite.wikidot.com/' | |
url 'http://pypi.python.org/packages/source/c/carbon/carbon-0.9.10.tar.gz' | |
md5 '1d85d91fe220ec69c0db3037359b691a' | |
depends_on 'python' | |
depends_on 'twisted' => :python | |
depends_on 'whisper' |
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
foreground-vim() { | |
fg %vim | |
} | |
zle -N foreground-vim | |
bindkey '^Z' foreground-vim |
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
table = pdf.make_table([["foo", "bar"], | |
["baz\n"*18, "quux"]], :position => :center) | |
pdf.move_down((pdf.bounds.height - table.height) / 2.0) | |
table.draw |
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
obj = %{<< /Rect [ 330.521 116.285 346.958 128.321 ] /F 4 /T (Check Box1) /Subtype | |
/Widget /P 3 0 R /MK 139 0 R /AP 140 0 R /H /P /V / /AS /Off /FT /Btn /Type | |
/Annot >>} | |
buf = PDF::Reader::Buffer.new(StringIO.new(obj)) | |
parser = PDF::Reader::Parser.new(buf, nil) | |
parser.parse_token | |
# => {:Rect=>[330.521, 116.285, 346.958, 128.321], :F=>4, :T=>"Check Box1", :Subtype=>:Widget, :P=>#<PDF::Reader::Reference:0x000000012afd40 @id=3, @gen=0>, :MK=>#<PDF::Reader::Reference:0x000000012ad298 @id=139, @gen=0>, :AP=>#<PDF::Reader::Reference:0x000000012accd0 @id=140, @gen=0>, :H=>:P, :V=>:"", :AS=>:Off, :FT=>:Btn, :Type=>:Annot} |
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 'prawn' | |
class ChangingMarginDocument < Prawn::Document | |
def start_new_page(options={}) | |
if (page_count % 2).zero? | |
super(:left_margin => 72, :right_margin => 36) | |
else | |
super(:left_margin => 36, :right_margin => 72) | |
end | |
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
Prawn::Document.generate("test_height.pdf") do |pdf| | |
box = Prawn::Text::Box.new("foo bar baz " * 50, :document => pdf, | |
:overflow => :shrink_to_fit, :height => 20) | |
box.render | |
puts box.height # >> 19.422 | |
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
Prawn::Document.new do |pdf| | |
box = Prawn::Text::Box.new("foo bar baz " * 50, :document => pdf, | |
:overflow => :expand, :height => 1) | |
box.render | |
puts box.height # >> 80.46 | |
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
Prawn::Document.generate 'test_table.pdf', :page_layout => :landscape do |pdf| | |
data = [(1..10).map { "foo bar baz " * 20 }] * 5 | |
pdf.table data, :column_widths => [96,120,54,54,54,54,54,54,54,54] do |t| | |
t.column(0).style :overflow => :shrink_to_fit, :min_font_size => 6 | |
end | |
end |