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 '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 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 '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 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
# 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 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
# 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 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 ApplicationHelper | |
def site_name | |
@@site_name ||= MyConfig['site_name'] | |
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
+--------------------------------------------------------+ | |
| 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 | |
NewerOlder