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
Family, | |
Please everyone take me off your lists of political emails. Most of them | |
are beyond common sense and incredibly insulting. I hate to have to ask | |
this of my family who I find smart and loving, but it's gone past the point | |
of just being able to simply delete or ignore. | |
Thank you. | |
Love you, | |
Jason Carpentier |
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
(1..100).each {|n| | |
if n % 3 === 0 && n % 5 === 0 | |
puts "FizzBuzz" | |
elsif n % 3 === 0 | |
puts "Fizz" | |
elsif n % 5 === 0 | |
puts "Buzz" | |
else | |
puts n | |
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
class Product < ActiveRecord::Base | |
validates_presence_of :price, :description, :votes | |
serialize :images | |
def self.new_from_url(url) | |
doc = Nokogiri(open(url)) | |
price = doc.search('h2').to_s[/\$(\d+)/].gsub('$',"") | |
title = doc.title | |
description = doc.search('#userbody').to_s.split('<!--')[0].gsub(%r{</?[^>]+?>},'').gsub(/\n/," ").strip |
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
count = 1 | |
while count < 100 | |
if count % 5 == 0 and count % 3 == 0 | |
puts "FizzBuzz" | |
elsif count % 5 == 0 | |
puts "Buzz" | |
elsif count % 3 == 0 | |
puts "Fizz" | |
else | |
puts count |
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
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb | |
# and made a lot more robust by me | |
# this implementation uses erb by default. if you want to use any other template mechanism | |
# then replace `erb` on line 13 and line 17 with `haml` or whatever | |
module Sinatra::Partials | |
def partial(template, *args) | |
template_array = template.to_s.split('/') | |
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}" | |
options = args.last.is_a?(Hash) ? args.pop : {} | |
options.merge!(:layout => false) |
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
if listing_count > 100 | |
listings = [] | |
limit = 100 | |
begin | |
listing_chunk = shop.get_shop_listings(username, :offset => listings.length, :limit => limit).results | |
listings += listing_chunk | |
end while listing_chunk.length >= limit | |
else |
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 Location < ActiveRecord::Base | |
attr_accessible :street_address, :city, :state, :zipcode, :price, :lat, :lng, :full_address | |
before_validation_on_create :geoleo | |
def geoleo | |
geo = Geokit::Geocoders::GoogleGeocoder.geocode(full_address) | |
errors.add(:full_address, "Could not Geocode address") if !geo.success | |
if geo.province == "Bexar" | |
self.street_address,self.city,self.state,self.county,self.lat, self.lng = geo.street_address,geo.city,geo.state,geo.province,geo.lat$ |