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
| # main logic | |
| def hi | |
| 'hi' | |
| end | |
| # rspec tests | |
| require 'rspec' | |
| describe "hi" do | |
| it "says 'hi'" 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
| module Concerns | |
| module Transactions | |
| extend ActiveSupport::Concern | |
| def transaction_begin | |
| ActiveRecord::Base.connection.begin_db_transaction | |
| ActiveRecord::Base.connection.increment_open_transactions | |
| render nothing: 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
| module Sidekiq | |
| module Middleware | |
| module Server | |
| class TaggedLogger | |
| def call(worker, item, queue) | |
| tag = "#{worker.class.to_s} #{SecureRandom.hex(12)}" | |
| ::Rails.logger.tagged(tag) do | |
| job_info = "Start at #{Time.now.to_default_s}: #{item.inspect}" | |
| ::Rails.logger.info(job_info) |
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
| #!/usr/bin/env bash | |
| if [ -n "$1" ]; | |
| then | |
| ssh_config=$(mktemp -t ssh_config) | |
| vagrant ssh-config > "$ssh_config" | |
| scp -F "$ssh_config" $@ | |
| else |
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
| server { | |
| listen 80; | |
| server_name [domain name]; | |
| root [Rails root]/public; | |
| location @passenger { | |
| passenger_enabled on; | |
| passenger_app_env production; | |
| } |
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 template_digest | |
| tmpl = lookup_context.find(action_name, _prefixes) | |
| ActionView::Digestor.digest(name: tmpl.virtual_path, finder: lookup_context) | |
| 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
| YourApp::Application.config.session_store.new(app).get_session({}, "session_store:fe95d1b2921ebf2eb7f18ece4f588520") |
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 ArCache | |
| extend ActiveSupport::Concern | |
| def get(path, headers = {}) | |
| cache_key = "ar_cache_#{path}" | |
| Rails.cache.fetch(cache_key, expires_in: 60.seconds) do | |
| super | |
| 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
| require "json" | |
| requests = {} | |
| File.open("production.log").each_line do |ln| | |
| if ln =~ /^\[([0-9a-f]+)\] (.+)/ | |
| id = $1 | |
| msg = $2 | |
| requests[id] ||= {lines: []} | |
| requests[id][:lines] << msg | |
| if msg =~ /Processing by (.+) as/ |
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
| # * Style guide based on Rails documention | |
| module Namespace #:nodoc: don't document this | |
| # Generic Namespace exception class | |
| class NamespaceError < StandardError | |
| end | |
| # Raised when... | |
| class SpecificError < NamespaceError | |
| end |