- TODO
- A
- B
- C
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
BEGIN; | |
CREATE TABLE IF NOT EXISTS students ( | |
student_id SERIAL PRIMARY KEY, | |
first_name VARCHAR(30) NOT NULL, | |
last_name VARCHAR(30) NOT NULL, | |
birthday DATE NOT NULL, | |
gender CHAR(1), | |
created_at TIMESTAMP, | |
updated_at TIMESTAMP | |
); |
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
defmodule StateServer do | |
@transitions %{ | |
initial: %{ receive_order: :check_stock }, | |
check_stock: %{ purchase: :ready_for_snipment }, | |
ready_for_snipment: %{ snipment: :package_arrive }, | |
package_arrive: %{ initial: :initial } | |
} | |
def run do | |
spawn(fn -> server(:initial) 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
require 'benchmark' | |
list = (1..10000).to_a | |
Benchmark.bm(20) do |x| | |
x.report('for:') do | |
hash = {} | |
for n in list do | |
hash[n.to_s] = n * 2 | |
end | |
end |
JOINのみ
EXPLAIN ANALYZE SELECT
*
FROM
user_products AS up
JOIN
users AS u
ON
中間テーブルの情報。現在はインデックスはuser_product_idにのみ付与。
Table "public.user_products"
Column | Type | Collation | Nullable | Default
-----------------+---------+-----------+----------+--------------------------------------------------------
user_product_id | integer | | not null | nextval('user_products_user_product_id_seq'::regclass)
user_id | integer | | |
product_id | integer | | |
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
# ref: https://www.paweldabrowski.com/articles/rails-enum-under-the-hood | |
module Channel | |
def enum_channels(mappings) | |
mappings.each_pair do |name, values| | |
singleton_class.define_method("#{name}_hash") { values } | |
values.each_pair do |key, value| | |
define_method("#{key}?") { self.status == value } | |
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
/* プレイヤー情報 */ | |
CREATE TABLE IF NOT EXISTS players ( | |
player_id SERIAL PRIMARY KEY, | |
name VARCHAR(50) NOT NULL, | |
created_at TIMESTAMP NOT NULL, | |
updated_at TIMESTAMP NOT NULL, | |
name_changed_at TIMESTAMP NOT NULL, | |
last_loggined_at TIMESTAMP NOT NULL | |
); |
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
/* プレイヤー情報 */ | |
CREATE TABLE IF NOT EXISTS players ( | |
player_id SERIAL PRIMARY KEY, | |
name VARCHAR(50) NOT NULL, | |
created_at TIMESTAMP NOT NULL, | |
updated_at TIMESTAMP NOT NULL, | |
name_changed_at TIMESTAMP NOT NULL, | |
last_loggined_at TIMESTAMP NOT NULL | |
); |
NewerOlder