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
+--------------------------------------------------------+ | |
| Name | Time (ms) | Requests/s | IO (KB/s) | Errors | | |
+--------------------------------------------------------+ | |
| baseline | 1310.3 | 0.8 | 3.9 | 14 | | |
+--------------------------------------------------------+ | |
+-----------------------------------------------------------------------------------------------------------------------------------------------+ | |
| % Baseline | Name | Time (ms) | Requests/s | IO (KB/s) | Errors | | |
+-----------------------------------------------------------------------------------------------------------------------------------------------+ | |
| 1.11929 | Using named scopes for late recommendations | 1466.6 | 0.7 | 3.5 | 14 | | |
| 1.17813 | Actually implementing named scopes for late recommendations into controller | 1543.7 | 0.6 | 3.8 | 14 | |
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 ApplicationHelper | |
def site_name | |
@@site_name ||= MyConfig['site_name'] | |
end | |
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
# In this model, we'll use a Markov chain to calculate probabilities associated with "Tweeting" | |
# A few code helpers for our exercise | |
class Float | |
def to_percentage | |
self*100 | |
end | |
end | |
# Now let's define our states |
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
# Part of the Dallas Ruby "A Year in Code" December 2010 meeting. | |
# http://groups.google.com/group/dallasrb/browse_thread/thread/1c114671b17dd81f | |
# Shame | |
# Yes it was committed. | |
# Yes I did come up with something better before it went to production. :) | |
<% 60.times do %> <% 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
require 'test/unit' | |
class PhoneNumberizeTest < Test::Unit::TestCase | |
# MM2: The one liner....and the one called by the tests | |
# yes it's ugly...I would probably not like to pick up someone else's code and see this ;) | |
def phone_numberize(number) | |
number.gsub(/#{/(\d{#{number.length-10}})/ if number.length>10}(\d{3})(\d{3})?(\d{1,4})/,"\\1-\\2-\\3-\\4").gsub("--","-").chomp("-") | |
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
require 'net/http' | |
require 'uri' | |
class LongUrl | |
attr_accessor :short_url | |
attr_reader :long_url | |
def initialize(short_url) | |
@short_url = short_url |
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 Fluidinfo | |
class SetOfStrings < Array; end | |
SERIALIZABLE_TYPES << SetOfStrings | |
end | |
# Use: strings = Fluidinfo::SetOfStrings["a", "b", "c"] |
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
# Scott and I came across some nested classes in some code we maintain. | |
# We then started talking about nested methods...and then started playing. | |
# After a couple of "Can you?" examples we asked the important "Why would you ever do this?" | |
# To be clear, I think nested methods are mostly evil (I think Scott agrees) | |
# Still, just maybe I can create a use case where using nested methods makes sense... | |
# The case below is something of a social manners exercise. | |
# Two instances call casual greeting methods (#hi) and interact in that way. | |
# However, when an instance calls a formal greeting method (#hello) all instances should elevate to formal methods |
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
# Part of the Dallas Ruby "Best and Worst of 2011" showcase at the December 2011 meeting | |
# http://groups.google.com/group/dallasrb/browse_thread/thread/998dd95dd4677042 | |
# Shame | |
@followings = current_profile.watch_events # NO LIMIT | |
# Fav | |
# Recursive Module Includes - yaml_dot_notation.rb |
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
class Rubyist | |
def check_me | |
puts "Rubyist" | |
end | |
end | |
class Chef | |
end |
OlderNewer