Skip to content

Instantly share code, notes, and snippets.

@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.
@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 / 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 / .gitignore
Last active July 24, 2019 03:04
sorbet
sorbet/
@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 / README.md
Last active September 17, 2019 06:24
カジュアルすえなみチャンス 開催概要