Skip to content

Instantly share code, notes, and snippets.

@gseitz
gseitz / Foo.scala
Created July 15, 2011 21:49
InYourCase: autogenerated scalaz.Lens'es for case classes
case class Foo(bar: Int)
@gseitz
gseitz / .sbt
Created July 22, 2011 19:01
Separate global plugins/settings folder per sbt version
## Note: the system property `sbt.global.base` was introduced in 0.10.1
## sbt-0.10.0 still uses the default global directory in ~/.sbt
gseitz@QBallz ~/.sbt % find . -name '*target*' -prune -o -print
.
./0.10.1
./0.10.1/plugins
./0.10.1/plugins/build.sbt
./0.10.1/plugins/project
@gseitz
gseitz / RetroLogger.scala
Created July 22, 2011 21:09
RetroLogger - Bringing old school log level commands to sbt-0.10.x
//
// RetroLogger
// A handy sbt-0.10.x plugin that allows you to set the log level like in the old days (aka sbt-0.7.x)
// "set logLevel := Level.Debug" ====> "debug"
//
// + put this file in ~/.sbt/plugins/
// + add "sbtPlugin := true" to ~/.sbt/plugins/build.sbt
import sbt._
import Keys._
@gseitz
gseitz / ShellPrompt.scala
Created July 23, 2011 15:58
SBT shell prompt respecting -Dsbt.nologformat
import sbt._
import Keys._
// source of the actual shell modification take from Daniel C. Sobral's gist:
// https://gist.github.com/996474
// prompt looks like:
// $PROJECTNAME:$GITBRANCH>
object ShellPrompt extends Plugin {
@gseitz
gseitz / myBuild.scala
Created July 23, 2011 19:20
Hook up a task to be invoked before publish-local
import sbt._
import Keys._
object MyBuild extends Build {
lazy val beforeDeploy = TaskKey[Unit]("before-deploy", "will be invoked before deploy")
val externalProcess = "echo $HOME"
override lazy val settings: Seq[Setting[_]] = Seq[Setting[_]](
@gseitz
gseitz / gist:1104166
Created July 25, 2011 13:50
package protected trait escaping its visibility scope in specs2
import org.specs2.mutable.Specification
import org.specs2.matcher.MatchResult
// protected[specs2] trait MatchResult[T] ...
class DummySpec extends Specification {
// Is MatchResult escaping its visibility scope here?
// vvvvvvvvvvv
def intSpec: MatchResult[Int] = 1 must be equalTo 1
@gseitz
gseitz / gist:1105498
Created July 25, 2011 23:10 — forked from dcbriccetti/gist:1105497
Trying to get war file name from SBT
import sbt._
import Keys._
import com.github.siasia.{WebPlugin=>WP}
object MyBuild extends Build {
val myTask = TaskKey[Unit]("my-task")
lazy val myProject = Project("webproject", file("."), settings =Defaults.defaultSettings ++
@gseitz
gseitz / gist:1106062
Created July 26, 2011 05:46
MatchResult escaping its 'package[specs2]' visibility scope
package example
import org.specs2.mutable.Specification
import org.specs2.matcher.MatchResult
class DummySpec extends Specification {
def intSpec: MatchResult[Int] = 1 must be equalTo 1
@gseitz
gseitz / MyClass.scala
Created July 26, 2011 06:19
Leaky protection
package test2
import test.MyTrait
class MyClass extends MyTrait
@gseitz
gseitz / notification.scala
Created August 29, 2011 23:06
Poor man's growl-like notification on windows
import java.awt.TrayIcon
import java.awt.SystemTray.{getSystemTray => tray}
import java.awt.Toolkit.{getDefaultToolkit => toolkit}
import java.net.URL
object Notification {
private lazy val scalaIcon = {
// of course we use the logo of our favorite language ;)
val img = toolkit.getImage(new URL("http://www.scala-lang.org/sites/default/files/favicon.gif"))
new TrayIcon(img)