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 Foo(value: Int) | |
def somethingThatDependsOnFoo(someInt: Int): Foo => Int = (foo: Foo) => someInt*foo.value | |
val myFooFunction: Foo => Int = somethingThatDependsOnFoo(5) | |
val myFooFunctionResult: Int = myFooFunction(Foo(5)) |
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
implicit class SqlIdeFixer(val sc: StringContext) { | |
def sqlIde[A: Composite](args: A): SqlInterpolator#Builder[A] = { | |
val interpolator = doobie.syntax.string.SqlInterpolator(sc) | |
new interpolator.Builder(args) | |
} | |
} |
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
object string { | |
object SqlInterpolator { | |
class Builder[A: Composite](a: A, stackFrame: Option[StackTraceElement], rawSql: String) { | |
def query[O: Composite]: Query0[O] = Query[A, O](rawSql, stackFrame).toQuery0(a) | |
def update: Update0 = Update[A](rawSql, stackFrame).toUpdate0(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
class UserDao(implicit comp: Composite[User]) extends BaseDao[User]{ | |
val tableName = "users" | |
val columnNames: List[String] = "id" :: "email_address" :: "created_on" :: "modified_on" :: "deleted_on" :: Nil | |
def insert(document: User): Task[User] = | |
sql""" | |
insert into $tableName ( | |
id, | |
email_address, |
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
[info] Compiling 17 Scala sources to /media/sf_windows/Users/Jacob/Projects/virtual-receptionist-server/target/scala-2.11/classes... | |
[error] /media/sf_windows/Users/Jacob/Projects/virtual-receptionist-server/src/main/scala/com/jbarber/receptionist/web/RootWebService.scala:20: type mismatch; | |
[error] found : Object | |
[error] required: scalaz.concurrent.Task[org.http4s.Response] | |
[error] .flatMap(_.getOrElse(BadRequest("Failure for some reason. i dunno.") : Task[Response])) |
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
val visitorWebService = VisitorWebService() | |
val userWebService = UserWebService() | |
val service = | |
"visitors" / visitorWebService ~ | |
"users" / userWebService | |
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
implicit class stringExtensions(str: String) { | |
def /(service: HttpService): HttpService = { | |
val root = if(str.startsWith("/")) str else "/" + str | |
URITranslation.translateRoot(root)(service) | |
} | |
} | |
implicit class SymbolExtensions(sym: Symbol) { | |
def /(service: HttpService): HttpService = { | |
sym.name / service |
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 MessageArray(list: List[MessageFields]) | |
case class MessageFields(fields: Message) | |
case class MessageObject(message: Message) | |
case class Message(value: String); | |
import spray.json._ | |
import DefaultJsonProtocol._ | |
implicit val messageFormats = jsonFormat1(Message.apply) | |
implicit val messageObjectFormats = jsonFormat1(MessageObject.apply) |
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
class FooClass[T <: Entity](...) { | |
... | |
// Should these 3 methods be on a typeclass? They only exist because we can't call the .copy method on a generic type. | |
def addCreatedDateToDocument(document: T, date: DateTime): T | |
def addModifiedDateToDocument(document: T, date: DateTime): T | |
def addIdToDocument(document: T, id: String): T | |
} |
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
def collectSubAar(ps: Seq[ProjectRef]): Seq[AarLibrary] = ps flatMap { p => | |
val locals = Project.runTask(libraryProjects in(p, Android), st).collect { | |
case (_, Value(value)) => value | |
} | |
val aarlibs = locals.fold(Seq.empty[AarLibrary])(_ collect { | |
case a: AarLibrary => a | |
}) | |
val sub = Project.getProject(p, struct) | |
if(sub.isEmpty) aarlibs |