Skip to content

Instantly share code, notes, and snippets.

class House
PHRASES = [
"the horse and the hound and the horn that belonged to",
"the farmer sowing his corn that kept",
"the rooster that crowed in the morn that woke",
"the priest all shaven and shorn that married",
"the man all tattered and torn that kissed",
"the maiden all forlorn that milked",
"the cow with the crumpled horn that tossed",
"the dog that worried",
class Bottles
MAX_BOTTLE = 99
MIN_BOTTLE = 0
def song
verses(MAX_BOTTLE, MIN_BOTTLE)
end
def verses(high_bottle_number, low_bottle_number)
high_bottle_number.downto(low_bottle_number).map do |bottle_number|
@mpelzsherman
mpelzsherman / gist:c0896ae43a95b8572d7c
Created May 23, 2014 19:47
Random House using strategy pattern
class House
attr_accessor :os
def initialize(os=DefaultOrderingStrategy.new)
@os = os
end
def recite
(1..actors.length).map { |i| line(i) }.join("\n")
@mpelzsherman
mpelzsherman / gist:c7e27fb7459abb0d5652
Created May 23, 2014 19:49
HappyEndingOrderingStrategy
class HappyEndingOrderingStrategy
def order(array)
array[1..-1].shuffle << array.last
end
end
@mpelzsherman
mpelzsherman / traverse.rb
Created July 1, 2014 04:48
Exploring Tree Algorithms with Ruby
class Node
@@visits = 0
@@queue = []
attr_accessor :value, :left_child, :right_child, :visited
def self.count_visit
@@visits += 1
module Letters
class A
def to_s
"A"
end
end
end
describe Letters:A
subject { described_class.new }
@mpelzsherman
mpelzsherman / gist:7f47619e5c9d7e4d7787
Created November 30, 2015 14:25
ag mobile api performance metrics for including photos with SRP
WITH PHOTOS: siege -b -c10 -t1 "http://m.api.ci.apartmentguide.com/search?query=Atlanta,GA&include_photos=true"
=================
Transactions: 979 hits
Availability: 100.00 %
Elapsed time: 60.24 secs
Data transferred: 53.63 MB
Response time: 0.61 secs
Transaction rate: 16.25 trans/sec
Throughput: 0.89 MB/sec
Concurrency: 9.86
@mpelzsherman
mpelzsherman / gist:174e8bfdd758562414d0
Last active November 30, 2015 14:28
ag mobile api performance metrics for including photos with SRP
WITH PHOTOS: siege -b -c10 -t1 "http://m.api.ci.apartmentguide.com/search?query=Atlanta,GA&include_photos=true"
=================
Transactions: 979 hits
Availability: 100.00 %
Elapsed time: 60.24 secs
Data transferred: 53.63 MB
Response time: 0.61 secs
Transaction rate: 16.25 trans/sec
Throughput: 0.89 MB/sec
Concurrency: 9.86
@mpelzsherman
mpelzsherman / save_all_listings.html
Last active December 11, 2015 15:49
A bookmarklet for saving all listings on an AG search results page.
<a href="javascript:$('.icon_favorites .sprite').each(function() { $(this).click(); });">Save all listings</a>

Product management has come up with the idea of allowing website users to leave reviews and ratings for listings. This feedback will be entered similar to how leads are submitted, but the user must enter the following information:

  • name
  • email address
  • phone number
  • rating from 1 to 5
  • optional review

In addition to the above information, a CAPTCHA presenting three different apartment complexes (only one of which is correct) is used in conjunction with the user’s name and phone number to determine whether or not the user actually lived at the listing. After validating and verifying the information, the user gets redirected to a thank you page. After a review is successfully submitted, it will show up as the first entry in the reviews for the listing. Pre-existing “certified resident” reviews will be integrated along with reviews that are submitted through the site. On the search results page, users can sort on rating type or filter on review type and rating. A link on each listing will take the us