Skip to content

Instantly share code, notes, and snippets.

View eed3si9n's full-sized avatar

eugene yokota eed3si9n

View GitHub Profile
trait CanWhere[A] {
def apply(f: PartialFunction[A, A]): Selector[Node]
}
implicit val stringToCanWhere = new CanWhere[String] {
def apply(f: PartialFunction[String, String]) =
Selector({ case Elem(p, name, a, s, c) if f.isDefinedAt(name) => Elem(p, f(name), a, s, c) })
}
implicit val nodeToCanWhere = new CanWhere[Node] {
trait CanReadXML[A] {
def reads(seq: scala.xml.NodeSeq): Either[String, A]
}
trait Foo { def foo: Int }
trait Bar { def bar: Int }
object Def {
def fromXML[A: CanReadXML](seq: scala.xml.NodeSeq) =
implicitly[CanReadXML[A]].reads(seq)
<?xml version='1.0' encoding='UTF-8' ?>
<!-- Schema for the SOAP/1.1 encoding
Portions © 2001 DevelopMentor.
© 2001 W3C (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, Keio University). All Rights Reserved.
This document is governed by the W3C Software License [1] as described in the FAQ [2].
[1] http://www.w3.org/Consortium/Legal/copyright-software-19980720
[2] http://www.w3.org/Consortium/Legal/IPR-FAQ-20000620.html#DTD
test in Assembly := {}
jarName in PluginA := "foo.jar"
jarName in PluginB := "bar.jar"
Assembly.test := {} // equivalent of test in Assembly := {}
PluginA.jarName := "foo.jar" // equivalent of jarName in PluginA := "foo.jar"
@eed3si9n
eed3si9n / gist:1209955
Created September 11, 2011 18:52
sbt-scalaxb not working on sbt 0.11.0-RC0
[helloworld]$ sbt
[info] Loading project definition from /Users/eed3si9n/work/helloworld/project
[info] Updating {file:/Users/eed3si9n/work/helloworld/project/}default-0a9cf4...
[info] Done updating.
[error] java.lang.NoClassDefFoundError: scalaxb/compiler/Config
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? l
[info] Loading project definition from /Users/eed3si9n/work/helloworld/project
[info] Updating {file:/Users/eed3si9n/work/helloworld/project/}default-0a9cf4...
[debug] Other repositories:
@eed3si9n
eed3si9n / sbtobfuscate.scala
Created September 23, 2011 01:07
sample plugins for discussion
object FooPlugin extends sbt.Plugin {
val FooConfig = config("foo")
lazy val fooA = SettingKey[Int]("foo-a")
lazy val fooB = SettingKey[String]("foo-b")
lazy val fooC = SettingKey[(Int, String)]("foo-c")
lazy val fooD = SettingKey[(Int, String, String)]("foo-d")
lazy val fooJars = TaskKey[Classpath]("foo-jars")
lazy val fooSomething = TaskKey[Classpath]("foo-something")
// Generated by <a href="http://scalaxb.org/">scalaxb</a>.
package general
case class SingularBuiltInTypeTest(singularbuiltintypetestsequence1: general.SingularBuiltInTypeTestSequence1,
singularbuiltintypetestsequence2: general.SingularBuiltInTypeTestSequence2,
singularbuiltintypetestsequence3: general.SingularBuiltInTypeTestSequence3,
singularbuiltintypetestsequence4: general.SingularBuiltInTypeTestSequence4,
singularbuiltintypetestsequence5: general.SingularBuiltInTypeTestSequence5) {
lazy val string = singularbuiltintypetestsequence1.string
giter8-plugin> compile
[info] Compiling 2 Scala sources to /Users/eed3si9n/work/giter8/plugin/target/scala-2.9.1/sbt-0.11.0/classes...
[error] /Users/eed3si9n/work/giter8/plugin/src/main/scala/giterate-plugin.scala:8: not found: value ScriptedPlugin
[error] import ScriptedPlugin._
[error] ^
[error] one error found
[error] {file:/Users/eed3si9n/work/giter8/}giter8-plugin/compile:compile: Compilation failed
[error] Total time: 1 s, completed Oct 15, 2011 4:33:52 PM
@eed3si9n
eed3si9n / klistDep.scala
Created October 26, 2011 06:57
more than 9 settings
// tasks
scalaxbConfig in scalaxb <<= new Scoped.RichTaskableKeys((combinedPackageNames in scalaxb) :^:
(packageDir in scalaxb) :^:
(classPrefix in scalaxb) :^:
(paramPrefix in scalaxb) :^:
(wrapContents in scalaxb) :^:
(generateRuntime in scalaxb) :^:
(chunkSize in scalaxb) :^:
(protocolFileName in scalaxb) :^:
(protocolPackageName in scalaxb) :^:
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? last
[info] Loading project definition from /Users/eed3si9n/work/sbt-assembly/project
[debug] Running task... Cancelable: false, max worker threads: 8, check cycles: false
[info] Updating {file:/Users/eed3si9n/work/sbt-assembly/project/}default-635ec9...
[debug] Other repositories:
[debug] Default repositories:
[debug] URLRepository(typesafe-ivy-releases,sbt.Patterns@7291b9b0)
[debug] Raw(ProjectResolver(inter-project, mapped: ))
[debug] FileRepository(local,FileConfiguration(true,None),sbt.Patterns@40d1e07c)
[debug] public: http://repo1.maven.org/maven2/