[
"id",
"other_id",
"other_type",
"stuff",
"things",
This file contains hidden or 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 Object | |
def | other | |
case other | |
when Proc | |
if self.is_a?(Proc) | |
proc { |input| other.call( self.call(input) ) } | |
else | |
other.call(self) | |
end | |
else |
This file contains hidden or 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
# | |
# RFC822 Email Address Regex | |
# -------------------------- | |
# | |
# Originally written by Cal Henderson | |
# c.f. http://iamcal.com/publish/articles/php/parsing_email/ | |
# | |
# Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb. | |
# | |
# Licensed under a Creative Commons Attribution-ShareAlike 2.5 License |
This file contains hidden or 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
site :opscode | |
metadata | |
cookbook 'locale', | |
git: "https://github.com/hw-cookbooks/locale.git", | |
tag: "v1.0.0" |
This file contains hidden or 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 Arel | |
module Predications | |
def not_eq other | |
if other.is_a? Nodes::Not | |
Nodes::Equality.new self, other.value | |
else | |
Nodes::NotEqual.new self, other | |
end | |
end |
How should ActiveRecord behave with merging conditions from various sources? See rails/rails#9813 for background.
- clobber: conflicting condition values are replaced with the rightmost value
- append: conflicting condition values are chained into an AND query
This file contains hidden or 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
v=0000;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP | |
4ZojjV)O>qIH1/n[|2yE[>:ieC "%.#% :::##" 97N-A&Kj_K_><wS5rtWk@*a+Y5 | |
yH?b[F^e7C/56j|pmRe+:)B "##% ::##########" O98(Zh)'Iof*nm.,$C5Nyt= | |
PPu01Avw^<IiQ=5$'D-y? "##: ###############" g6`YT+qLw9k^ch|K'),tc | |
6ygIL8xI#LNz3v}T=4W "# #. .####:#######" lL27FZ0ij)7TQCI)P7u | |
}RT5-iJbbG5P-DHB<. " ##### # :############" R,YvZ_rnv6ky-G+4U' | |
$*are@b4U351Q-ug5 " #######################" 00x8RR%`Om7VDp4M5 | |
PFixrPvl&<p[]1IJ " ############:#### %#####" EGgDt8Lm#;bc4zS^ | |
y]0`_PstfUxOC(q " .#############:##% .## ." /,}.YOIFj(k&q_V | |
zcaAi?]^lCVYp!; " %% .################. #. " ;s="v=%04o;ev"% |
This file contains hidden or 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 'active_support/time' | |
require 'active_support/version' | |
t0 = Time.now # => 2013-05-26 01:14:51 +0000 | |
t1 = t0 + 86400 | |
t2 = t0 + 1.day | |
puts "Ruby %s / ActiveSupport %s" % [RUBY_VERSION, ActiveSupport::VERSION::STRING] | |
puts "Time + Fixnum nsec: %s" % t1.nsec # => 11111111 | |
puts "Time + AS::Duration nsec: %s" % t2.nsec # => 11111000 |
This file contains hidden or 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
pry> c = ObjectSpace.each_object.detect { |i| i.class.to_s == "#<Class:0xb8f4e33c>" } | |
pry> c | |
=> {:perform_caching=>true, | |
:request_forgery_protection_token=>:authenticity_token, | |
:allow_forgery_protection=>true, | |
:relative_url_root=>nil, | |
:logger=> | |
#<ActiveSupport::TaggedLogging:0xbc9d972c... | |
:cache_store=> |
Override ActionController layout class method to take a view_options hash, whether or not the actual layout template is being changed:
layout "foo", view_options: {sidebar: 'special'}
layout view_options: {sidebar: 'special'}
Define a LayoutOptions module in the controller class and give it to the view helpers. It would define methods: