Skip to content

Instantly share code, notes, and snippets.

Avatar

Junichi Kato j5ik2o

View GitHub Profile
@marmotte
marmotte / docker_run
Created Jun 13, 2014
dockerコンテナ起動時にコンテナに振り当てられたIPを取得する docker runのラッパー
View docker_run
#/bin/bash
echo $@
CONTAINER_ID=$(docker run $@)
docker inspect --format='{{.NetworkSettings.IPAddress}}' $CONTAINER_ID
@maoe
maoe / ViewPatterns.hs
Created Jun 21, 2010
How to use view patterns
View ViewPatterns.hs
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE ViewPatterns #-}
module ViewPatterns where
import Data.List
data EMail = EMail User Domain deriving Show
type User = String
type Domain = String
view :: String -> Maybe EMail
View gist:839320
import java.io.File
import sbt._
import de.element34.sbteclipsify._
class Project(info: ProjectInfo) extends ParentProject(info) with IdeaProject {
//lazy val mavenLocal = "Local Maven Repository" at "file://"+Path.userHome+"/.m2/repository"
lazy val geotoolsRepository = "Open Source Geospatial Foundation Repository" at "http://download.osgeo.org/webdav/geotools/"
lazy val javanetRepository = "Java.net Repository" at "http://download.java.net/maven/2"
lazy val iglootoolsRepository = "Iglootools Releases Repository" at "http://developers.sirika.com/maven2/releases/"
@xuwei-k
xuwei-k / gist:977994
Created May 18, 2011
ScalaのREPL上から、Web browser上で指定したソースコードのページ開くスクリプト
View gist:977994
object SourceCode{
val browser = """ "C:\Documents and Settings\scalaちゃん\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" """
val srcURL = "https://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_8_1_final/src//library/"
def apply(clazz:Class[_]){
val url = srcURL + clazz.getName.replace('.','/') + ".scala#L1"
@brunoborges
brunoborges / DSLWicket.scala
Created Jul 27, 2011
Scala DSL for Wicket
View DSLWicket.scala
package code.webapp
import scala.collection.JavaConversions.seqAsJavaList
import org.apache.wicket.behavior.AttributeAppender
import org.apache.wicket.datetime.markup.html.form.DateTextField
import org.apache.wicket.extensions.validation.validator.RfcCompliantEmailAddressValidator
import org.apache.wicket.markup.html.basic.{ MultiLineLabel, Label }
import org.apache.wicket.markup.html.form.{ TextField, TextArea, SubmitLink, RadioGroup, Radio, PasswordTextField, FormComponent, Form, DropDownChoice, CheckGroup, Button }
import org.apache.wicket.markup.html.link.{ Link, BookmarkablePageLink }
import org.apache.wicket.markup.html.link.ExternalLink
@xuwei-k
xuwei-k / README.md
Created Oct 22, 2011
Scala dependent method types ?
View README.md

Scala dependent method types ?

ついに、ねんがんのでぃぺんでんとめそっどたいぷをてにいれたぞ

新しく 2.10 から(?) dependent method types っていう機能が Scala に入るらしいので、最新版をゴニョゴニョしてみた。 2.9.1で同じことやろうとすると def withFoo(foo: Foo): foo.Bar = foo.f という部分がコンパイル通らないはず。fooという 引数 の抽象型であるBarに依存した型だからっていう感じ?

しかし、機能の概念はなんとなくぼんやりと、把握はできたが、まだどういったときに役に立つのかわかっていない(・ω・`)

参考URLのメモ

@tyano
tyano / gist:1429205
Created Dec 4, 2011
List(1, 2, 3, 1) を Map(1 -> 2, 2 -> 1, 3 -> 1)
View gist:1429205
List(1,2,3,1).zip(List(1,1,1,1)).foldLeft(Map[Int,Int]()) { (x, y) => x.get(y._1) match { case Some(v) => x + Pair(y._1, (v + y._2)) case None => x + y }}
@makotan
makotan / gist:1476310
Created Dec 14, 2011
Either[L,Either[L,R]]のように多段になる場合にRだけを取得する
View gist:1476310
def eith[R](arg: Either[Throwable, Any] ) : R = {
arg match {
case Left(e) => throw e
case Right(o:Either[Throwable, Any]) => eith(o)
case Right(o:R) => o
}
}
@ogatatsu
ogatatsu / gist:1518754
Created Dec 25, 2011 — forked from j5ik2o/gist:1518723
こんな構文で階層型のログ出力をしたい
View gist:1518754
def connect = {
log("connect") { // connect start
// ... 何かの処理 ...
log("login") { // connect : login start
// ... 何かの処理 ...
} // connect : login end
// ... 何かの処理 ...
} // connect end
}
@j5ik2o
j5ik2o / rest.scala
Created Feb 24, 2012 — forked from stonegao/rest.scala
Basic RESTful service with Finagle
View rest.scala
class Respond extends Service[Request, Response] with Logger {
def apply(request: Request) = {
try {
request.method -> Path(request.path) match {
case GET -> Root / "todos" => Future.value {
val data = Todos.allAsJson
debug("data: %s" format data)
Responses.json(data, acceptsGzip(request))
}
case GET -> Root / "todos" / id => Future.value {
You can’t perform that action at this time.