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
| $ heroku pg:cachehit --remote production | |
| name | ratio | |
| ----------------+------------------------ | |
| index hit rate | 0.99929808820146663449 | |
| cache hit rate | 1.00 |
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 Dms | |
| def self.last_checked_at | |
| value = Setting.get('last_checked_at') | |
| Time.parse(value) if value | |
| end | |
| def self.checked! | |
| last_checked_at = Time.now.utc | |
| Setting.set('last_checked_at', last_checked_at) | |
| 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 Checking | |
| def run | |
| Rails.logger.info "Checking #{snitch.id} (#{snitch.name})..." | |
| unless checkable? | |
| Rails.logger.error "Snitch #{snitch.id} is not checkable" | |
| return false | |
| end | |
| ... more stuff | |
| 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
| # passes (from different app) | |
| it "should associate with a location with location_ids" do | |
| location = create(:location) | |
| vendor = create(:vendor, location_ids: [location.id]) | |
| vendor.reload | |
| vendor.locations.should include(location) | |
| end | |
| # fails |
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 RandyStore | |
| def initialize(options={}) | |
| @data = if options.is_a?(Redis) | |
| options | |
| else | |
| Redis.new options | |
| end | |
| end | |
| attr_reader :data |
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 DeleteResourceRoute | |
| def resources(*args, &block) | |
| super(*args) do | |
| yield if block_given? | |
| member do | |
| get :delete | |
| delete :delete, action: :destroy | |
| end | |
| 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
| 1.9.3p194 :003 > 0.0 / 0.0 | |
| => NaN |
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 ResizeioHelper | |
| def resizeio_image_tag(original, options={}) | |
| rio_options = extract_resizeio_options(options) | |
| image_tag resizeio_url(original, rio_options), options | |
| end | |
| def extract_resizeio_options(options) | |
| retina = !!options.delete(:retina) | |
| multiplier = retina ? 2 : 1 |
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 Dossi.Models.Photo extends Backbone.Model | |
| paramRoot: 'photo' | |
| preload: => | |
| tempImg = new Image() | |
| tempImg.src = @largeUrl() | |
| tempImg.src = @smallUrl() | |
| largeUrl: -> | |
| @resizeioURL({w: 64, h: 64, t: 'crop'}) |
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 ApplicationController < ActionController::Base | |
| protect_from_forgery | |
| before_filter do | |
| @categories = Rails.cache.fetch("global/categories", expires_in: 10.minutes) do | |
| Category.where("posts_count > 0").all | |
| end | |
| end | |
| end |