Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
require "prawn/core"
class Prawn::Document
def go_to_page(k)
jump_to = @store.pages.data[:Kids][k]
@current_page = jump_to.identifier
@page_content = jump_to.data[:Contents].identifier
end
def number_pages(string, position)
require "prawn/core"
class Prawn::Document
def go_to_page(k)
jump_to = @store.pages.data[:Kids][k]
@current_page = jump_to.identifier
@page_content = jump_to.data[:Contents].identifier
end
def number_pages(string, position)
IMAGE_TYPES = %w( image/jpeg image/png image/pjpeg image/x-png image/gif )
validates_attachment_content_type :image, :content_type => IMAGE_TYPES
acc += (e.is_a?(Hash) && e.has_key?(:colspan)) ? e[:colspan] : 1
cell_text = cell.is_a?(Hash) ? cell[:text] : cell.to_s
if cell.is_a?(Hash) && cell[:colspan]
text = e.is_a?(Hash) ? e[:text] : e.to_s
width = if e.is_a?(Hash) && e.has_key?(:colspan)
-module(ttfunk).
-define(uint8, 8/unsigned-big-integer).
-define(int8, 8/signed-big-integer).
-define(uint16, 16/unsigned-big-integer).
-define(int16, 16/signed-big-integer).
-define(uint32, 32/unsigned-big-integer).
-define(int32, 32/signed-big-integer).
-export([parse/1]).
The Traveling Hacker --------------------
Today you will be building a tool for a travel agency that determines the
total distance traveled on a tour with many stops. As luck would have it, some
of the core functionality you need has already been implemented, and you won't
need to worry about coding a mileage and routing system from scratch.
But there's a catch: The mileage and routing system you'll be using lies on
the other side of a service boundary, and only minimal work has been done on
the client side. Essentially, all that has been written so far is a bit of
Role.define "guest",
:permissions => [:read_questions]
Role.define "basic",
:permissions => [:read_answers, :answer_questions]
Role.define "premium",
:parent => "basic",
:permissions => [:hide_advertisements]
def paint(canvas, filename)
doc = Prawn::Document.new
doc.add_content(canvas.to_pdf)
doc.render_file(filename)
end
canvas = Prawn::Canvas.new
canvas.line(:point1 => [100,100], :point2 => [150,175])
canvas.move_to(:point => [100,100])
canvas.curve_to(:point => [50,50], :bounds => [[60,90], [60,90]])
module Prawn
class Canvas
include Prawn::Chunkable
def initialize
@chunks = []
end
attr_accessor :chunks