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
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 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 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 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 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 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 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 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 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
[repositories] | |
local | |
my-maven-repo: http://artifactory.ebc/artifactory/repo/ | |
my-ivy-artifacts: http://artifactory.ebc/artifactory/repo/, [organization]/[module]/[revision]/[type]s/[type].[ext], [organization]/[module]/[revision]/[type]s/[module].[ext] | |
my-ivy-classifiers: http://artifactory.ebc/artifactory/repo/, [organization]/[module]/[revision]/[type]s/[type].[ext], [organization]/[module]/[revision]/[type]s/[module]-[classifier].[ext] |
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
case class ListZipper[+A](lefts: List[A], x: A, rights: List[A]) { | |
def map[B](f: A => B): ListZipper[B] = | |
sys.error("todo") | |
// map with zipper context | |
def coFlatMap[B](f: ListZipper[A] => B): ListZipper[B] = | |
sys.error("todo") | |
def findRight(p: A => Boolean): Option[ListZipper[A]] = | |
sys.error("todo") |