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
#---- run this section just once ----# | |
export GOPATH="${HOME}/go" | |
export GO15VENDOREXPERIMENT='1' | |
` | |
cd $GOPATH/src/github.com/go-swagger/go-swagger | |
go get -u github.com/asaskevich/govalidator | |
go get -u github.com/naoina/denco | |
go get -u github.com/go-swagger/scan-repo-boundary/makeplans |
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
abstract class BaseResource(implicit protected val swagger: Swagger) | |
extends ScalatraServlet with FutureSupport with JacksonJsonSupport with SwaggerSupport with Imports { | |
override protected val applicationName = Some("messaging-api") | |
protected def applicationDescription = "Messaging Services API" | |
protected implicit val defaultTimeout = Timeout(5 seconds) | |
override val jsonpCallbackParameterNames: Iterable[String] = Some("callback") |
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 GOption { | |
def some[A](a: A): GOption[A] = new GOption[A] { | |
def cata[B](n: => B, s: A => B): B = sys.error("Implement me") | |
} | |
def none[A]: GOption[A] = new GOption[A] { | |
def cata[B](n: => B, s: A => B): B = sys.error("Implement me") | |
} | |
} | |
trait GOption[+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
implicit class PagePatternHelper(val sc: StringContext) extends AnyVal { | |
def page(args: Any*): PagePattern = { | |
val template = sc.standardInterpolator(treatEscapes, args) | |
val templateUrl = rl.Uri(template) | |
val path = templateUrl.path | |
val routeMatcher = new SinatraRouteMatcher(path) | |
val queryMultiParams = rl.MapQueryString.parseString(templateUrl.query.rawValue) | |
val queryParams = queryMultiParams.mapValues(_.head) |
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
#!/usr/bin/env sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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.controllers | |
import java.io.File | |
import java.io.PrintWriter | |
import java.io.StringWriter | |
import scala.collection.JavaConversions.mapAsScalaMap | |
import org.scalatra.ScalatraKernel.MultiParamsKey | |
import org.scalatra.ContentTypeInferrer | |
import org.scalatra.util.MultiMap | |
import org.scalatra.CookieSupport | |
import org.scalatra.RouteMatcher |
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 HttpMethod | |
object HttpPostMethod extends HttpMethod { override def toString = "POST" } | |
object HttpGetMethod extends HttpMethod { override def toString = "GET" } | |
object HttpDeleteMethod extends HttpMethod { override def toString = "DELETE" } | |
object HttpPutMethod extends HttpMethod { override def toString = "PUT" } | |
trait Param { | |
def name: String | |
def description: String |
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 Paginator[A]( | |
val adapter: Adapter[A], | |
val currentPage: Int = 1, | |
val maxPerPage: Int = 10 | |
) extends PaginatorLike[A] { | |
assert(maxPerPage > 0, "Max per page must be greater than zero") | |
assert(currentPage > 0, "Current page must be greater than zero") |
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
# Source accepts the protocol region:// with the host as the bucket | |
# access_key_id and secret_access_key are just that | |
# for the eu-west-1 region: | |
s3_file "/var/bulk/the_file.tar.gz" do | |
source "s3-eu-west-1://your.bucket/the_file.tar.gz" | |
access_key_id your_key | |
secret_access_key your_secret | |
owner "root" | |
group "root" |
NewerOlder