Skip to content

Instantly share code, notes, and snippets.

View seratch's full-sized avatar

Kazuhiro Sera seratch

View GitHub Profile
@seratch
seratch / gist:1079626
Created July 13, 2011 02:57
Apache Solr setup script
#!/bin/sh -x
# ------------------------
# Configuration
BASE_URL=http://ftp.kddilabs.jp/infosystems/apache/lucene/solr
VERSION=3.3.0
DEPLOY_DIR=/your/tomcatorlikethat/webapps
SOLR_WAR_NAME=solr
WORK_DIR=~/solr_update_work
BACKUP_DIR=~/solr_backup
@seratch
seratch / gist:1080390
Created July 13, 2011 14:26
JerseyTest example with Spring
/*
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
<version>${jersey.version}</version>
<scope>test</scope>
</dependency>
*/
package restful.server.resource;
@seratch
seratch / gist:1094823
Created July 20, 2011 11:50 — forked from akr4/gist:1094761
Scala 練習問題 #daimonscala
class StringSupport(s: String) {
def reverseOrder: String = s.toList.foldLeft(Nil: List[Char])((result, c) => c :: result).mkString
def reverseCase: String = s.toList.map {
case c if c.isUpper => c.toLower
case c if c.isLower => c.toUpper
case c => c
}.mkString
@seratch
seratch / gist:1096531
Created July 21, 2011 05:04
Eclipse marketplace API Error message
Query failed to complete
MarketplaceDiscoveryStrategy failed with an error
Cannot complete request to
http://marketplace.eclipse.org/api/p/search/apachesolr_search/JUnit?product=org.eclipse.epp.package.jee.product&os=win32&runtime.version=3.6.0.v20100505&client=org.eclipse.epp.mpc.core&java.version=1.6.0_24&product.version=1.3.2.20110218-0812&ws=win32: Element type "tag" must be followed by either attribute specifications, ">" or "/>".
Element type "tag" must be followed by either attribute specifications, ">" or "/>".
@seratch
seratch / gist:1108560
Created July 27, 2011 02:54
Daimon.scala #8 やってみよう
/**
* Daimon.scala #8 やってみよう
* http://d.hatena.ne.jp/seratch2/20110507/1304777166
* 以下のPlayer、Gameをそれぞれアクターとして定義して山手線ゲームをコメント例のように実行できるようにしてください。
*/
import actors.Actor
case object Get
case class IsUsed(station: Station)
@seratch
seratch / gist:1121858
Created August 3, 2011 03:42
Daimon.scala #9 やってみよう
/**
* Daimon.scala #9 やってみよう
* http://d.hatena.ne.jp/seratch2/20110802/1312305023
* scala -cp .:akka-actor-1.1.3.jar yamanote-akka.scala
* 実装例: https://gist.github.com/1121859
*/
import akka.actor.Actor
import akka.actor.ActorRef
import akka.actor.Actor._
@seratch
seratch / gist:1121859
Created August 3, 2011 03:42
Daimon.scala #9 やってみよう(実装例)
/**
* Daimon.scala #9 やってみよう
* http://d.hatena.ne.jp/seratch2/20110802/1312305023
* scala -cp .:akka-actor-1.1.3.jar yamanote-akka.scala
*/
import akka.actor.Actor
import akka.actor.ActorRef
import akka.actor.Actor._
@seratch
seratch / gist:1149214
Created August 16, 2011 14:27
S-99 blank
// *** S-99: Ninety-Nine Scala Problems ***
// http://aperiodic.net/phil/scala/s-99/
//
// wget http://www.scala-tools.org/repo-releases/org/scalatest/scalatest_2.9.0-1/1.6.1/scalatest_2.9.0-1-1.6.1.jar
// scala -cp scalatest-*.jar s99.scala
import org.scalatest.matchers.ShouldMatchers._
// P01: Find the last element of a list.
def last[T](list: List[T]): T = { // TODO }
@seratch
seratch / gist:1158602
Created August 20, 2011 03:19
Iterable#zip snippet
val ids = List(1,2,3,4,5)
val names = List("Andy", "Brian", "Kent", "Taro", "John")
ids zip names foreach {
case (id, name) => println("id:" + id + ",name:" + name)
}
// id:1,name:Andy
// id:2,name:Brian
// id:3,name:Kent
// id:4,name:Taro
// id:5,name:John
@seratch
seratch / gist:1159315
Created August 20, 2011 16:41
S-99 P11-P20 blank
// *** S-99: Ninety-Nine Scala Problems ***
// http://aperiodic.net/phil/scala/s-99/
//
// wget http://www.scala-tools.org/repo-releases/org/scalatest/scalatest_2.9.0-1/1.6.1/scalatest_2.9.0-1-1.6.1.jar
// scala -cp scalatest-*.jar s99-11-20.scala
import org.scalatest.matchers.ShouldMatchers._
class NotImplementedYet extends RuntimeException