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
# A small example of Method Forwarding | |
# | |
# The permissions are stored on the object concerned with access control. | |
# You send a message to one object, which forwards it to the access controller. | |
class User | |
attr_accessor :zombie | |
def method_missing(meth, object, *args) | |
if object.permissions | |
object.send(meth, self, *args) |
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
# Instead of writing ternary operators with respond_to?: | |
# obj.respond_to?(:method_one) ? obj.method_one : obj.method_two | |
# I want something simpler | |
class Object | |
def fallback(*args) | |
method_to_try = args.find{|meth| self.respond_to?(meth) && meth.to_s != __method__.to_s } | |
self.send(method_to_try) | |
end | |
alias trial fallback | |
alias trip fallback |
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
Bump:~ jim$ curl https://github.com/atmos/cinderella/raw/master/bootstrap.sh -o - | sh | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
102 1333 102 1333 0 0 5016 0 --:--:-- --:--:-- --:--:-- 31738 | |
Ensuring we have the latest version of cinderella installed | |
A first time install takes about 45 minutes on a modern machine | |
Cinderella installed successfully | |
[Thu, 02 Dec 2010 23:42:05 -0500] INFO: Setting the run_list to ["homebrew", "homebrew::dbs", "homebrew::misc", "ruby", "ruby::irbrc", "node", "python"] from JSON | |
[Thu, 02 Dec 2010 23:42:05 -0500] INFO: Starting Chef Run (Version 0.9.12) | |
[Thu, 02 Dec 2010 23:42:05 -0500] ERROR: Running exception handlers |
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
MarkdownFilterExtension.setup do |config| | |
config.auto_ids = false | |
config.parse_block_html = false | |
end |
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
.grid_list li | |
display: -moz-inline-box | |
-moz-box-orient: vertical | |
display: inline | |
display: inline-block | |
vertical-align: top | |
word-wrap: break-word | |
list-style: none | |
* html .grid_list li |
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
// Fisher-Yates shuffle | |
function fyshuffle(a){ var t,i,l = a.length; if(l) while(--l){ i = Math.floor(Math.random() * (l + 1)); t = a[i]; a[i] = a[l]; a[l] = t; }; return a;}; |
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
task :census => ['census:snippets', 'census:layouts'] | |
namespace :census do | |
desc "Show usage stats for Snippets" | |
task :snippets => :environment do | |
snippets, missing_snippets = snippet_usage | |
longest_name = snippets.keys.inject(0) do |max, name| | |
max = name.to_s.size > max ? name.to_s.size : max |
NewerOlder