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: | |
dry_validation: | |
errors: | |
rules: | |
data: | |
attributes: | |
phone_number: | |
invalid_format: 'is of invalid format' |
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
use std::sync::{Arc, Mutex}; | |
use std::thread; | |
use std::time::Duration; | |
fn main() { | |
let counter = Arc::new(Mutex::new(0)); | |
let counter2 = Arc::new(Mutex::new(0)); | |
let mut handles = vec![]; | |
for _ in 0..10 { |
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 ruby | |
# frozen_string_literal: true | |
# https://juanitofatas.com/series/sidekiq/rename | |
files = Dir.glob("app/workers/**/*.rb") | |
puts "Found #{files.count} files" | |
files.each do |file| | |
content = File.read(file) | |
if match = content.match(/class (\S+)Worker/) |
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
$find . -depth -name "*old.txt" -exec sh -c 'f="{}"; mv -- "$f" "${f%old.txt}new.csv"' \; |
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 ruby | |
# frozen_string_literal: true | |
files = Dir.glob("app/jobs/**/*.rb") | |
puts "Found #{files.count} files" | |
files.each do |file| | |
content = File.read(file).split("\n") | |
content.each_with_index do |line, index| | |
if match = line.match(/Worker/) |
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 ApplicationRecord < ActiveRecord::Base | |
self.abstract_class = true | |
class << self | |
# Start a new transaction with a statement timeout. | |
# The timeout is reset after the block is executed. Works even with pg_bouncer in transaction mode | |
# This is useful for queries that are expected to be slower than the default timeout | |
# timeout - the timeout in seconds | |
# Usage: | |
# with_statement_timeout(10) 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
# frozen_string_literal: true | |
ActiveSupport::Notifications.monotonic_subscribe("sql.active_record") do |_name, start, finish, _id, payload| | |
duration = (finish.to_f - start.to_f) * 1000 | |
# NOTE: duration is in milliseconds | |
if duration >= 500 | |
sql = payload[:sql].to_s.tr("\n", " ").squeeze(" ") | |
Rails.logger.info("Slow SQL: #{sql} (duration: #{duration.to_i}ms)") | |
end |
OlderNewer