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
| 1 | |
| -------- | |
| val list = List("Scala", "http://scala-lang.org", "Java", "http://java.net/", "Haskell", "http://haskell.org/") | |
| list.zipWithIndex.partition(_._2 % 2 == 0).zip.map(a => a._1._1 -> a._2._1) | |
| 2 | |
| --------- | |
| val list = List(1,2,1,3,2,4,4,2,4,3) | |
| list.distinct |
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
| // ----------------- | |
| // #daimonscala 22 ハンズオン | |
| // ----------------- | |
| // 1. ListからMapをつくろう | |
| val list = List("Scala", "http://scala-lang.org", "Java", "http://java.net/", "Haskell", "http://haskell.org/") | |
| // Map(Scala -> http://scala-lang.org, Java -> http://java.net/, Haskell -> http://haskell.org/) |
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
| @GrabResolver(name='seratch_github_com_releases', root='http://seratch.github.com/mvn-repo/releases', m2Compatible='true') | |
| @Grab('com.github.seratch:httpilot:0.1') | |
| import httpilot.*; | |
| import java.util.*; | |
| formParams = new HashMap<String, Object>(); | |
| formParams.put("user", "seratch"); | |
| formParams.put("repo", "scalikesolr"); | |
| formParams.put("version", "3.5.0"); | |
| req = new Request("http://ls.implicit.ly/api/1/libraries"); |
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
| #!/bin/sh -x | |
| # --- KeyczarTool Script --- | |
| # @see http://code.google.com/p/keyczar/wiki/KeyczarTool | |
| wget http://keyczar.googlecode.com/files/KeyczarTool.jar | |
| java -jar ./KeyczarTool.jar create --location=. --purpose=crypt --name="$1" | |
| java -jar ./KeyczarTool.jar addkey --location=. --status=primary | |
| ls # 1 meta |
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
| // #nodejyuku | |
| var connect = require("connect"); | |
| // my first middleware | |
| var requestDumper = function() { | |
| return function(req, res, next) { | |
| console.log(req); | |
| next(); | |
| }; |
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
| organization := "net.seratch" | |
| name := "sandbox" | |
| version := "0.1" | |
| scalaVersion := "2.9.1" | |
| libraryDependencies ++= Seq( | |
| "junit" % "junit" % "4.9" withSources(), |
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
| @Grab('commons-codec:commons-codec:1.2') | |
| import org.apache.commons.codec.net.URLCodec; | |
| def input = URLDecoder.decode("http://www.google.co.jp/?q=URLEncoder%E3%81%AF%E3%81%A9%E3%82%8C%E3%81%8F%E3%82%89%E3%81%84%E9%81%85%E3%81%84%E3%81%AE%E3%81%8B%E3%80%81commons-codec%E3%81%A8%E6%AF%94%E8%BC%83%E3%81%97%E3%81%A6%E3%81%BF%E3%81%BE%E3%81%99", "UTF-8") | |
| int times = 1000000; | |
| class Stopwatch { | |
| Integer startTime = null | |
| Integer endTime = null |
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
| package tools; | |
| import static org.mockito.Matchers.*; | |
| /** | |
| * Problem: cannot compile the following code | |
| * | |
| * <pre> | |
| * import static org.hamcrest.Matchers.*; | |
| * import static org.mockito.Matchers.*; |
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 += "org.jsoup" % "jsoup" % "1.6.1" | |
| import org.jsoup._ | |
| import java.io._ | |
| import java.net.URL | |
| import collection.JavaConversions._ | |
| val url = "https://picasaweb.google.com/xxx" | |
| val dir = "downloaded" |
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
| val uriEscaped = args(0) | |
| def unescapeHexChars(char1: Char, char2: Char): Byte = { | |
| Integer.decode("0x" + char1 + char2).toByte | |
| } | |
| def unescape(str: List[Char]): List[Byte] = { | |
| str match { | |
| case '%' :: x1 :: x2 :: xs => unescapeHexChars(x1, x2) :: unescape(xs) | |
| case x :: xs => x.toByte :: unescape(xs) |