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 Paperclip | |
| module ClassMethods | |
| def has_attached_file name, options = {} | |
| include InstanceMethods | |
| write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil? | |
| attachment_definitions[name] = {:validations => []}.merge(options) | |
| after_save :save_attached_files | |
| before_destroy :destroy_attached_files |
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 AWS | |
| module S3 | |
| class Bucket | |
| def copy_to(target) | |
| each do |obj| | |
| returning Base.put("/#{target}/#{obj.key}", { 'x-amz-copy-source' => "/#{name}/#{obj.key}", 'x-amz-metadata-directive' => 'COPY', 'Content-Length' => 0 }) do | |
| S3Object.acl(obj.key, target, S3Object.acl(obj.key, name)) | |
| 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
| ca = ClientApplication.create(:name => 'Test Consumer App', :url => 'http://consumerapp.local') | |
| consumer = OAuth::Consumer.new(ca.key, ca.secret, :site => 'http://localhost:3000') | |
| request_token = consumer.get_request_token | |
| `open #{request_token.authorize_url}` | |
| # after POSTing that form... | |
| db_request_token = RequestToken.last |
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
| ActiveRecord::Schema.define(:version => 20100824224246) do | |
| create_table "users", :force => true do |t| | |
| t.string "name" | |
| t.text "friend_list" | |
| t.datetime "created_at" | |
| t.datetime "updated_at" | |
| 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
| Rails.application.config.to_prepare do | |
| SubscriptionPlan.class_eval do | |
| scope :active, where(:active => true) | |
| scope :by_price, order(:amount) | |
| 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
| en: | |
| groceries: | |
| sample_data: [Eggs, Milk, Bread] |
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
| function displaySuccess(message) { | |
| $('body').scrollTo(); | |
| $('#success_message').remove(); | |
| $('#content').prepend(banner = $('<div class="ui-widget flash hidden" id="success_message"><div class="ui-state-corner-all ui-state-highlight"><p><span class="ui-icon ui-icon-info"></span>' + message + '</p></div></div>')); | |
| banner.slideDown('normal', function() { | |
| setTimeout(function() { banner.slideUp('slow'); }, 10000); | |
| }); | |
| } | |
| function formSubmit(data, status, xhr, form) { |
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
| Delayed::Worker.auto_scale = true | |
| if Rails.env.production? | |
| Delayed::Worker.auto_scale_manager = ENV['HEROKU_APP'] ? :heroku : :local | |
| else | |
| Delayed::Worker.auto_scale_manager = :local | |
| 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 QueryTracer < ActiveSupport::LogSubscriber | |
| ACCEPT = %r{^(app|config|lib)}.freeze | |
| FRAMES = 5 | |
| THRESHOLD = 300 # In ms | |
| def sql(event) | |
| return unless event.duration > THRESHOLD | |
| callers = Rails. | |
| backtrace_cleaner. |
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
| # Jekyll archive page generator with pagination. | |
| # | |
| # Based on the category generator from | |
| # http://recursive-design.com/projects/jekyll-plugins/, | |
| # which is copyright (c) 2010 Dave Perrett, | |
| # http://recursive-design.com/ and is licensed under the MIT | |
| # license (http://www.opensource.org/licenses/mit-license.php), and | |
| # on the pagination code from Jekyll itself. | |
| # | |
| # This code is copyright (c) 2011 Benjamin Curtis, and is licensed |