- 2014/07/13 Scalaz勉強会
- @gakuzzzz
- 中村 学
- 株式会社Tech to Value
- play2-auth が scala-awesomeに載りました
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
object RetryUtil { | |
case class RetryException(throwables: List[Throwable]) extends Exception | |
def retry[T](retryLimit: Int, retryInterval: Int, shouldCatch: Throwable => Boolean)(f: => T): T = { | |
// @annotation.tailrec | |
def _retry( errors: List[Throwable], f: => T):T = { | |
try { | |
f | |
} catch { |
###Install docker-machine-driver-xhyve docker-machine-driver-xhyve is a docker machine driver plugin for xhyve native OS X Hypervisor. xhyve is a lightweight OS X virtualization solution. In my opinion, it's a far better option than virtualbox for running minikube. ####Brew On MacOS sierra, download latest using
brew install docker-machine-driver-xhyve --HEAD
sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
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
def index(id:String) = Action { | |
getFirstData(id) | |
} | |
private def getFirstData(id:String) = { | |
Cache.get(id) match { | |
case Some(id2) => getSecondData(id2) | |
case None => NotFound | |
} | |
} | |
private def getSecondData(id2: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
// under construction ... | |
sealed trait BusinessDaySpec | |
case object WorkDay extends BusinessDaySpec | |
case object Holiday extends BusinessDaySpec | |
sealed trait MovieDaySpec | |
case object MovieDay extends MovieDaySpec |
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
stop: 現在処理中のメッセージを完了させる。それ以外のMailboxに溜まっているメッセージは処理しない | |
PoisonPill: メッセージの追加なので、投げた時点でたまっているメッセージが処理される (キュー消化+stop) | |
kill: ActorKilledExceptionが速攻出る(処理中の動作を破棄?)。その後はsupervisorのstrategyに依存(default:stop)。Mailboxはそのまま残る(restartしたactorが継続) | |
http://stackoverflow.com/questions/13847963/akka-kill-vs-stop-vs-poison-pill |
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
# -*- coding: utf-8 -*- | |
from itertools import repeat | |
foldr = lambda f, xs: reduce(lambda x, y: f(y, x), xs) | |
applyn = lambda f: lambda n, times: foldr(f, repeat(n, times)) | |
towerN = lambda n: pow if n == 1 else applyn(towerN(n - 1)) | |
tower1 = towerN(1) | |
tower2 = towerN(2) |
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
var BankAccount = (function () { | |
function BankAccount(balance) { | |
this.balance = balance; | |
} | |
BankAccount.prototype.increase = function (money) { | |
var a = _.clone(this); | |
a.balance += money; | |
return a; | |
}; |
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
// 銀行口座 | |
var BankAccount = function (balance) { this.balance = balance; }; | |
BankAccount.prototype.increase = function (money) { this.balance += money; }; | |
BankAccount.prototype.decrease = function (money) { this.balance -= money; }; | |
// ロール: 送信側 | |
var Sender = function () {}; | |
Sender.prototype.send = function (money, to) { | |
this.decrease(money); | |
to.onReceived(money, this); |