This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object App | |
{ | |
def main(args : Array[String]){ | |
doMatch(args[0].toInt) | |
} | |
def doMatch( id : Int) = { | |
id match{ | |
// scala2.10では()つけないとコンパイルエラーなのであまりいけてない? | |
case Status.OK() => println("OK") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Wifi | |
SSID:LabWirelessFree | |
PASS:なし | |
Twitterハッシュタグ: #rpscala | |
飲食は可ですが、ごみは持ち帰りです。 | |
コンビニは、ラクーアの方へ坂おりる途中にローソンがあります。 | |
ランチは適当に各自行ってください。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def detectDriverNameFromUrl(url : String) : Option[String] = { | |
val splits = url.split(":") | |
if(splits.length < 2){ | |
return None | |
} | |
if(splits(0) != "jdbc"){ | |
return None | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.reflect.runtime.universe._ | |
import scala.reflect._ | |
object App{ | |
def main(args : Array[String]){ | |
val m = toMap(User("Kudo",2,false)) | |
println(m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
libraryDependencies := Seq("org.specs2" %% "specs2" % "1.11" % "test") // regardless of libraries | |
/* | |
This build.sbt works well in sbt 0.11.X. | |
But in sbt 0.12.X this build.sbt throws below Exception while compiling | |
> compile | |
[info] Compiling 1 Scala source to PROJECT_PATH\target\scala-2.9.2\classes... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.sql.{Savepoint, Connection} | |
import java.util.{Properties, Map} | |
import java.util.concurrent.Executor | |
class ConnectionWrapper(connection : Connection) extends Connection{ | |
def setReadOnly(v0 : Boolean) = connection.setReadOnly(v0) | |
def close() = connection.close() | |
def isValid(v0 : Int) = connection.isValid(v0) | |
def isReadOnly() = connection.isReadOnly() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.xml.Elem | |
import scala.xml.XML | |
/** | |
* From console. | |
* scala MavenToSBTDependencies _pom_file_ {sbt or scala} | |
*/ | |
object MavenToSBTDependencies{ | |
case class Dep(scala_? : Boolean, vals : List[String]){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
{{{ | |
def main(args : Array[String]) = { | |
val aMap = SimpleArgsParser.parse(args) | |
... | |
} | |
}}} | |
Parse command line args and convert to Map | |
For example | |
"scala hoge.scala -f fuga.txt --help -v" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cgi | |
import BaseHTTPServer,CGIHTTPServer | |
class MyHandler(CGIHTTPServer.CGIHTTPRequestHandler): | |
def printPath(self): | |
print "Path:",self.path | |
def printHeaders(self): | |
headers = self.headers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.io.Source | |
import java.io.{FileInputStream,FileOutputStream,InputStream,OutputStream,File} | |
import scala.xml.{XML,Elem} | |
// usage | |
// val fileAsText = "clannad.txt" loadText | |
// "air.txt" << "This text is written to file air.txt" | |
// | |
class FileObject( filePath : String) { |
NewerOlder