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
class LeapYear | |
LEAP_MSG = "%d is a leap year" | |
NOT_LEAP_MSG = "%d is not a leap year" | |
class << self | |
def leap?(n) | |
n % 400 == 0 || (n % 4 == 0 && n % 100 != 0) | |
end | |
def msg(n) |
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
SELECT | |
b.id, | |
b.brandname, | |
COUNT(*) | |
FROM | |
gamelist g | |
INNER JOIN brandlist b | |
ON g.brandname= b.id | |
GROUP BY | |
b.id |
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
SELECT | |
to_char(g.sellday, 'YYYY') "year", | |
g.sellday, | |
g.gamename, | |
g.median | |
FROM gamelist g | |
INNER JOIN ( | |
SELECT | |
to_char(g2.sellday, 'YYYY') "year", | |
MAX(g2.median) "median" |
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
SELECT | |
c.name, | |
COUNT(*) | |
FROM createrlist c | |
INNER JOIN shokushu s | |
ON c.id = s.creater | |
INNER JOIN gamelist g | |
ON g.id = s.game | |
INNER JOIN userreview_with_tag uwt | |
ON g.id = uwt.game |
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
SELECT | |
to_char(g.sellday, 'YYYY') "year", | |
SUM(CASE a.title WHEN 'Nscripter' THEN 1 ELSE 0 END) "Nscripter", | |
SUM(CASE a.title WHEN '吉里吉里' THEN 1 ELSE 0 END) "吉里吉里" | |
FROM attributelist a | |
INNER JOIN attributegroupsboolean ag | |
ON a.id = ag.attribute | |
INNER JOIN gamelist g | |
ON g.id = ag.game | |
WHERE |
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
SELECT | |
g.sellday, | |
g.gamename, | |
COUNT(u.game) "count" | |
FROM gamelist g | |
INNER JOIN userreview u | |
ON g.id = u.game | |
WHERE | |
g.sellday > to_date('2000', 'YYYY') | |
GROUP BY |
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
describe User do | |
let(:user) { FactoryGirl.create :user } | |
before { user.fizz_buzz! } | |
# 実行結果で副作用があるので、それのテスト | |
it { expect(user.name).to eq 'fizz_buzz' } | |
it { expect(user.age).to be_nil } | |
# has_many の関連先が消えている事の確認 | |
it { expect(user.friendships).to be_blank } | |
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
protocol ExternalAccount {} | |
extension ExternalAccount { | |
func save() { | |
print("PATCH http://api.external.com/user") | |
} | |
} | |
protocol DataBaseAccount {} | |
extension DataBaseAccount { | |
func save() { |
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
protocol StringConvertible {} | |
extension StringConvertible { | |
func toString() -> String { | |
return "StringConvertible: \(self)" | |
} | |
} | |
protocol StringType {} | |
extension StringType { | |
func toString() -> String { |
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
class User {} | |
protocol Twitter { | |
// var username: String { get } | |
} | |
extension Twitter { | |
var username: String { | |
get { return "tryswiftconf" } | |
} |