Skip to content

Instantly share code, notes, and snippets.

View markbates's full-sized avatar

Mark Bates markbates

View GitHub Profile
require 'rubygems'
require 'configatron'
class Hello
def self.say_hi
configatron.hello
end
end
<h1>Edit User</h1>
<%= error_messages_for :user %>
<%= debug @user %>
<% form(users_update_url(:id => @user), :class => "edit_user", :id => "edit_user", :method => :put) do %>
<p>
1: <%= :user.radio_button :level, :value => 1, :label => true %>
2: <%= :user.radio_button :level, :value => 2, :label => true %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>users: edit</title>
<link href="/stylesheets/scaffold.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
require 'rubygems'
require 'configatron'
store = Configatron::Store.new
store.foo = :bar
puts store.foo
store.one.two.three = [1,2,3]
configatron.letters.a = 'A'
configatron.letters.b = 'B'
configatron.lock(:letters)
configatron.letters.a = 'C' # ok
configatron.letters.b = 'D' # ok
configatron.letters.c = 'C' # raises Configatron::LockedNamespace
configatron.letters.d = 'D' # raise Configatron::LockedNamespace
configatron.letters.whatever_else = :foo # raises Configatron::LockedNamespace
class GodfatherFormBuilder
include Mack::View::FormBuilder
def text_field(*args)
"<p>#{element(:text_field, *args)}</p>"
end
def all(sym, *args)
"<i>#{element(sym, *args)}</i>"
end
class StripesBuilder
include Mack::View::FormBuilder
partial :text_field, 'fb_partials/text_field'
partial :form_start, 'fb_partials/form_start'
partial :all, 'fb_partials/all'
def form_end
'</div>'
end
require 'pcp_middleware'
require 'benchmark'
configatron.sr.pcp.default_partner = 'www'
configatron.sr.pcp.default_configuration_name = 'site'
configatron.sr.pcp.partner.cache = false
configatron.sr.pcp.partner.site = 'https://test_user:abc123@pcp.stage.secondrotation.com'
res = Benchmark.realtime do
10.times do
13239240
13099710
12966510
12832220
12694260
12511350
12362990
12237120
13938470
13709900
Part 1: Standard Library
Chapter 1: Distributed Ruby (DRb)
1.1 Hello World
1.2 Proprietary Ruby Objects
1.3 Security
1.3.1 Access Control Lists (ACLs)
1.3.2 DRb Over SSL
1.4 ID Conversion
1.4.1 Built-in ID Converters