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 Middleware::CustomLogging | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) | |
| if debug_logging? | |
| Rails.logger.level = Logger::DEBUG | |
| 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 'memoize_until' |
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 install memoize_until | |
| > irb | |
| irb:> require 'memoize_until' | |
| irb:> MemoizeUntil.hour(:default) { | |
| irb:> $redis.get("APP_CONFIGS") | |
| irb:> } | |
| irb:> # memoizes(until the end of the day) and returns the result of #PerformSomeComplexOperation |
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 Memcache | |
| KEY_HASH = YAML.load_file(File.join(Rails.root, 'config', 'memcached_keys.yml')).symbolize_keys! | |
| def self.key(key, value) | |
| “#{KEY_HASH[key]}:#{value}” | |
| end | |
| def self.multi_key(key, value1, value2) | |
| “#{KEY_HASH[key]}:#{value1}:#{value2}” | |
| 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
| # irb | |
| SOME_CONSTANT = "SOME_CONSTANT" | |
| puts "#{SOME_CONSTANT}#{'abcd.freshservice.com'}" | |
| > "SOME_CONSTANT:abcd.freshservice.com" |
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
| # irb | |
| SOME_CONSTANT = "SOME_CONSTANT%{value}" | |
| puts SOME_CONSTANT % {value: "abcd.freshservice.com"} | |
| > "SOME_CONSTANT:abcd.freshservice.com" |
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::Base.logger = nil | |
| subject = "Benchmarking" | |
| description = "Benchmarking " * 1000 | |
| type = "Incident" | |
| email = "[email protected]" | |
| status = 2 | |
| source = 2 | |
| priority = 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
| default: &default | |
| adapter: mysql2 | |
| encoding: utf8mb4 | |
| pool: 5 | |
| development: | |
| <<: *default | |
| database: development | |
| test: |
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
| const redis = require('redis'); | |
| const redis_client = redis.createClient(); | |
| const MemoizeUntil = require('memoize_until').MemoizeUntil | |
| MemoizeUntil.init({ | |
| min: ['api_key'] | |
| }) | |
| MemoizeUntil.fetch('min', 'api_key', () => { |
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 MemoizeExtensions | |
| def memoize_methods(method_name, *params) | |
| @@hash ||= {} | |
| return @@hash[params] if @@hash[params] | |
| @@hash[params] = send(method_name, *params) | |
| end | |
| end | |
| class User < ActiveRecord::Base | |