Skip to content

Instantly share code, notes, and snippets.

@viktorklang
viktorklang / CQRS_ES_Actor.scala
Created February 1, 2011 15:05
CQRS and EventSourcing using Akka Actors
import scala.collection.mutable.ListBuffer
import akka.actor.{Actor,ActorRef}
import akka.actor.Actor._
import akka.routing.{ Listeners, Listen }
//Represents a domain event
trait Event
//A builder to create domain entities
trait EntityBuilder[Entity] {
/**
* Creates a build properties file resource and packages it into the JAR,
* which can be read for various information such as version and build time.
* */
trait BuildPropertiesResource extends BasicScalaProject {
/**
* Specifies the name of the resource file. This is put [by default]
* in the top level directory of the jar.
* */
def buildPropertiesResourceFile = "build.properties"
@mtigas
mtigas / gist:952344
Last active August 27, 2025 05:41
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

@viktorklang
viktorklang / ScalaEnum.scala
Created June 30, 2011 23:12
DIY Scala Enums (with optional exhaustiveness checking)
trait Enum { //DIY enum type
import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia
type EnumVal <: Value //This is a type that needs to be found in the implementing class
private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values
//Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal
private final def addEnumVal(newVal: EnumVal): Int = { import _values.{get, compareAndSet => CAS}
val oldVec = get
@krasserm
krasserm / MonadTransformerExamples.scala
Created July 14, 2011 10:32
Scalaz 7 monad transformer examples
import scalaz._
import Scalaz._
object MonadTransformerExamples {
def main(args: Array[String]) = run
def run {
// ------------------------------------------------------
// Combined Option/Option
// ------------------------------------------------------
@chalmerj
chalmerj / gist:1492384
Created December 18, 2011 04:39
Init script for Graphite carbon-cache
#! /bin/sh
### BEGIN INIT INFO
# Provides: carbon-cache
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: carbon-cache init script
# Description: An init script for Graphite's carbon-cache daemon.
### END INIT INFO
@pvlugter
pvlugter / SalatBuild.scala
Created December 18, 2011 21:19 — forked from rktoomey/SalatBuild.scala
Salat build - attempting to configure sbtscalariform formatting preferences
object Format {
import com.typesafe.sbtscalariform.ScalariformPlugin
import ScalariformPlugin._
lazy val settings = scalariformSettings ++ Seq(
ScalariformKeys.preferences := formattingPreferences
)
lazy val formattingPreferences = {
import scalariform.formatter.preferences._
@evantahler
evantahler / gist:1574158
Last active June 3, 2016 22:28
Build Node on Phidget (ARMv4tl + emdebian)
@cedricwalter
cedricwalter / example
Created January 18, 2012 21:52
Nginx configuration for JIRA, TeamCity, Nexus or any other Tomcat web application
## Server configuration for nginx to host Atlassian Jira / Jetbrain TeamCity or any other Tomcat web application
#
# author cedric.walter, www.waltercedric.com
# to be saved for ex in /etc/nginx/sites-available/example
server {
listen 80;
server_name jira.example.com;
access_log off;
location / {
@raymondtay
raymondtay / gist:2289212
Created April 3, 2012 04:01
Interactive Input 2
import scala.util.continuations._
object AskMe {
def sleep(delay: Long) = shift[Unit,Int,Unit]{ k: (Unit => Int) =>
val runnable = new Runnable {
var leave = false
def run = {
while( ! leave ) {
Thread.sleep(delay)
val res = k()