I hereby claim:
- I am kdwinter on github.
- I am kdwinter (https://keybase.io/kdwinter) on keybase.
- I have a public key whose fingerprint is 6B53 97C8 5A66 AA0F 4D4C F915 3C0E 8824 60A5 849A
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
require 'benchmark' | |
Benchmark.bm 20 do |x| | |
x.report "define_method" do | |
25_000.times do | |
class MyClass | |
define_method :foo do | |
puts 'hi' | |
end | |
end |
module Authenticable | |
extend ActiveSupport::Concern | |
included do | |
key :username, String | |
key :email, String | |
key :crypted_password, String | |
key :password_salt, String | |
key :persistence_token, String | |
key :login_count, Integer, :default => 0 |
module Authenticable | |
def self.included(model) | |
model.class_eval do | |
extend ClassMethods | |
include InstanceMethods | |
field :username | |
field :email | |
field :crypted_password | |
field :password_salt |
<% cache 'recent_pages' do %> | |
<% @pages.each do |page| %> | |
<%=h page.title %> | |
<%# ... %> | |
<% end %> | |
<% end %> |
# include this in application controller | |
module Authentication | |
protected | |
# Inclusion hook to make #current_user and #signed_in? | |
# available as ActionView helper methods. | |
def self.included(base) | |
base.send :helper_method, :current_user, :signed_in?, :authorized? if base.respond_to? :helper_method | |
end | |
# Returns true or false if the user is signed in. |
development: &global_settings | |
database: textual_development | |
host: 127.0.0.1 | |
port: 27017 | |
test: | |
database: textual_test | |
<<: *global_settings | |
production: |
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb | |
# and made a lot more robust by me | |
# this implementation uses erb by default. if you want to use any other template mechanism | |
# then replace `erb` on line 13 and line 17 with `haml` or whatever | |
module Sinatra::Partials | |
def partial(template, *args) | |
template_array = template.to_s.split('/') | |
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}" | |
options = args.last.is_a?(Hash) ? args.pop : {} | |
options.merge!(:layout => false) |