Skip to content

Instantly share code, notes, and snippets.

View YusukeKokubo's full-sized avatar

Yusuke Kokubo YusukeKokubo

View GitHub Profile
@YusukeKokubo
YusukeKokubo / Server.fs
Last active December 11, 2015 17:38
hello lemon (todo)
module Server
open Lemon
open System.Collections.Generic
let todolist = ResizeArray<string>()
let (|Int|_|) (str: string) =
match System.Int32.TryParse(str) with
| true, x -> Some x
@YusukeKokubo
YusukeKokubo / HelloAkka.scala
Created January 10, 2013 15:38
hello Akka on Scala 2.10.0
import akka.actor._
class HogeActor extends Actor {
def receive = {
case i:Int => println("Int=" + i)
case hoge:Hoge => println("your name is " + hoge.name)
case _ => sender ! "received something."
}
}
@YusukeKokubo
YusukeKokubo / gist:3747461
Created September 19, 2012 03:19
Operator ||| like as ||
class CondOp(val a: Boolean) {
def |||(b: => Boolean) = if (a) a else b
}
object Main {
def main(args: Array[String]) {
implicit def boolWrapper(cond: Boolean) = new CondOp(cond)
true ||| { println("hoge"); false }
false ||| { println("foo"); true}
@YusukeKokubo
YusukeKokubo / ConfiguableAsyncCallback.xtend
Created May 29, 2012 07:38
Github api via GWT with Xtend
package nyao.client
import com.google.gwt.user.client.rpc.AsyncCallback
class ConfigurableAsyncCallback<T> implements AsyncCallback<T> {
def static <T> AsyncCallback<T> onSuccess((T)=>void onSuccess) {
val x = new ConfigurableAsyncCallback<T>()
x.onSuccessDo(onSuccess)
return x
@YusukeKokubo
YusukeKokubo / Hello.gwt.xml
Created April 27, 2012 05:25
Hello GwtQuery
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="hello">
<inherits name="com.google.gwt.user.User" />
<inherits name='com.google.gwt.query.Query' />
<source path="client" />
<entry-point class="as.client.Hello"></entry-point>
</module>
@YusukeKokubo
YusukeKokubo / fizzbuzz.hs
Created April 19, 2012 08:46
FizzBuzz by Haskell
fizzbuzz :: Int -> [String]
fizzbuzz n = map fb [1..n]
where fb x
| x `mod` 15 == 0 = "fizzbuzz"
| x `mod` 5 == 0 = "buzz"
| x `mod` 3 == 0 = "fizz"
| otherwise = show x