This file contains 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 Colors | |
RED = 31 | |
GREEN = 32 | |
YELLOW = 33 | |
BLUE = 34 | |
end | |
class String | |
def colorize(color_code) | |
"\e[#{color_code}m#{self}\e[0m" |
This file contains 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
[sqlfluff] | |
dialect = clickhouse | |
templater = jinja | |
sql_file_exts = .sql,.sql.j2,.dml,.ddl | |
max_line_length = 140 | |
; exclude CO03 capitalisation.functions as sqlfluff does not have camelCase option used by ClickHouse. | |
; https://docs.sqlfluff.com/en/stable/rules.html#rule-CP03 | |
; exclude LT01 layout.spacing as it removes space alignment and adds space to `Nullable ()` call in some cases. |
This file contains 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 'benchmark' | |
def show_memory_consumption | |
puts `pmap #{Process.pid} | tail -n 1` | |
end | |
#GC.disable | |
result = Benchmark.measure do | |
200.times { |i| | |
"a"*100_000_000 |
This file contains 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 A | |
def foo | |
:a | |
end | |
end | |
module B | |
def foo | |
:b | |
end |
This file contains 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
git checkout master2 | |
# delete local master | |
git branch -D master | |
# rename master2 to master | |
git branch -m master2 master | |
# Push master with force option to overwrite existing remote branch. | |
git push --set-upstream -f origin master |
This file contains 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 Receipt | |
def initialize(user:) | |
@user = user | |
end | |
def payments | |
# Imagine you get payments like Payment.where(user: @user). So payments are actually retrieved, `get`. | |
[ | |
{name: 'Shoes', price: 5.2 }, | |
{name: 'Book', price: 3.5 } |
This file contains 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 TimeUtils | |
def self.wait_for(title: '', max_wait_time: 5, wait_interval: 0.1, | |
raise_timeout_error: false, | |
debug: false, | |
&block) | |
puts "Waiting for #{title}" if debug | |
waiting_time = 0 |
This file contains 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 'net/http' | |
# The simplified version of logger can be copypasted into Rails initializer. | |
module HttpLogger | |
def request(req, body = nil, &block) | |
start_time = Time.current | |
super.tap do |resp| | |
log_request(http: self, request: req, response: resp, start_time: start_time) rescue nil | |
end | |
end |
This file contains 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
CSV.open("tmp/records.csv", "wb") do |csv| | |
csv << ConnectRequest.attribute_names | |
ConnectRequest.where('created_at > ?', 2.day.ago).each do |record| | |
csv << record.attributes.values | |
end | |
end |
This file contains 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
<!-- Global site tag (gtag.js) - Google Analytics --> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag() { | |
dataLayer.push(arguments); | |
} | |
document.addEventListener('turbolinks:load', function (event) { | |
if (typeof gtag === 'function') { |
NewerOlder