Skip to content

Instantly share code, notes, and snippets.

@mitoma
mitoma / gist:4139626
Created November 24, 2012 13:09
kaminari bug report. page メソッドを呼び出したとき、条件が欠落する場合がある。
# rails (3.2.8), kaminari (0.13.0)
# $> rails g model foo
# $> rails g model bar foo_id:integer
class Foo < ActiveRecord::Base
has_many :foo
end
class Bar < ActiveRecord::Base
@mitoma
mitoma / holiday.sh
Last active March 4, 2022 02:03
shellでGoogleカレンダーから祝日を判定するにはこういう風に判定するといい。jenkinsなどで祝日稼働したくないジョブがあるときに便利だと思う。
#!/bin/sh
# 独自で休日を定義する場合は独自で作ったGoogleカレンダーのIDを指定する
# ここで指定しているカレンダーは公開カレンダー「日本の休日」
CALENDAR_ID='ja.japanese%23holiday%40group.v.calendar.google.com'
# GoogleカレンダーのAPI KEYを設定する。
API_KEY='API KEY'
DATE=`date +%Y-%m-%d`
@mitoma
mitoma / yaritaikoto.org
Last active February 8, 2017 12:43
やりたいこと

やりたいこと

以下のように ControllerA から呼び出される場合と ControllerB で呼び出される場合で DbRepository と InMemoryRepository を呼び出しわけたい。(各Repositoryは共通のインターフェイスを実装している)

  • ControllerA#get() → ServiceX#doSomething() → DbRepository#findById()
  • ControllerB#get() → ServiceX#doSomething() → InMemoryRepository#findById()

知っているやり方(@Qualifier)

この場合はそれぞれ以下のようにすれば期待する動作になる。