Skip to content

Instantly share code, notes, and snippets.

@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: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 / 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 / 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 / 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 / .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 / Foo.scala
Created July 15, 2011 21:49
InYourCase: autogenerated scalaz.Lens'es for case classes
case class Foo(bar: Int)
val rhs = Apply(lensApply, lensGet :: lensSet :: Nil)
yields the correct
rhs: scalaz.Lens.apply[test.this.Foo, scala.this.Int](((t: test.this.Foo) => 3), ((t: test.this.Foo, m: scala.this.Int) => t.copy(m)))
val appliedLensType = TypeApply(REF(lensClass), REF(ccClazz) :: TypeTree(ccMember.symbol.tpe) :: Nil)
yields
appliedLensType: scalaz.this.Lens[test.this.Foo, scala.this.Int]
@gseitz
gseitz / ImplicitTimerDemo.scala
Created July 13, 2011 07:24 — forked from dcbriccetti/ImplicitTimerDemo.scala
Example of using implicit conversions to avoid creating anonymous inner classes
package sample
import java.util.{TimerTask, Timer}
/**
* Shows Java way of creating an anonymous inner class to supply the code for a TimerTask.
*/
object TimerDemo extends Application {
new Timer().schedule(new TimerTask {
def run() {
@gseitz
gseitz / oxbow.icls
Last active November 22, 2023 08:54 — forked from oxbowlakes/oxbow.xml
IntelliJ IDEA color scheme for Scala/Java
<scheme name="oxbow" version="142" parent_scheme="Default">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2023-11-22T09:52:13</property>
<property name="ide">idea</property>
<property name="ideVersion">2023.2.5.0.0</property>
<property name="modified">2023-11-22T09:52:19</property>
<property name="originalScheme">oxbow</property>
</metaInfo>
<option name="LINE_SPACING" value="1.2" />