Skip to content

Instantly share code, notes, and snippets.

View mather's full-sized avatar
🐻
friendly bear

Eisuke Kuwahata mather

🐻
friendly bear
View GitHub Profile
@mather
mather / Main.java
Created January 30, 2014 02:24
Scalaの列挙型をJavaから参照してみる ref: http://qiita.com/mather314/items/9c0e58578597e264c41d
public class Main {
public static void main(String[] args) {
// Signal class
System.out.println(Signal.class.toString());
// Signal$ class (Signal.type @ Scala)
System.out.println(Signal$.class.toString());
// Signal singleton object
Signal$ obj = Signal$.MODULE$;
@mather
mather / gist:8778065
Created February 3, 2014 02:27
Scalaで単体とコレクションを透過的に扱う
sealed abstract class MailList {
// コレクションとして扱うための抽象メソッド
def +(mailbox: Mailbox): MailList
// 別の型に変換するなどの処理
def publish: String = this match {
case Mailbox(str) => str
case MailboxList(list) => list.map(_.publish).mkString(",")
}
}
@mather
mather / file0.scala
Created February 5, 2014 05:48
Parser CombinatorでIPアドレスのチェック ref: http://qiita.com/mather314/items/dfa76148270f10bbad95
import java.net.{InetAddress,UnknownHostException}
import util.parsing.combinator.RegexParsers
object IpParsers extends RegexParsers {
def ipAddress: Parser[String] = """[0-9a-fA-F:\.]+""".r.withFilter { str =>
try {
val addr = InetAddress.getByName(str)
true
} catch {
case e: UnknownHostException => false
require 'formula'
class Jhcal < Formula
homepage 'http://www2.tokai.or.jp/y_okamon/myfreesoft/jhcal/jhcal.html'
url 'http://www2.tokai.or.jp/y_okamon/myfreesoft/jhcal/jhcal-2.0.tar.gz'
sha1 'ae09d530c3e89da8624245f95378a7991b597101'
def install
system "make"
bin.install "jhcal"
@mather
mather / A.java
Last active August 29, 2015 13:57
Scalaでは定数を含むインターフェースの継承クラスから定数を取得できない…
public interface A {
public static final String C = "hoge";
}
class MyException(message: String = null, cause: Throwable = null) extends RuntimeException(message, cause) {
def this(cause: Throwable) = this(Option(cause).map(_.toString).getOrElse(null), cause)
}
@mather
mather / file0.diff
Created April 7, 2014 04:00
Redmine2.5とredmine_redcarpet_formatterプラグインの衝突回避 ref: http://qiita.com/mather314/items/79e082bf4f9f9300c0a9
-gem "redcarpet"
+#gem "redcarpet"
@mather
mather / Dockerfile
Last active August 29, 2015 14:01
Dockerfile for Debian 7.4 with Chef
FROM debian:7.4
MAINTAINER mather <mather314@gmail.com>
RUN apt-get update
# SSH Server
RUN apt-get install -y openssh-server sudo
RUN mkdir /var/run/sshd
RUN echo 'root:root' | chpasswd
@mather
mather / fabfile.py
Created May 14, 2014 12:25
fabricのenvをyamlで定義する
# -*- coding: utf-8 -*-
from fabric.api import *
from yaml_loader import load_env_from_yaml
load_env_from_yaml('env.yaml', globals())
@mather
mather / Database.scala
Last active August 29, 2015 14:02
SlickでJDBCドライバを実行時に切り替えるメモ(ver. 2.x) ref: http://qiita.com/mather314/items/f3c1c465aa0b74f10236
trait DatabaseComponent { this: Profile =>
def database: profile.simple.Database
}
// テスト時
trait H2DatabaseComponent extends DatabaseComponent {
import profile.simple._
def database = Database.forURL("jdbc:h2:mem:test")
}