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 User < ActiveRecord::Base | |
| after_create :notify_user_created | |
| def notify_user_created | |
| # Things happen in here | |
| end | |
| handle_asynchronously :notify_user_created | |
| 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 'net/http' | |
| Net::HTTP.start("example.com") do |http| | |
| resp = http.get("/path/file.blah") | |
| open("file.blah", "wb") do |file| | |
| file.write(resp.body) | |
| 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
| // Show the event map | |
| var $map = $('.location-map'); | |
| if($map.length) { | |
| var approx_location = $map.attr('approx-location'); | |
| var approx_city = $map.attr('approx-city'); | |
| var location = new google.maps.LatLng( | |
| $map.data('latitude'), | |
| $map.data('longitude') | |
| ); |
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
| # Logs are saying: | |
| # | |
| # Cache read: geocoded/New York, NY | |
| # Cache fetch_hit: geocoded/New York, NY | |
| # Google Geocoding API error: over query limit. | |
| # | |
| # Seems to hit a match, then query google anway | |
| def self.geocode(address) | |
| location = Rails.cache.fetch("geocoded/#{address}") do |
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 UserSession < Authlogic::Session::Base | |
| validate :check_presence | |
| # Without the following method, calling persisted? on UserSession fails, | |
| # which is needed for polymorphic_url when called with a UserSession. | |
| def destroyed? | |
| false | |
| 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
| Gem::Specification.new do |s| | |
| s.files = 'lib/cold_shoulder.rb' | |
| 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 Message < ActiveRecord::Base | |
| validates :body, cold_shoulder: true | |
| 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
| twitter_regex = /(@[A-Za-z0-9_]{1,15})/i | |
| formatted_phone_regex = /((?:\+?(\d{1,3}))?[- (]*(\d{3})[- )]*(\d{3})[- ]*(\d{4})(?: *x(\d+))?\b)/i | |
| email_regex = /(\b[^\s]+?\s*(@|at)\s*[^\s]+?\.[^\s]+?\b)/i # Very general so as to catch BS |
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
| Gem::Specification.new do |s| | |
| s.files = `git ls-files`.split("\n") | |
| 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 CreateLocations < ActiveRecord::Migration | |
| def change | |
| create_table :locations do |t| | |
| t.string :address | |
| t.float :latitude | |
| t.float :longitude | |
| t.integer :located_id | |
| t.string :located_type | |
| t.timestamps |