def findMofu(id: Int): Future[CacheError | IOError | NotFound, Mofu] = ???
def createMofu(mofu: Mofu): Future[CacheError | IOError | DuplicateError, Mofu] = ???
val result = findMofu(5).recoverWith {
case NotFound =>
createMofu(Mofu(5)).recoverWith {
case DuplicateError => UnknownError
}
}
This file contains hidden or 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 MofuSpec extends WordSpec with GeneratorDrivenPropertyChecks { | |
def measure(seq: Seq[Int], heap: Heap[Int]): Unit = { | |
val h = seq.foldLeft(heap) { (h, x) => h.insert(x) } | |
val h2 = seq.foldLeft(h) { (h, x) => h.deleteMin() } | |
assert(h2.isEmpty) | |
} | |
"mofu" should { | |
"fumo" in { | |
val initial = 300000 |
- 僕はおくみん
- @okumin
This file contains hidden or 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
<?php | |
require_once "twitteroauth/twitteroauth/twitteroauth.php"; | |
$client = new TwitterOauth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); | |
$next_cursor = -1; | |
$target = ""; | |
$f = fopen("./hogehoge.txt", "w"); | |
while($next_cursor != 0) { | |
for($i = 0 ; $i < 5; $i++) { |
This file contains hidden or 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 -*- | |
class UnionFind: | |
def __init__(self): | |
self.refs = {} | |
def find(self, x): | |
if x in self.refs: | |
ref = self.find(self.refs[x]) | |
self.refs[x] = ref |
This file contains hidden or 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
<?php | |
/** | |
* Copyright (c) 2012 okumin, http://okumin.com/ | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files (the | |
* "Software"), to deal in the Software without restriction, including | |
* without limitation the rights to use, copy, modify, merge, publish, | |
* distribute, sublicense, and/or sell copies of the Software, and to |
NewerOlder