Skip to content

Instantly share code, notes, and snippets.

View yakamoto69's full-sized avatar

Kenji Iino yakamoto69

  • Tokyo, Japan
View GitHub Profile
@yakamoto69
yakamoto69 / Pager.scala
Created December 7, 2012 12:13
A Pager, Handles Sequential Data as a Link of Pages.
class Pager[A](seq: Sequential[A], chunkSize: Int) {
self =>
import Pager._
private val ls: GrowingList[Chunk[A]] = mkGrowingList(seq, chunkSize)
var pageNo: Int = _
def hasNext: Boolean = {
@yakamoto69
yakamoto69 / RepeatTask.scala
Created October 18, 2012 10:21
Execute the Same Task Many Times as Much as Possible
import com.twitter.concurrent.{NamedPoolThreadFactory, Broker}
import com.twitter.util.{ExecutorServiceFuturePool, FuturePool}
import java.util.concurrent.{Executors, TimeUnit}
import annotation.tailrec
object RepeatTask {
/**
* Executes the "task" many times as much as possible within given "repeatMilliSecs".
* The "task" must be thread safe, since it is called simultaneously.
@yakamoto69
yakamoto69 / EasyLock.scala
Created October 18, 2012 10:17
Lock, Condition wrapper
import actors.threadpool.locks.{Condition, ReentrantLock}
class EasyLock {
val lock = new ReentrantLock
def mkCondition(f: => Boolean): EasyCondition = {
new EasyCondition(lock.newCondition(), f)
}
def apply[A](f: => A): A = {
@yakamoto69
yakamoto69 / mobamas_jump.js
Created April 17, 2012 10:59
モバゲーIDを入力すると相手のモバマスTOPに移動するブックマークレット
javascript:var%20c=prompt("%E3%83%A2%E3%83%90%E3%82%B2%E3%83%BC%EF%BC%A9%EF%BC%A4");if(c)%20window.location.href="http://sp.pf.mbga.jp/12008305/?guid=ON&url=http%3A%2F%2F125.6.169.35%2Fidolmaster%2Fprofile%2Fshow%2F"+c+"%3Frnd%3D732740346";