add_column :table_name, :column_name, :decimal, default: 0, precision: 15, scale: 10
add_column :table_name, :column_name, :jsonb, default: {}, null: false
add_column :table_name, :column_name, :string, array: true, default: []
add_foreign_key :table_name, :table_name
add_foreign_key :table_name, :table_name, column: :column_name, name: :index_table_name_on_column_name
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
#!/bin/bash | |
convert() { | |
file=$1 | |
target=${file//.sass/.scss} | |
paths_with_file=$(echo $file | tr '/' "\n" | wc -l | tr -d ' ') | |
paths_number=$(($paths_with_file - 4)) # app assets stylesheets ... filename.sass |
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
gem install mysql2 -- --with-mysql-lib=$(brew --prefix)/Cellar/mysql/5.7.35/lib/ --with-mysql-dir=$(brew --prefix)/Cellar/mysql/5.7.35/ --with-mysql-config=$(brew --prefix)/Cellar/mysql/5.7.35/bin/mysql_config --with-mysql-include=$(brew --prefix)/Cellar/mysql/5.7.35/include/ |
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
def country_code_to_flag(country_code) | |
code = country_code.to_s.upcase | |
return unless code =~ /\A[A-Z]{2}\z/ | |
code.codepoints.map { |codepoint| (codepoint + 127_397).chr(Encoding::UTF_8) }.join | |
end | |
country_code_to_flag("BR") | |
# => "🇧🇷" |
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
# frozen_string_literal: true | |
Rails.application.routes.draw do | |
if Rails.env.test? | |
namespace :test do | |
resource :session, only: :create | |
end | |
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
sudo chown -R $USER ~/.gnupg | |
sudo chmod 700 ~/.gnupg | |
sudo chmod 600 ~/.gnupg/* |
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
awk -F, 'NR > 1{ print "SET", $0, "true" }' large_data.csv | redis-cli -h redis.amazonaws.com -n 7 --pipe |
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
knife cookbook site share 'chef-unicorn' 'Web Servers' |
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
total_count = "SELECT COUNT(DISTINCT resource_id) FROM reviews WHERE resource_type = 'Article' AND scopeable_type is NULL" | |
distinct_count = "SELECT COUNT(1) FROM reviews WHERE resource_type = 'Article' AND scopeable_type is NULL" | |
Review.find_by_sql("#{distinct_count}").as_json | |
Review.find_by_sql("#{total_count}").as_json | |
Review.find_by_sql("SELECT (CAST(0 AS DECIMAL(17, 14)) / 0) count_avg").as_json |
NewerOlder