If one was inclined to use the acts_as_yaffle pattern, they would probably use the second one, rather than the heavily cargo-culted first one.
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 Decorator | |
def decorate(decorator_name, &block) | |
(class << self; self; end).class_eval do | |
define_method(decorator_name) do |method_name_to_decorate| | |
with_feature = "#{method_name_to_decorate}_with_#{decorator_name}" | |
without_feature = "#{method_name_to_decorate}_without_#{decorator_name}" | |
define_method with_feature do | |
# call decorator code passing argument of a proc that will call original method |
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
#!/usr/bin/env ruby | |
# | |
# Assignment block tidier, version 0.1. | |
# | |
# Copyright Chris Poirier 2006. | |
# Licensed under the Academic Free License version 3.0. | |
# | |
# This script can be used as a command for TextMate to align all | |
# of the equal signs within a block of text. When using it with | |
# TextMate, set the command input to "Selected Text" or "Document", |
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
sadasdasd |
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[:slow].present? %> | |
<% 100.times do %> | |
<% content_tag :div do %> | |
Something here!! | |
<% end -%> | |
<% end -%> | |
<% else %> | |
<% 100.times do %> | |
<%= content_tag :div, "Something here!!" %> | |
<% 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
.DS_Store | |
*.log |
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
=begin | |
FOR UPDATE | |
- no one else can SELECT ... FOR UPDATE the row | |
- no one else can update/delete the row | |
LOCK IN SHARE MODE | |
- others may SELECT ... LOCK IN SHARE MODE | |
- no one else can update/delete the row | |
=end | |
require 'rubygems' |
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
16. Fix opacity on IE8 | |
view source | |
print? | |
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> | |
Internet Explorer 8 is a bit peculiar when it comes to support CSS opacity. It still doesn’t support the ‘opacity’ property like any other browser, but also breaks support for ‘filter: alpha(opacity=XX)’, which worked fine in IE6 and IE7. To work around this, insert above meta element in the HEAD section of the HTML. | |
(from http://mir.aculo.us/2010/04/30/build-a-flash-like-game-with-scripty2/) |
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 'open-uri' | |
# url dsl -- the ultimate url dsl! | |
# | |
# You just can't beat this: | |
# | |
# $ irb -r url_dsl | |
# >> include URLDSL | |
# => Object | |
# >> http://github.com/defunkt.json |