This file contains 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
(defun unhtml (start end) | |
(interactive "r") | |
(save-excursion | |
(save-restriction | |
(replace-string "&" "&" nil start end) | |
(replace-string "<" "<" nil start end) | |
(replace-string ">" ">" nil start end)))) | |
(defun html (start end) | |
(interactive "r") |
This file contains 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
lazy val hadoopHomePath = | |
Properties.envOrNone("HADOOP_HOME").map { file }.getOrElse(error("please set HADOOP_HOME")) | |
lazy val main = Project(groupName, file("."), | |
settings = defaultSettings ++ Seq( | |
unmanagedClasspath in Compile <<= (unmanagedClasspath in Compile, baseDirectory) map { | |
(cp, bd) => cp ++ Attributed.blankSeq(hadoopHomePath ** "*.jar" get) | |
} | |
) | |
) |
This file contains 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
// modified from http://d.hatena.ne.jp/alpha_neet/20110706/1309901375 | |
import processing.core._ | |
import processing.core.PConstants._ | |
trait Application extends PApplet { | |
def main(args: Array[String]) { | |
PApplet.runSketch(Array("title"), this) | |
} | |
} |
This file contains 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
scala> import maze._ | |
import maze._ | |
scala> val m = Mazes.load(new java.io.File("maze.txt")) | |
m: maze.Maze = maze.Maze@20ccb51 | |
scala> Mazes.encodeRunLength(m.solve.get) | |
res0: List[(maze.Direction.Value, Int)] = List((S,1), (E,10), (S,2), (W,31), (N,4), (E,2), (S,2), (E,2), (N,4), (E,7), (N,1)) |
This file contains 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
class FixedSizeQueue[A](limit: Int) extends scala.collection.mutable.Queue[A] { | |
override def +=(elem: A) = { | |
super.+=(elem) | |
while (size > limit) { dequeue } | |
this |
This file contains 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.sys.process._ | |
for (pom <- ("find . -name pom.xml" !!) split "\n") { | |
"mvn -f " + pom + " clean" run | |
} |
This file contains 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 com.fourseasonszoo.niboshi | |
import com.sun.syndication.io._ | |
import com.sun.syndication.feed.synd._ | |
import scala.collection.JavaConverters._ | |
import org.scala_tools.time.Imports._ | |
import scalax.io._ | |
import java.io.StringWriter | |
object Main extends App { |
This file contains 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 Levenshtein { | |
def calc(a: String, b: String): Int = { | |
val d = Array.ofDim[Int](a.size + 1, b.size + 1) | |
// initialization | |
for (i <- 0 to a.size) d(i)(0) = i | |
for (j <- 0 to b.size) d(0)(j) = j | |
for ( | |
i <- 1 to a.size; |
This file contains 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
while (true) { | |
readLine | |
println("start") | |
val start = System.currentTimeMillis | |
readLine | |
val end = System.currentTimeMillis | |
println("end") | |
println("%.1f".format( (end - start).toDouble / 1000)) | |
} |
This file contains 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
scala> val a = (1 to 100).grouped(10).map(_.iterator) | |
a: Iterator[Iterator[Int]] = non-empty iterator | |
scala> val b = Stream.continually{ print("#"); a.next }.take(10) | |
#b: scala.collection.immutable.Stream[Iterator[Int]] = Stream(non-empty iterator, ?) | |
scala> val c = b.iterator.flatten | |
c: Iterator[Int] = non-empty iterator | |
scala> c.foreach(print) |