Skip to content

Instantly share code, notes, and snippets.

View biesnecker's full-sized avatar

biesnecker

  • Orlando, FL
  • 21:44 (UTC -04:00)
View GitHub Profile
(import '(org.joda.time LocalDate))
(defn today [] (LocalDate.))
;; basic functions to increment or decrement a date
(defn inc-date [#^LocalDate ds] (.plusDays ds 1))
(defn dec-date [#^LocalDate ds] (.minusDays ds 1))
;; generate infinite streams of LocalDate objects starting with start-ds
(defn inc-date-stream [#^LocalDate start-ds] (iterate inc-date start-ds))
@biesnecker
biesnecker / simple-work-queue.clj
Created January 14, 2012 08:39
A very simple set of functions create a work queue with an arbitrary number of workers attached in Clojure
(ns nadsack.utils.queue
(:import (java.util.concurrent BlockingQueue LinkedBlockingQueue)))
(defn- generic-worker [worker-function #^BlockingQueue queue switch]
(future
(let [worker-id (.toString (java.util.UUID/randomUUID))]
(while (not (realized? switch))
(let [work-item (.take queue)]
(cond
@biesnecker
biesnecker / jetty.xml
Created August 17, 2011 23:18
Jetty configuration
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<!-- =============================================================== -->
<!-- Configure the Jetty Server -->
<!-- -->
<!-- Documentation of this file format can be found at: -->
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax -->
<!-- -->
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
@biesnecker
biesnecker / akka.conf
Created August 17, 2011 23:18
Akka configuration
####################
# Akka Config File #
####################
# This is the Akka config template to be used for spray SERVLET CONTAINER deployments
akka {
version = "1.1.3" # Akka version, checked against the runtime version of Akka.
# spray requires nothing but akka-actors, which are implicitly enabled
@biesnecker
biesnecker / ScalaJetty.scala
Created August 17, 2011 23:17
Main method
package com.biesnecker.scalajetty
import cc.spray._
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.xml.XmlConfiguration
import org.eclipse.jetty.webapp.WebAppContext
import java.io.File
object ScalaJetty {