Skip to content

Instantly share code, notes, and snippets.

View HHRy's full-sized avatar
👔
Looking for work, contact me!

Ryan Stenhouse HHRy

👔
Looking for work, contact me!
View GitHub Profile
name: keynote
title: Keynote Theme
font_color: 'FFFFFF'
background_colour: '000000'
marker_colour: 'FFFFFF'
stroke_grid_markers: 0
colours:
- '6886B4'
- 'FDD84E'
- '72AE6E'
Prawn::Document.generate('bar_graph.pdf') do
bar_graph 'Hornets on Weekdays', [ 10, 10 ], :keynote do |graph|
graph.data 'Monday', 5
graph.data 'Tuesday', 4
graph.data 'Wednesday', 3
graph.data 'Thursday', 2
graph.data 'Friday', 1
graph.label_x 'Week Day'
graph.label_y 'Number of Hornets'
end
require "#{File.dirname(__FILE__)}/../example_helper.rb"
options = {
:title => 'Average litter size per kind of animal',
:label_x => 'Kind of animal',
:label_y => 'Average litter size',
:theme => Prawn::Chart::Themes.monochrome ,
:at => [10,10]
}
set :trigger_sign, '!'
on :privmsg, :in => :channel, :trigger => 'stuff' do |channel, user, message|
channel.message StuffMachine.random_entry
end
on :privmsg, :in => :channel, :trigger => 'findstuff' do |channel, user, message|
user.notice StuffMachine.find(message)
end
@HHRy
HHRy / prawn-oddness.rb
Created September 10, 2010 10:32
Strange behaviour with Prawn
require 'rubygems'
require 'prawn'
pdf = Prawn::Document.new(:page_size => "A4", :page_layout => :landscape)
pdf.bounding_box [0, pdf.bounds.height - 40,], :width => 740 do
# No Entries
#
pdf.table([["Total Value of Spend", "Total Transactions", "Average Transaction Value"], ["4558.5100", "30", "151.95033333"]], :header => true) do
row(0).style(:style => :bold, :background_color => 'cccccc')
end
# Replace the YAML'd hash in config/database.yml with an actual Ruby hash.
#
{
:development => { :name => 'dev', :adapter => 'mysql', :username => 'root', :password => '' },
:test => { :name => 'test', :adapter => 'mysql', :username => 'root', :password => '' },
:production => { :name => 'prod' :adapter => 'mysql', :username => 'db', :password => '1234', :host => 'db1.app.com' }
}
@HHRy
HHRy / prawn_graph_two_with_background_document.rb
Created October 25, 2010 22:21
A little example of what I'm working on just now, Prawn::Graph version two and Prawn::BackgroundDocument, a way to offload the generation of complicated PDFs.
require 'prawn'
require 'prawn/graph'
require 'prawn/background_document'
require 'active_record'
Prawn::BackgroundDocument.generate('some_file.pdf', :callback => [ :completed, :failure ]) do |pdf|
pdf.bar_graph Bees.where('number_spotted > 0').order('number_spotted'), :best_fit
end
def completed
# GemAgent API Interface
# Ryan Stenhouse, 20 January 2011
# Longhand representation of connecting to the FreeAgent API
#
ga = GemAgent::NetHttpConnection.new 'you.freeagentcentral.com', GemAgent::HttpBasicAuthentication.new('username','password')
ga.verify # => { :user_id => 1, :permission_level => 8, :company_type => UK_LIMITED }
# Sexy sugary version of the above.
#
@HHRy
HHRy / gist:907521
Created April 7, 2011 10:39
Chad's configuration DSL Exercise - My attempt.
class Configuration
attr_accessor :tail_logs, :max_connections, :admin_password, :app_server
class AppServer
attr_accessor :port, :admin_password
end
def initialize
@app_server = AppServer.new
end