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
SELECT COUNT(DISTINCT (CASE WHEN bundle_id IS NOT NULL THEN bundle_id END )) + COUNT(CASE WHEN bundle_id IS NULL THEN 1 END) | |
FROM purchase_ratings | |
WHERE created_at BETWEEN to_date('01/09/2018', 'DD/MM/YYYY') AND to_date('30/09/2018', 'DD/MM/YYYY') | |
Janeiro | |
39,688 | |
Fevereiro |
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
# Cria o objeto | |
object = { a: 1, b: 2 } | |
=> {:a=>1, :b=>2} | |
# Cria a referência | |
reference = object | |
=> {:a=>1, :b=>2} | |
# Deleta o objeto da referência | |
reference.delete(:a) |
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
-- show running queries (pre 9.2) | |
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(query_start, clock_timestamp()), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
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
mkdir ~/.go | |
echo "GOPATH=$HOME/.go" >> ~/.bashrc | |
echo "export GOPATH" >> ~/.bashrc | |
echo "PATH=\$PATH:\$GOPATH/bin # Add GOPATH/bin to PATH for scripting" >> ~/.bashrc | |
source ~/.bashrc |
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
ActiveRecord::Base.logger = Logger.new(STDOUT) |
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 branch --merged | grep -v \* | xargs git branch -D |
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
annotate --show-indexes --exclude tests,fixtures,factories,serializers --show-foreign-keys |
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 WithSelfClass | |
class << self | |
def my_function | |
"Presenter" | |
end | |
end | |
end | |
class MyClassWithSelfClass | |
extend WithSelfClass |
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
docker stop $(docker ps -a -q) | |
docker rm $(docker ps -a -q) | |
#Clear all volumes | |
docker volume rm $(docker volume ls -qf dangling=true) | |
# QQQQQQ | |
docker rm $(docker ps -q -f 'status=exited') | |
docker rmi $(docker images -q -f "dangling=true") |
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
ActiveRecord::Base.connection.tables.each do |table| | |
indexes = ActiveRecord::Base.connection.indexes(table) | |
if indexes.length > 0 | |
puts "====> #{table} <====" | |
indexes.each do |ind| | |
puts "----> #{ind.name}" | |
end | |
puts "====> #{table} <====" | |
2.times{ puts ''} | |
end |