This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'activesupport' | |
class StringProxy | |
def initialize(string, negate) | |
@string = string | |
@negate = negate | |
end | |
def method_missing(name, *args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Bar | |
def self.foo | |
puts "foo.bar" | |
end | |
end | |
Bar.foo # => outputs foo.bar | |
class << Bar | |
remove_method :foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_permalinks | |
# note that this test assumes you haven't changed the `extra_word` argument of Post.to_permalink | |
# from the default 'again'... if you have, change the equality assertions below appropriately | |
p = Post.new | |
p.title = 'test post' | |
p.body_raw = "this is my post content and it's a test" | |
assert p.save | |
assert_equal (Preference.get_setting('SIMPLE_TITLES') == 'yes' ? 'this_is_my_post_content' : 'test_post'), p.permalink | |
# cleaning HTML... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_pref_speed | |
total = 0 | |
total2 = 0 | |
10.times do | |
start = Time.now | |
Preference.get_setting('domain') | |
Preference.get_setting('site_name') | |
Preference.get_setting('slogan') | |
Preference.get_setting('site_description') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AccountController < ApplicationController | |
def signup | |
@user = User.new(params[:user]) | |
if @user.save | |
run_later do | |
AccountMailer.deliver_signup(@user) | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if @params[:highlighting] | |
hash[:hl] = true | |
hash["hl.fl"] = @params[:highlighting][:field_list].join(',') if @params[:highlighting][:field_list] | |
snippets = @params[:highlighting][:max_snippets] | |
if snippets | |
if snippets.kind_of? Hash | |
if snippets[:default] | |
hash["hl.snippets"] = snippets[:default] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def new(clazz) | |
clazz.new | |
end | |
end | |
obj = new Object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Persistence | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
def start_transaction | |
puts "Starting transaction" | |
end | |
def commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load 'deploy' if respond_to?(:namespace) # cap2 differentiator | |
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } | |
load 'config/deploy' | |
gem 'mattmatt-cap-ext-webistrano' | |
require 'cap-ext-webistrano' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Project < ActiveResource::Base | |
self.site = "http://localhost:3000" | |
end | |
@projects = Project.find(:all) |
OlderNewer