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
import cats.effect.{Effect, IO} | |
import cats.syntax.flatMap.toFlatMapOps | |
import cats.syntax.functor.toFunctorOps | |
import fs2.StreamApp.ExitCode | |
import fs2.{Pipe, Scheduler, Stream, StreamApp} | |
import io.circe.Json | |
import io.circe.jawn.CirceSupportParser | |
import jawn.Facade | |
import jawnfs2._ | |
import org.http4s.client.Client |
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
import cats.data.Xor | |
import cats.syntax.all._ | |
import org.openjdk.jmh.annotations.{ Benchmark, Scope, State } | |
@State(Scope.Benchmark) | |
class EitherBench { | |
val ea: Either[String, Int] = Right(1) | |
val eb: Either[String, Int] = Right(2) | |
val ec: Either[String, Int] = Right(3) |
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 title: String | |
-@ val headline: String = title | |
-@ val body: String | |
script(src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js") | |
script(src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js") | |
!!! 5 | |
html(lang="en" ng-app) | |
head | |
title= title |
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
package com.matygo.validation | |
import com.matygo.validation.validators.Validator | |
import com.matygo.validation.validators.StringLengthValidatorFactory | |
class TestObject(val someString: String, var someString2: String) extends Validatable[TestObject] { | |
validates( | |
lengthOfString(_.someString, 1, 5), | |
lengthOfString(_.someString2, 1, 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
import org.scalatra._ | |
import org.scalatra.test.scalatest._ | |
import org.scalatest._ | |
import org.scalatest.matchers._ | |
class MatygoAuthenticationTest extends WordSpec with ScalatraSuite with ShouldMatchers { | |
trait MatygoAuthentication extends ScalatraFilter with CookieSupport { | |
def setCookie(cookieString: String, expiry: Int) = { |
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 setSession(user: User) = setCookie(generateSessionString(user), SessionValidity.inSeconds) | |
def setSession(userOption: Option[User]) = userOption.map(user => setCookie(generateSessionString(user), SessionValidity.inSeconds)) | |
def clearSession = cookies.delete("MatygoSession") | |
private def setCookie(cookieString: String, expiry: Int) = { | |
println("Setting cookie"); | |
try { | |
cookies.update("MatygoSession", params(cookieString))(CookieOptions(maxAge = expiry, path = "/")) |
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 Main { | |
def main(args: Array[String]) { | |
MySquerylScheme.initialize() | |
WebServer("src/main/webapp", Config.webServerPort) { server => | |
server.inContext("/api") { context => | |
context.mount("validate", new ValidateApp) | |
context.mount("channels", new MessageChannelApp) | |
context.mount("streams", new StreamsApp) |
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
trait HandlerArgs extends FiniteStateMachineActor { | |
def isInitial: Boolean | |
} | |
class Handler extends ((Request, HandlerArgs) => Response) | |
class Middleware extends (Handler => Handler) | |
object Server { |
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
trait HandlerArgs extends FiniteStateMachineActor { | |
def isInitial: Boolean | |
} | |
class Handler extends ((Request, HandlerArgs) => Response) | |
class Middleware extends (Handler => Handler) | |
object Server { |
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
package com.dailyLif | |
import org.scalatra._ | |
import scalate.ScalateSupport | |
import org.scalatra.scalate._ | |
class DailyLifUserFilter extends ScalatraFilter /* with DatabaseInit with DatabaseSessionSupport */ with CookieSupport with FlashMapSupport with ScalateSupport { | |
get("/user/login") { | |
contentType = "text/html" | |
templateEngine.layout("/WEB-INF/scalate/templates/login.ssp", Map("message" -> flash.getOrElse("message", ""))) |
NewerOlder