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 DeferredGarbageCollection | |
| DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 15.0).to_f | |
| @@last_gc_run = Time.now | |
| def self.start | |
| GC.disable if DEFERRED_GC_THRESHOLD > 0 | |
| 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
| # Precompile all assets | |
| # config.assets.precompile = [ /\.coffee$/, /\.css\.scss\$/ ] | |
| config.assets.precompile += [ | |
| Proc.new{ |path| File.basename(path) =~ /^[^_][\w\.]+?\.(js|css)$/ }, | |
| ] |
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
| # ~/.tmuxinator/metrics.yml | |
| # you can make as many tabs as you wish... | |
| project_name: Metrics | |
| project_root: ~/Documents/Librato/metrics | |
| socket_name: metrics # Not needed. Remove to use default socket | |
| # rvm: 1.9.2@rails_project | |
| # pre: sudo /etc/rc.d/mysqld start | |
| pre: mysql.server start | |
| tabs: |
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
| Surround these with : e.g. :calling: | |
| +1 | |
| -1 | |
| bulb | |
| calling | |
| clap | |
| cop | |
| feet |
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 MissingRecordHandler | |
| extend ActiveSupport::Concern | |
| included do | |
| # Catch any RecordNotFound errors and route them appropriately | |
| # to the 404 handler. | |
| # | |
| # (see #record_not_found) | |
| # (see #render_404) | |
| rescue_from ActiveRecord::RecordNotFound, :with => :render_404 |
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 MissingRecordHandler | |
| extend ActiveSupport::Concern | |
| included do | |
| rescue_from ActiveRecord::RecordNotFound, :with => :render_404 | |
| end | |
| module InstanceMethods | |
| def record_not_found | |
| raise ActiveRecord::RecordNotFound |
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
| $(document).ajaxComplete(function(event, request) { | |
| var flash = $.parseJSON(request.getResponseHeader('X-Flash-Messages')); | |
| if (!flash) return; | |
| if (flash.notice) $('.notice').html(flash.notice); | |
| if (flash.error) alert(flash.error); | |
| } |
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 Socialite | |
| class User < ActiveRecord::Base | |
| has_many :facebook_identities, :dependent => :destroy | |
| has_many :twitter_identities, :dependent => :destroy | |
| def self.identity_associations | |
| @identity_associations ||= reflect_on_all_associations(:has_many).map(&:name).select {|n| n =~ /_identities$/} | |
| end | |
| # Create or update a user by identity |
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
| def render_404(exception = nil) | |
| if exception | |
| logger.info "Rendering 404 with exception: #{exception.message}" | |
| end | |
| respond_to do |format| | |
| format.html { render :file => "#{Rails.root}/public/404.html", :status => :not_found } | |
| format.xml { head :not_found } | |
| format.any { head :not_found } | |
| 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
| $.ajaxSetup({ | |
| cache: false, | |
| dataType: 'json' | |
| }); | |
| SC.RestDataSource = SC.DataSource.extend({ | |
| storagePrefix: null, | |
| pluralResourceName: function(recordType) { | |
| return recordType.pluralResourceName || SC.String.pluralize(recordType.resourceName); |