Skip to content

Instantly share code, notes, and snippets.

@rabitarochan
rabitarochan / gist:1884467
Created February 22, 2012 11:49
SPI example #1
public interface IHello {
public String say();
}
public class JapaneseHello implements IHello {
public String say() {
reutrn "こんにちは";
}
}
@rabitarochan
rabitarochan / XmlFileSerializer.cs
Created April 30, 2012 23:44
任意のオブジェクトをXMLファイルにシリアライズするクラス
using System;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
using System.Reflection;
namespace Rabitarochan.Serializer
{
/// <summary>
/// オブジェクトをXMLファイルにシリアライズ/デシリアライズするクラス
@rabitarochan
rabitarochan / gist:2927368
Created June 14, 2012 00:30
implicitをまだ理解しきれてない
object Test {
implicit def int2String(x: Int): String = x.toString
}
// defined module Test
import Test._
val num = 123
@rabitarochan
rabitarochan / AddFunction.java
Created July 6, 2012 04:46
MongoDBにjavaドライバーから関数を登録する方法
package com.rabitarochan.mongodb;
import org.bson.types.Code;
import com.mongodb.BasicDBObject;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.mongodb.Mongo;
@rabitarochan
rabitarochan / gist:3179946
Created July 26, 2012 02:42
JavaFXをScala風にこんな感じで書けたらいいな。
pane: ActionPane {
prefHeight = 400.0
prefWidth = 600.0
children {
hbox: HBox {
alignment = "CENTER"
prefHeight = 50.0
prefWidth = 572.0
spacing = 20.0
children {
@rabitarochan
rabitarochan / Epic-customize.css
Created August 8, 2012 04:11
はてなブログのEpicに追加したCSS
#main {
width: 690px;
}
.date {
width: 660px;
position: static;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #DDD;
@rabitarochan
rabitarochan / sbt-create.bat
Created August 30, 2012 08:34
sbtでビルドするための最低限必要なファイルを作成するためのバッチ (Windows)
@echo off
if exist build.sbt (
echo [error] Project already exists.
exit /b 1
)
if not "%1" == "" (
set project_name=%1
@rabitarochan
rabitarochan / classmanifesttest.scala
Created August 31, 2012 14:31
ScalaのClassManifestについてハマった
// コンストラクタをプライベートにし、コンパニオンオブジェクト経由でのみ生成させる。
class ClassName[A] private (val clazz: Class[A]) {
// toString で、引数に指定されたクラスの名称を返す。
override def toString(): String = {
clazz.getName
}
}
object ClassName {
@rabitarochan
rabitarochan / gist:3722161
Created September 14, 2012 14:15
gist-slide-test
!SLIDE
# gist-slide を試してみよう!
!SLIDE
これで合ってるの??
@rabitarochan
rabitarochan / Parser.scala
Created October 31, 2012 15:08
処理が終わらないパーサー
import scala.util.parsing.combinator.RegexParsers
case class Indent(i: Int)
case class Text(s: String)
case class Line(i: Indent, t: Text)
object Parser extends RegexParsers {
def indent: Parser[Indent] = """^\s*""".r ^^ {in => Indent(in.length)}
def text: Parser[Text] = """[^\n\r]*""".r ^^ {s => Text(s)}