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 / 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 <[email protected]>
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 / ApplicaitonDaemon.scala
Last active May 25, 2016 10:30
commons-daemonとAkkaでバッチアプリケーションの作成 ref: http://qiita.com/mather314/items/08e42057943e30aacb35
import org.apache.commons.daemon.{Daemon, DaemonContext}
class ApplicationDaemon(appName: String) extends Daemon {
private[this] val actorSystem = ActorSystem(appName)
override def init(context: DaemonContext) {}
override def destroy {}
override def start {
@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")
}
import akka.actor.{ExtendedActorSystem, Extension, ExtensionId}
class SampleExtentionImpl(system: ExtendedActorSystem) extends Extension {
val hoge = "HOGE"
}
object SampleExtension extends ExtensionId[SampleExtensionImpl] {
def createExtension(system: ExtendedActorSystem) = new SampleExtensionImpl(system)
}
@mather
mather / Dockerfile
Last active August 29, 2015 14:04
Scala REPL by Docker
FROM debian:latest
MAINTAINER mather <[email protected]>
RUN apt-get update
RUN apt-get autoremove -y
RUN apt-get install -y wget openjdk-7-jre
RUN wget http://downloads.typesafe.com/scala/2.11.1/scala-2.11.1.deb
RUN dpkg -i scala-2.11.1.deb
@mather
mather / file0.scala
Created July 29, 2014 02:46
IgnoreCaseなパーサコンビネータ ref: http://qiita.com/mather314/items/0535f237f007c13942dc
trait SampleParsers extends RegexParsers {
/** 文字列に".i"を付けると大文字小文字を区別せずマッチさせるようにする拡張 */
implicit class IgnoreCaseString(s: String) {
def i: Parser[String] = ("""(?i)\Q""" + s + """\E""").r
}
def keyword: Parser[String] = "keyword:".i
def value: Parser[String] = "[a-zA-Z0-9]+".r
def parameter: Parser[(String,String)] = keyword ~ value ^^ { case k~v => (k,v) }
}
@mather
mather / mandelbrot.scala
Last active August 29, 2015 14:04
http://justindomke.wordpress.com/2008/11/29/mandelbrot-in-scala/ のマンデルブロ集合を描画するプログラムのリファクタ
import java.io._
import java.lang.Math
import scala.annotation.tailrec
/**
* ref: http://justindomke.wordpress.com/2008/11/29/mandelbrot-in-scala/
*/
object mandelbrot {
// tiny complex number class including syntactic sugar for basic operations
@mather
mather / Hoge.scala
Last active February 25, 2016 04:08
import scala.reflect.ClassTag
object Hoge {
def main(args: Array[String]) = {
val s = new Hoge[StringSample]
val i = new Hoge[IntSample]
s.detectType(StringSample("hogehoge")) //=> detected!
s.detectType(IntSample(1))
i.detectType(StringSample("hogehoge"))
i.detectType(IntSample(2)) //=> detected!