Skip to content

Instantly share code, notes, and snippets.

View j5ik2o's full-sized avatar

Junichi Kato j5ik2o

View GitHub Profile
@maoe
maoe / ViewPatterns.hs
Created June 21, 2010 23:12
How to use view patterns
{-# 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
@poutyface
poutyface / git
Created December 29, 2010 17:37
gitの使い方
githubへ登録
===========
git remote add origin [email protected]:<username>/<application_name>.git
git push origin master
初期設定
=======
git config --global user.name "Foo Bar"
git config --global user.email "[email protected]"
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 04:36
ScalaのREPL上から、Web browser上で指定したソースコードのページ開くスクリプト
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 July 27, 2011 15:22
Scala DSL for Wicket
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
@stonegao
stonegao / rest.scala
Created October 9, 2011 16:05 — forked from robi42/rest.scala
Basic RESTful service with Finagle
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 {
@xuwei-k
xuwei-k / README.md
Created October 22, 2011 18:31
Scala dependent method types ?

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 December 4, 2011 04:48
List(1, 2, 3, 1) を Map(1 -> 2, 2 -> 1, 3 -> 1)
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 December 14, 2011 11:59
Either[L,Either[L,R]]のように多段になる場合にRだけを取得する
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 December 25, 2011 05:10 — forked from j5ik2o/gist:1518723
こんな構文で階層型のログ出力をしたい
def connect = {
log("connect") { // connect start
// ... 何かの処理 ...
log("login") { // connect : login start
// ... 何かの処理 ...
} // connect : login end
// ... 何かの処理 ...
} // connect end
}