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
dcs@shadowfax:~/github/example-sbt-project$ cat ~/bin/sbt | |
#!/bin/sh | |
if test -f ~/.sbtconfig; then | |
. ~/.sbtconfig | |
fi | |
#java -Xmx512M -noverify -javaagent:/home/dcs/ZeroTurnaround/JRebel/jrebel.jar -jar `dirname $0`/sbt-launch.jar "$@" | |
java \ | |
-XX:+CMSClassUnloadingEnabled -XX:+UseParallelGC -Xss1m -XX:MaxPermSize=512m -Xmx1536M \ | |
-jar `dirname $0`/sbt-launch.jar "$@" | |
# -Dhttp.auth.preference=ntlm -Dhttp.auth.ntlm.domain=domain \ |
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
// Try | |
def percentCompleted(total: Int, | |
done: Int): Int = | |
Try ( done * 100 / total ) getOrElse 100 | |
// Try/rescue/recover/andThen | |
Try { | |
new FileInputStream(a) |
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.collection.GenTraversableOnce | |
case class Numero(n: Int, s: String) | |
case class Xyzzy(lst: List[Int]) | |
case class Nested(nums: List[Numero], xyzzy: Xyzzy) | |
object Test extends App { | |
def serialize[T: TypeTag](obj: T): 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
// a.scala | |
// Fri Jun 29 16:15:08 PDT 2012 | |
import scala.reflect.makro.Context | |
import collection.mutable.ListBuffer | |
import collection.mutable.Stack | |
import language.experimental.macros | |
object Macros { | |
val conversionChars = "%BbCcdEefGgHhinosuXx" |
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
// This needs to be put inside an object, I think, but SIP13+SIP-15 is not working right now, so I couldn't test it | |
implicit class ForwardPipe[T](val obj: T) extends AnyVal { | |
def |> [U](f : T => U) = f(obj) | |
} |
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
Show hidden characters
{ | |
"cmd": ["sbt-no-color test"], | |
"file_regex": "^\\[error\\] ([.a-z_A-Z0-9/-]+[.]scala):([0-9]+):", | |
"selector": "source.scala", | |
"working_dir": "${project_path:${folder}}", | |
"shell": "true" | |
} |
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.sys.process._ | |
import scala.util.control.ControlThrowable | |
class ProcTrav(pb: ProcessBuilder) extends Traversable[String] { | |
var iterating: Boolean = _ | |
var exception: Option[Throwable] = _ | |
// This is required to stop the process, but since we are not doing that... | |
// var process: Process = _ // Need to synchronize access to this | |
def logger[U](f: String => U): String => Unit = (input: String) => if (iterating) try { f(input) } catch { |
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
shellPrompt <<= name(name => { state: State => | |
object devnull extends ProcessLogger { | |
def info(s: => String) {} | |
def error(s: => String) { } | |
def buffer[T](f: => T): T = f | |
} | |
val current = """\*\s+(\w+)""".r | |
def gitBranches = ("git branch --no-color" lines_! devnull mkString) | |
"%s:%s>" format ( | |
name, |
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 collection.mutable.ArrayBuffer | |
import collection.immutable.HashMap | |
object HashMapTest { | |
val random = new util.Random(1234) | |
def time(block: => Unit): Double = { | |
val start = System.nanoTime() | |
block |
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
dcs@ayanami:~/github/GenRegex (master)$ ~/scala-2.7.7.final/bin/scala -deprecation | |
Welcome to Scala version 2.7.7.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> List(1, 2, 3,) | |
<console>:1: warning: Trailing commas have been deprecated | |
List(1, 2, 3,) | |
^ | |
<console>:2: warning: Trailing commas have been deprecated |