Skip to content

Instantly share code, notes, and snippets.

# nginx - web server
description "nginx web server"
author "Graham Edgecombe <[email protected]>"
start on runlevel [2345]
stop on runlevel [016]
expect fork
respawn
//Usage:
//override def pomPostProcess(node: Node): Node = mcPom(moduleConfigurations)(super.pomPostProcess(node))
trait McPom { self: DefaultProject =>
import scala.xml._
def mcPom(mcs: Set[ModuleConfiguration])(node: Node): Node = {
//make sure we have a trailing slash so we deduplicate URLs properly
def cleanUrl(url: String) = url match {
case null => ""
<% iterations.each do |iteration| %>
<h2 id='Sprint_<%= iteration.number %>' style='display:inline'>Sprint <%= iteration.number %></h2><i> - ends <%= iteration.finish.strftime("%Y-%m-%d") %></i><a href='#Sprint_<%= iteration.number %>' class='anchor'>&nbsp;&para;</a>
<ul>
<% iteration.stories.each do |story| %>
<li class='story'><h3 style='display:inline'><i>Story <%= story.id %> (<%= story.current_state %>)</i></h3>
<small class='taskCount'><i><%= " - #{story.tasks.size} tasks defined" if story.respond_to?(:tasks) %></i></small>
<p class='storyDescription'><span class="storyIngress"><%= story.name%></span><br><span class="storyRest" style="color:grey"></span></p>
<% end %>
</ul>
<% end %>
trait HandlerArgs {
def isInitial: Boolean
}
case object InitialArgs { val isInitial = true }
case object ContinuationArgs { val isInitial = false }
class Handler extends ((Request, HandlerArgs) => Response)
class Middleware extends (Handler => Handler)
import javax.servlet.annotation._
import grizzled.generator._
import scala.annotation._
import scala.util.Random
trait Request
case object Request extends Request
trait Handler extends (Request => Response)
@casualjim
casualjim / recipe.rb
Created October 5, 2011 09:37 — forked from rberger/recipe.rb
S3 File Resource for Chef
# 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"
@casualjim
casualjim / ScalatraServer.scala
Created October 24, 2011 21:33 — forked from rossabaker/ScalatraServer.scala
dsl proposal for embedded servers
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)
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")
@casualjim
casualjim / base.scala
Created November 30, 2011 23:19 — forked from robb1e/base.scala
Creating API docs for scalatra
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
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