Skip to content

Instantly share code, notes, and snippets.

View a-suenami's full-sized avatar

Akira Suenami a-suenami

View GitHub Profile
@a-suenami
a-suenami / README.md
Last active September 17, 2019 06:24
カジュアルすえなみチャンス 開催概要
@a-suenami
a-suenami / check_constraint_sample.sql
Created July 29, 2019 08:21
チェック制約で文字列長を制限する
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);
-- 以下、すべてエラー
@a-suenami
a-suenami / .gitignore
Last active July 24, 2019 03:04
sorbet
sorbet/
@a-suenami
a-suenami / irbify.rb
Created July 2, 2019 13:09
Execute local ruby script on Heroku.
#!/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]
@a-suenami
a-suenami / sorbet_sample.rb
Last active June 30, 2019 03:51
Sorbet sample
# 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
@a-suenami
a-suenami / option.sh
Last active March 20, 2019 07:06
オプション引数解析テンプレート thx. http://dojineko.hateblo.jp/entry/2016/06/30/225113
#!/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.奢る
@a-suenami
a-suenami / product_mapper.rb
Last active March 13, 2019 11:03
インピーダンスを解決したいの会
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
@a-suenami
a-suenami / README.md
Last active June 13, 2022 07:46
Railsでエヴァンスのいう集約の概念を取り入れる方法(案)
@a-suenami
a-suenami / README.md
Last active November 19, 2018 14:01
すえなみチャンス忘年会 企画概要

きっかけ

こんな感じで雑に思いついた。

https://twitter.com/search?q=%E3%81%99%E3%81%88%E3%81%AA%E3%81%BF%E3%83%81%E3%83%A3%E3%83%B3%E3%82%B9%E5%BF%98%E5%B9%B4%E4%BC%9A&src=typd

やりたいこと

  • 語弊を恐れずに言うと、僕(a-suenami)が会いたい人が一同に集まって飲みながらいろいろ話せる場。
  • 僕のための会ということになるのでお金的なところはそこそこ何とかする気概はある。(人数次第では全奢りとかは厳しいけど)