Skip to content

Instantly share code, notes, and snippets.

View naokitanimura's full-sized avatar

Naoki Tanimura naokitanimura

View GitHub Profile
@naokitanimura
naokitanimura / Result.java
Created June 19, 2022 03:04
Result like Rust
package com.example;
public interface Result<T, E> {
public class Ok<T, E> implements Result {
private T t;
private Ok(T t) {
this.t = t;
}
@Override
class MemberType {
readonly typeClassName: string;
private constructor(
readonly key: string,
) {
this.typeClassName = this.constructor.name;
}
static readonly ADMIN = new MemberType("admin")
static readonly USER = new MemberType("user")
static getCodes(): MemberType[] {
@naokitanimura
naokitanimura / ts-enum-map.ts
Last active October 26, 2021 21:45
TypeScript enumでのマップ。
enum BarType {
TYPE_A,
TYPE_B,
TYPE_C
}
type FooFlags = {
[key in ApplyType]?: boolean;
};
@naokitanimura
naokitanimura / App.java
Last active January 8, 2018 15:25
name space mapping
package com.example.openadr;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.Locale;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
@naokitanimura
naokitanimura / gist:1183230
Created August 31, 2011 10:06 — forked from seratch/gist:1167860
S-99 P21-P28 blank
// *** S-99: Ninety-Nine Scala Problems ***
// http://aperiodic.net/phil/scala/s-99/
//
// wget http://www.scala-tools.org/repo-releases/org/scalatest/scal.test_2.9.0-1/1.6.1/scalatest_2.9.0-1-1.6.1.jar
// scala -cp scalatest-*.jar s99-21-28.scala
import org.scalatest.matchers.ShouldMatchers._
class NotImplementedYet extends RuntimeException
@naokitanimura
naokitanimura / gist:1168105
Created August 24, 2011 13:48 — forked from seratch/gist:1149214
S-99 blank
// *** S-99: Ninety-Nine Scala Problems ***
// http://aperiodic.net/phil/scala/s-99/
//
// wget http://www.scala-tools.org/repo-releases/org/scalatest/scalatest_2.9.0-1/1.6.1/scalatest_2.9.0-1-1.6.1.jar
// scala -cp scalatest-*.jar s99.scala
import org.scalatest.matchers.ShouldMatchers._
// P01: Find the last element of a list.
def last[T](list: List[T]): T = {
@naokitanimura
naokitanimura / gist:1168103
Created August 24, 2011 13:47 — forked from seratch/gist:1159315
S-99 P11-P20 blank
// *** S-99: Ninety-Nine Scala Problems ***
// http://aperiodic.net/phil/scala/s-99/
//
// wget http://www.scala-tools.org/repo-releases/org/scalatest/scalatest_2.9.0-1/1.6.1/scalatest_2.9.0-1-1.6.1.jar
// scala -cp scalatest-*.jar s99-11-20.scala
import org.scalatest.matchers.ShouldMatchers._
class NotImplementedYet extends RuntimeException
@naokitanimura
naokitanimura / gist:1109402
Created July 27, 2011 13:53 — forked from seratch/gist:1108560
Daimon.scala #8 やってみよう
import actors.Actor
class Get
case class IsUsed(station: Station)
case class MarkAsUsed(station: Station)
case class MarkAsUsedResponse(isMarkedAsUsed: Boolean)
case class Station(name: String)
class Yamanotesen extends Actor {
start()