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 'yaml' | |
ads = YAML.load_file 'config/page_ads.yml' | |
class PageAds | |
attr :anchors | |
attr :positions | |
class Anchor |
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 Rails 3 ActiveSupport I believe | |
class StringInquirer < String | |
def method_missing(method_name, *arguments) | |
if method_name.to_s[-1,1] == "?" | |
self == method_name.to_s[0..-2] | |
else | |
super | |
end | |
end | |
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
require 'yaml' | |
# From Rails 3 ActiveSupport I believe | |
class StringInquirer < String | |
def method_missing(method_name, *arguments) | |
if method_name.to_s[-1,1] == "?" | |
self == method_name.to_s[0..-2] | |
else | |
super | |
end | |
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
class YohDawgDecorator | |
def initialize(subject) | |
subject.public_methods(false).each do |meth| | |
meth_name = "yoh_dog" + meth | |
(class << self; self; end).class_eval do | |
define_method meth_name do |*args| | |
subject.send meth, *args | |
end | |
end | |
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
#!/usr/bin/ruby -w | |
require 'benchmark' | |
require 'set' | |
array = (1..1_000_000).to_a | |
hash = {} | |
array.map {|x| hash[x] = nil} | |
a_set = array.to_set | |
Benchmark.bm(15) do |x| |
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
## | |
# Be lazy and restart your node.js app when you change things. | |
# Screenshot: http://img.skitch.com/20100606-mbi52g6knk3n83b6m3eqxr4pa4.png | |
# INSTALL: | |
# $ gem install watchr | |
# $ wget http://gist.github.com/raw/427720/2aae1f3b43a256f5ca07a603025d455aa92560e1/node_run | |
# $ cd YOUR_NODE_APP | |
# $ watchr node_runner.rb | |
# | |
# NOTES: |
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
asdf | |
asdf | |
asdf | |
asdf | |
asdf |
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
# Shows the difference in doing crazy stuff like extending an instance on a say... busy loop or lots of requests. | |
# | |
# [16:38][wmaldonado@wmaldonado0:]$ ruby test.local.extend.rb | |
# user system total real | |
# extend instance 23.150000 0.430000 23.580000 ( 23.777088) | |
# create a class 2.390000 0.810000 3.200000 ( 3.209350) | |
# | |
require 'benchmark' |
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
67 before_filter :ping | |
68 before_filter :reset_current_request | |
69 before_filter :initialize_current_page | |
70 before_filter :rpc_tracking_prefix | |
71 before_filter :update_content_cache | |
72 before_filter :update_config | |
73 before_filter :initialize_site | |
74 before_filter :initialize_ad_system | |
75 before_filter :update_content_cache | |
76 before_filter :initialize_rpc |
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
hgfhgfh |