Skip to content

Instantly share code, notes, and snippets.

View rktoomey's full-sized avatar

Rose Toomey rktoomey

View GitHub Profile
package com.novus.salat.test.model
import com.novus.salat._
import com.novus.salat.annotations._
import com.mongodb.casbah.Imports._
case class Bar(email: String)
case class Foo[X](jobId: String, bar: Bar, x: Set[X] = Set.empty) {
@Persist @Key("_id") val guid = jobId + bar.email
}
@rktoomey
rktoomey / SalatBuild.scala
Created December 18, 2011 19:17
Salat build - attempting to configure sbtscalariform formatting preferences
object Format {
import com.typesafe.sbtscalariform.ScalariformPlugin
import ScalariformPlugin._
lazy val settings = seq(scalariformSettings: _*) ++ Seq(
preferences = formattingPreferences
)
lazy val formattingPreferences = {
import scalariform.formatter.preferences._
@rktoomey
rktoomey / gist:1387338
Created November 22, 2011 23:04
how to update using SalatDAO
salat-core:master:0.0.8-SNAPSHOT> test:console
[info] Formatting 2 Scala sources {file:/home/rose/workspace/salat/}salat-core(test)...
[info] Compiling 2 Scala sources to /home/rose/workspace/salat/salat-core/target/scala-2.8.1.final/test-classes...
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.8.1.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> import com.novus.salat._
@rktoomey
rktoomey / gist:1313696
Created October 25, 2011 18:10
Clean build of salat 0.0.8-SNAPSHOT for 2.9.1
cleanbuild@marzipan:~$ ls -al
total 28
drwxr-xr-x 2 cleanbuild cleanbuild 4096 2011-11-08 10:47 .
drwxr-xr-x 5 root root 4096 2011-10-25 13:02 ..
-rw------- 1 cleanbuild cleanbuild 689 2011-11-08 10:47 .bash_history
-rw-r--r-- 1 cleanbuild cleanbuild 220 2011-10-25 13:02 .bash_logout
-rw-r--r-- 1 cleanbuild cleanbuild 3353 2011-10-25 13:02 .bashrc
-rw-r--r-- 1 cleanbuild cleanbuild 179 2011-10-25 13:02 examples.desktop
-rw-r--r-- 1 cleanbuild cleanbuild 797 2011-10-25 13:03 .profile
-rw-rw-r-- 1 cleanbuild cleanbuild 0 2011-10-25 13:15 .sbt.cache.lock
@rktoomey
rktoomey / gist:1313695
Created October 25, 2011 18:10
Clean build of salat 0.0.8-SNAPSHOT for 2.9.1
$ sudo su - cleanbuild
cleanbuild@marzipan:~$ ls -al
total 28
drwxr-xr-x 2 cleanbuild cleanbuild 4096 2011-10-25 13:10 .
drwxr-xr-x 5 root root 4096 2011-10-25 13:02 ..
-rw------- 1 cleanbuild cleanbuild 195 2011-10-25 13:10 .bash_history
-rw-r--r-- 1 cleanbuild cleanbuild 220 2011-10-25 13:02 .bash_logout
-rw-r--r-- 1 cleanbuild cleanbuild 3353 2011-10-25 13:02 .bashrc
-rw-r--r-- 1 cleanbuild cleanbuild 179 2011-10-25 13:02 examples.desktop
-rw-r--r-- 1 cleanbuild cleanbuild 797 2011-10-25 13:03 .profile
@rktoomey
rktoomey / BinaryTypeHintContext.scala
Created August 4, 2011 13:47
Binary "when necessary" type hinting with Salat
package com.novus.salat.test
import com.novus.salat.util.encoding.TypeHintEncoding
import com.novus.salat.{ TypeHintFrequency, BinaryTypeHintStrategy, Context }
package object when_necessary_binary_type_hint_encoding {
implicit val ctx = new Context {
val name = Some("WhenNecessary-BinaryTypeHint")
override val typeHintStrategy = BinaryTypeHintStrategy(when = TypeHintFrequency.WhenNecessary,
typeHint = "t",
@rktoomey
rktoomey / gist:1112062
Created July 28, 2011 17:35
Using xsbt 0.10.1 with salat
rose@calisson:~$ sudo su - cb
cb@calisson:~$ ls -al
total 36
drwxr-xr-x 2 cb cb 4096 2011-09-16 15:02 .
drwxr-xr-x 5 root root 4096 2011-01-27 09:07 ..
-rw------- 1 cb cb 2599 2011-09-16 15:02 .bash_history
-rw-r--r-- 1 cb cb 220 2010-08-10 16:47 .bash_logout
-rw-r--r-- 1 cb cb 3353 2010-08-10 16:47 .bashrc
-rw-r--r-- 1 cb cb 179 2010-09-15 07:41 examples.desktop
@rktoomey
rktoomey / gist:1107284
Created July 26, 2011 17:28
Clean build of casbah-salat-maven-example
cb@calisson:~$ ls -al
total 40
drwxr-xr-x 3 cb cb 4096 2011-07-26 13:22 .
drwxr-xr-x 5 root root 4096 2011-01-27 09:07 ..
-rw------- 1 cb cb 1824 2011-07-26 13:22 .bash_history
-rw-r--r-- 1 cb cb 220 2010-08-10 16:47 .bash_logout
-rw-r--r-- 1 cb cb 3353 2010-08-10 16:47 .bashrc
-rw-r--r-- 1 cb cb 179 2010-09-15 07:41 examples.desktop
-rw-r--r-- 1 cb cb 675 2010-08-10 16:47 .profile
drwxr-xr-x 10 cb cb 4096 2011-01-27 12:22 querulous-generic
@rktoomey
rktoomey / ScalaSigOrBust.scala
Created May 11, 2011 16:24
Trying to get ScalaSig for class in REPL
Welcome to Scala version 2.9.0.RC4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_24).
Type in expressions to have them evaluated.
Type :help for more information.
scala> case class Foo(x: String) {
| def distinctiveMethodName = "Hello"
| }
defined class Foo
scala> val clazz = classOf[Foo]
@rktoomey
rktoomey / gist:898115
Created April 1, 2011 13:09
Ways to look at a compiled Scala class
rose@marzipan:~/workspace/salat/target/scala_2.8.1/test-classes/com/novus/salat/test/model$ scalap -cp . "Maud"
package com.novus.salat.test.model
@scala.serializable
case class Maud(swept : scala.Predef.String, out : scala.Predef.String) extends java.lang.Object with scala.ScalaObject with scala.Product {
val swept : scala.Predef.String = { /* compiled code */ }
val out : scala.Predef.String = { /* compiled code */ }
@com.novus.salat.annotations.raw.Persist
val toSea : scala.Predef.String = { /* compiled code */ }
def copy(swept : scala.Predef.String, out : scala.Predef.String) : com.novus.salat.test.model.Maud = { /* compiled code */ }
override def hashCode() : scala.Int = { /* compiled code */ }