Skip to content

Instantly share code, notes, and snippets.

View markbates's full-sized avatar

Mark Bates markbates

View GitHub Profile
class GemHelper # :nodoc:
include Singleton
attr_accessor :project
attr_accessor :package
attr_accessor :gem_name
attr_accessor :version
def initialize
self.project = "magrathea"
class WelcomeEmail
include Mack::Mailer
end
mail = WelcomeEmail.new
mail.to = "foo@example.com"
mail.from = "me@example.com"
mail.subject = "Hello"
mail.body(:plain) = "This is my plain text body"
mail.body(:html) = "This is my <b>HTML</b> body"
<script>
var helium = Array.new;
</script>
<div id=debate_1>
<script>
helium[0] = "debate_1"
</script>
</div>
...
<%
@simple = "hi"
@user = User.new(:username => "markbates", :level => 1)
@default_file = "~/resume.doc"
-%>
check_box
<%= :simple.check_box %>
<input type="checkbox" name="simple" id="simple" checked="checked">
module Mack
module Rendering # :nodoc:
module Engine # :nodoc:
class Pdf < Mack::Rendering::Engine::Base
def render(io, binding)
if io.is_a?(File)
io = io.read
end
@_pdf = ::PDF::Writer.new
pdf.select_font "Times-Roman"
pdf.fill_color(Color::RGB::Red)
pdf.text @post.title, :font_size => 24, :justification => :center
pdf.fill_color(Color::RGB::Black)
pdf.text "by #{@post.email}", :font_size => 12, :justification => :center
pdf.with_options(:font_size => 10, :justification => :left) do |p|
p.text "nn"
p.text @post.body
p.text "nn"
p.text "Created at: #{@post.created_at}"
cachetastic_default_options:
# this will dump into the log, configuration info for each cache, as well as the .inspect
# for each object returned from the cache
debug: true # true | false (default: false)
# this is the type of file store to be used for this cache.
# more adapters can be developed and plugged in as desired
adapter: local_memory # local_memory | memcache | file | drb | html_file (default: local_memory)
# this will marshall objects into and out of the store.
marshall_method: none # none | yaml | ruby (default: none)
# this sets how long objects will live in the cache before they are auto expired.
module Mack # :nodoc:
module Routes # :nodoc:
module Urls
# Retrieves a distributed route from a DRb server.
#
# Example:
# droute_url(:app_1, :home_page_url)
# droute_url(:registration_app, :signup_url, {:from => :google})
def droute_url(app_name, route_name, options = {})
class Passport
include DataMapper::Resource
storage_names[:hls] = "tbl_pssptz"
property :id, Integer, :key => true
property :country_code, String, :nullable => false
property :expiration_date, Date, :nullable => false
repository(:hls) do
class UsersController
include Mack::Controller
def show
@user = User.get(params[:id])
wants(:xml) do
render(:text, @user.to_xml)
end
wants(:html) do
# do some more work to set up the view...