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
def accumulate_js(key, path) | |
javascript_list[key] ||= [] | |
if path.class == Array || path.class == String | |
javascript_list[key] << path | |
javascript_list[key].flatten! | |
javascript_list[key].uniq! | |
else | |
raise ArgumentError | |
end | |
javascript_list |
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
var start = new Date(); | |
var end = new Date(); | |
end.setDate(end.getDate() + 7); | |
$.fullCalendar.gcalFeed("http://www.google.com/calendar/feeds/b878ac83tpkjckoqh1mccmsrfk%40group.calendar.google.com/public/basic",{currentTimezone: 'America/New_York'})(start, end, function(events){ | |
var now = new Date(); | |
var VALID_SHOW_TITLES = ["The Ruby Show", "The Conversation", "The Big Web Show", "The Dev Show", "EE Podcast"]; | |
// auto detect from the page title if we should check for the next show for this page | |
var current_page_belongs_to_show = $.grep(VALID_SHOW_TITLES, function(el, idx){ | |
return document.title.indexOf(el) > -1; |
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
# Usage include Categorizable::Categorized or Categorizable::Categorizable | |
module Categorizable | |
module Categorized | |
def self.included(klass) | |
associations = [ | |
[:has_many, :categorings], | |
[:has_many, :content_categories, {:through => :categorings}], | |
[:has_one, :primary_categoring, {:conditions => {:primary => true}, :class_name => "Categoring"}], | |
[:has_one, :primary_content_category, {:through => :primary_categoring}] |
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
# this is an experiment that I tried about 3 years ago. | |
# instead of calling asset.attachable.post.user.login just calling asset.login | |
class User < ActiveRecord::Base #fields are :login, :email | |
has_many :posts | |
has_many :channels | |
end | |
class Channel < ActiveRecord::Base #fields are :private(bool), :channel_type, :name | |
belongs_to :user |
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
hash = Hash.new(&(p = lambda{|hsh, key| hsh[key] = Hash.new(&p)})) | |
# now you can do this | |
hash[:this][:is][:very][:cool] = "Yeah baby, yeah ... " | |
#=> "Yeah baby, yeah ... " | |
hash | |
#=> {:this=>{:is=>{:very=>{:cool=>"Yeah baby, yeah ... "}}}} |
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 MyRakeContext | |
class MyClass < ::MyClass | |
#... different logic here | |
end | |
rakeCommand() | |
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
def yield_if?(bool = false, value = nil) | |
yield(value) if bool && block_given? | |
bool | |
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
From 02edb2d2de470bec7bcdd030bb05ed7c7c967907 Mon Sep 17 00:00:00 2001 | |
From: Diego Scataglini <[email protected]> | |
Date: Wed, 24 Nov 2010 12:11:20 -0500 | |
Subject: [PATCH] gsub! should raise runtime error on frozen strings when block is given and match is found | |
--- | |
kernel/common/string.rb | 4 +++- | |
1 files changed, 3 insertions(+), 1 deletions(-) | |
diff --git a/kernel/common/string.rb b/kernel/common/string.rb |
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
gem install linecache | |
Building native extensions. This could take a while... | |
ERROR: Error installing linecache: | |
ERROR: Failed to build gem native extension. | |
/Users/developer/.rvm/rubies/rbx-head/bin/rbx extconf.rb | |
creating Makefile | |
make | |
gcc -I. -I/Users/developer/.rvm/rubies/rbx-head/include -I/Users/developer/.rvm/rubies/rbx-head/include -I. -fPIC -ggdb3 -O2 -fPIC -c trace_nums.c |
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
def font_size_matrix(default = 16) | |
puts "px\t%\t\s\sem" | |
(10..26).each do |n| | |
val = (n * 100) / default.to_f | |
puts "#{n}px\t%0.1f%%\t\s\s%0.3fem" % [val, val/100] | |
end | |
end | |
font_size_matrix |