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
if ENV["APPSIGNAL_PUSH_API_KEY"] | |
require "rake/task" | |
module Appsignal | |
module Integrations | |
module CustomRakeIntegration | |
EXCLUDED_RAKE_TASKS = [ | |
"timezone_environment", | |
"assets:clean", | |
"assets:precompile", |
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
# Useful when dealing with screenshots taken by Selenium | |
def selenium_driver | |
@_selenium_driver ||= begin | |
options = Selenium::WebDriver::Chrome::Options.new | |
options.add_argument('--headless') | |
options.add_argument('--no-sandbox') | |
options.add_argument('--disable-dev-shm-usage') | |
Selenium::WebDriver.for :chrome, options: options | |
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
## The base branch in this case is called `develop` | |
SimpleCov.start 'rails' do | |
add_group 'Policies', 'app/policies' | |
add_group 'Serializers', 'app/serializers' | |
add_group 'Services', 'app/services' | |
add_group 'This Branch' do |source_file| | |
`git diff --name-only develop`.split("\n").detect do |filename| | |
source_file.filename.ends_with?(filename) | |
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
curl -XPUT localhost:9201/_template/haraka_results -d ' | |
{ | |
"template" : "smtp-transaction-*", | |
"mappings" : { | |
"haraka" : { | |
"dynamic_templates" : [ | |
{ "fail_results" : { | |
"match" : "fail", | |
"mapping" : { | |
"type" : "string", "index" : "not_analyzed" |
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
# http://www.jkfill.com/2015/02/14/log-which-line-caused-a-query/ | |
module LogQuerySource | |
def debug(*args, &block) | |
return unless super | |
backtrace = Rails.backtrace_cleaner.clean caller | |
relevant_caller_line = backtrace.detect do |caller_line| | |
!caller_line.include?('/initializers/') | |
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
ping www.google.com | while read pong; do echo "$(date): $pong"; done |
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
SELECT * | |
FROM "measures" | |
INNER JOIN | |
(SELECT * | |
FROM | |
(SELECT * | |
FROM | |
(SELECT "measures".*, | |
(CASE WHEN ("measures"."validity_start_date" IS NULL) THEN base_regulations.validity_start_date ELSE measures.validity_start_date END) AS "effective_start_date", | |
(CASE WHEN ("measures"."validity_end_date" IS NULL) THEN base_regulations.effective_end_date ELSE measures.validity_end_date END) AS "effective_end_date" |
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 "ruby-prof" |
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
Benchmark.ips do |x| | |
x.config(time: 5, warmup: 5) | |
x.report("Option 1") do | |
"quota_order_number_origin_exclusions".classify | |
end | |
x.report("Option 2") do | |
"quota_order_number_origin_exclusions".gsub(/(^|_)(.)/) { $2.upcase }.gsub(/s$/, '') | |
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
# Ruby Optimizations | |
# Comparison: | |
# Array#[-1]: 8053888.8 i/s | |
# Array#last: 7388678.2 i/s - 1.09x slower | |
# Comparison: | |
# Array#length: 11394036.7 i/s | |
# Array#size: 11302701.1 i/s - 1.01x slower | |
# Array#count: 9194976.2 i/s - 1.24x slower | |
# Comparison: |
NewerOlder