Skip to content

Instantly share code, notes, and snippets.

View thbar's full-sized avatar

Thibaut Barrère thbar

View GitHub Profile
ruby -S spec spec/unit/simple_pdf_spec.rb
if [ $? -eq 0 ]
then open spec/unit/simple-output.pdf
else
echo "Failed to generate PDF"
fi
require 'hpricot'
=begin
Untested code showing how a custom parser can be used in
ActiveWarehouse-ETL to translate one xml element like:
<client>
<account_number>9999</account_number>
<telephone_number>8885551212</telephone_number>
# find_each is not there yet in MongoMapper 0.6.10 - here's a backport
def find_each(options)
criteria, options = to_finder_options(options)
collection.find(criteria, options).each do |doc|
yield initialize_doc(doc)
end
end
require 'rubygems'
require 'prawn/core'
# don't do this - only the first doc will be A4 formatted
OPTIONS = { :page_size => 'A4' }
Prawn::Document.generate("1.pdf", OPTIONS) do
end
# gem unpack your gem into ./gems folder
# then tweak the LOAD_PATH after Bundler.setup
Dir[File.dirname(__FILE__) + "/gems/*/lib"].each { |f| $LOAD_PATH.insert(0,f) }
@thbar
thbar / pages-numbers-prawn.rb
Created July 13, 2010 15:39
Logo + page numbers with prawn 0.8.4
require "prawn/core"
require "prawn/layout"
require "prawn/measurement_extensions"
Prawn::Document.generate(output_filename, options) do
repeat(:all, :dynamic => true) do
if (page_number == 1)
image File.dirname(__FILE__) + "/../logos/...", :at => [x.cm,y.cm], :height => x.cm
end
SystemStackError: stack level too deep
/Users/thbar/.rvm/gems/ruby-1.8.7-p249/gems/resque-1.9.10/lib/resque/helpers.rb:15:in `to_json'
/Users/thbar/.rvm/gems/ruby-1.8.7-p249/gems/resque-1.9.10/lib/resque/helpers.rb:15:in `encode'
/Users/thbar/.rvm/gems/ruby-1.8.7-p249/gems/resque-status-0.1.4/lib/resque/status.rb:34:in `set'
/Users/thbar/.rvm/gems/ruby-1.8.7-p249/gems/resque-status-0.1.4/lib/resque/job_with_status.rb:121:in `status='
/Users/thbar/.rvm/gems/ruby-1.8.7-p249/gems/resque-status-0.1.4/lib/resque/job_with_status.rb:183:in `set_status'
/Users/thbar/.rvm/gems/ruby-1.8.7-p249/gems/resque-status-0.1.4/lib/resque/job_with_status.rb:161:in `failed'
/Users/thbar/.rvm/gems/ruby-1.8.7-p249/gems/resque-status-0.1.4/lib/resque/job_with_status.rb:109:in `safe_perform!'
/Users/thbar/.rvm/gems/ruby-1.8.7-p249/gems/resque-status-0.1.4/lib/resque/job_with_status.rb:87:in `perform'
/Users/thbar/.rvm/gems/ruby-1.8.7-p249/gems/resque-1.9.10/lib/resque/job.rb:129:in `perform'
$ gem list -d bundler
*** LOCAL GEMS ***
bundler (0.9.26)
Authors: Carl Lerche, Yehuda Katz, André Arko
Rubyforge: http://rubyforge.org/projects/bundler
Homepage: http://github.com/carlhuda/bundler
Installed at: /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8
require 'rubygems'
require 'test/unit'
#gem 'mongo', '1.0.5' # -> won't work
gem 'mongo', '1.0.6' # -> will work
require 'mongo'
class MyTest < Test::Unit::TestCase
def test_connect
#!/bin/bash
#
# god Startup script for god (http://god.rubyforge.org)
#
# chkconfig: - 85 15
# description: God is an easy to configure, easy to extend monitoring \
# framework written in Ruby.
#
CONF_DIR=/etc/god