文字通り、カジュアルなすえなみチャンス。
こんな感じの意図。 https://twitter.com/a_suenami/status/1145912998902394880
こんな感じ。
文字通り、カジュアルなすえなみチャンス。
こんな感じの意図。 https://twitter.com/a_suenami/status/1145912998902394880
こんな感じ。
| CREATE TABLE check_constraint_sample (col_not_null VARCHAR(255) NOT NULL, col_nullable VARCHAR(255)); | |
| ALTER TABLE check_constraint_sample ADD CONSTRAINT constraint1 CHECK (LENGTH(col_not_null) > 0); | |
| ALTER TABLE check_constraint_sample ADD CONSTRAINT constraint2 CHECK (LENGTH(col_nullable) > 0); | |
| -- 正常終了する | |
| INSERT INTO check_constraint_sample (col_not_null, col_nullable) VALUES ('not null', 'not null'); | |
| INSERT INTO check_constraint_sample (col_not_null, col_nullable) VALUES ('not null', null); | |
| -- 以下、すべてエラー |
| sorbet/ |
| #!/usr/bin/env ruby | |
| # | |
| # Usage: | |
| # irbify.rb script.rb | heroku run rails console --app=my-app | |
| # | |
| # Why eval and not piping directly? Piping directly would run all lines even if previous line was an invalid statement. | |
| # | |
| script_name = ARGV[0] |
| # typed: strong | |
| class SorbetSample | |
| sig { params(array: T::Array[MyInteger]).void } | |
| def initialize(array) | |
| @array = T.let(array, T::Array[MyInteger]) | |
| end | |
| sig { returns(Integer) } | |
| def use_array_of_premitive_types |
| #!/bin/bash | |
| PROGNAME="$( basename $0 )" | |
| # Usage | |
| function usage() { | |
| cat << EOS >&2 | |
| Usage: ${PROGNAME} [-h,--hoge] [--fuga [VALUE]] [--piyo VALUE] | |
| A sample script of parsing on bash. |
| class Person # エンティティ | |
| attr_reader :name, :yakiniku_treatment_type | |
| def initialize(name, yakiniku_treatment_type, credit_card_number, cash_amount) | |
| @name = Person::Name.new(name) | |
| @yakiniku_treatment_type = Person::YakinikuTreatmentType.new(yakiniku_treatment_type) | |
| end | |
| def 焼肉を奢る | |
| @yakiniku_treatment_type.奢る |
| class ProductMapper | |
| def attributes | |
| [:id, :name, :price] | |
| end | |
| def self.map(relation, limit: nil) | |
| mapping_type = Struct.new(attributes) | |
| relation.limit(limit).pluck(attributes).map do |record| | |
| mapping_type.new(record) | |
| end |
MemberAggregate::Member をアレコレしてから store とかするのだるいので Command クラスにして、そこから直接 AR で副作用起こす感じ。こんな感じで雑に思いついた。