Skip to content

Instantly share code, notes, and snippets.

View j5ik2o's full-sized avatar

Junichi Kato j5ik2o

View GitHub Profile
@xuwei-k
xuwei-k / not_tailrec.scala
Created June 26, 2012 16:32 — forked from j5ik2o/gist:2996293
リトライハンドラーの殴り書き
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 {
@gakuzzzz
gakuzzzz / gist:8d497609012863b3ea50
Last active January 12, 2021 12:50
Scalaz勉強会 主要な型クラスの紹介
@codesword
codesword / minikube.md
Last active October 31, 2019 21:27
Installing minikube using xhyve driver

###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
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) = {
// under construction ...
sealed trait BusinessDaySpec
case object WorkDay extends BusinessDaySpec
case object Holiday extends BusinessDaySpec
sealed trait MovieDaySpec
case object MovieDay extends MovieDaySpec
@seizans
seizans / persistent.md
Created December 10, 2012 15:21
Haskellで便利にデータ設計

Haskellで便利にデータ設計

概要

これは [Haskell Advent Calendar 2012][] の11日目の記事です。
Haskell でデータ設計を便利に行う発想・方法について書きました。
[persistent][] というライブラリを活用します。
Haskell を知らなくても読めます。
主な対象読者は [プログラミングHaskell][] か [すごいHaskellたのしく学ぼう!][] を読み、Haskell をより使いたい人です。

@maiha
maiha / gist:9f305fb909fd357eb467
Last active November 9, 2016 11:30
akka: killとstopとPoisonPillの違い
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
# -*- 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)
@yaakaito
yaakaito / compiled.js
Last active January 2, 2016 09:18
型とか微妙になってるけど多分こんなん
var BankAccount = (function () {
function BankAccount(balance) {
this.balance = balance;
}
BankAccount.prototype.increase = function (money) {
var a = _.clone(this);
a.balance += money;
return a;
};
@kyo-ago
kyo-ago / gist:8280903
Last active January 2, 2016 09:09
JavaScriptでDCI的なものを実装してみた例
// 銀行口座
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);