Skip to content

Instantly share code, notes, and snippets.

View terjesb's full-sized avatar

Terje Sten Bjerkseth terjesb

  • Outnordic
  • Norway
View GitHub Profile
;variants of the code from point #2 of:
; http://www.tbray.org/ongoing/When/200x/2009/12/01/Clojure-Theses
;original
(apply merge-with +
(pmap count-lines
(partition-all *batch-size*
(line-seq (reader filename)))))
import scala.xml.{Node, Elem, Group}
/**
* A path to a Node in a Node tree.
*/
sealed trait NodePath {
def depth: Int
}
object NodePath {
@citerus
citerus / main.clj
Created May 3, 2010 20:33
Clojure program for controlling build status lava lamps
; Copyright (c) 2010 Patrik Fredriksson
;
; Permission is hereby granted, free of charge, to any person obtaining a copy
; of this software and associated documentation files (the "Software"), to deal
; in the Software without restriction, including without limitation the rights
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the Software is
; furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice shall be included in
(ns bpsmannschott
(:import java.io.File)
(:import java.io.FileNotFoundException))
(defn as-file [s]
"Return whatever we have as a java.io.File object"
(cond (instance? File s) s ; already a file, return unchanged
(string? s) (File. s) ; return java.io.File for path s
:else (throw (FileNotFoundException. (str s)))))
trait AuthenticationSupport
        extends ScentrySupport[ApiUser]
                with FlashMapSupport
                with CookieSupport
                with Logging { self: ScalatraKernel =>
  before { scentry.authenticate('RememberMe) }
  override protected def registerAuthStrategies = {
    scentry.registerStrategy('UserPassword, app => new UserPasswordStrategy(app))
@ghostm
ghostm / MongoProtoUser.scala
Created November 11, 2010 05:53
MetaMegaProtoUser that uses Mongo
/*
Copyright 2012 Matthew Henderson
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@wrwills
wrwills / LensTest.scala
Created November 30, 2010 13:47
playing with some of the ideas from the Haskell fclabels library using the new Lens functionality in scalaz
import scalaz._
/**
* playing with some of the ideas from the Haskell fclabels library
* using the new Lens functionality in scalaz
*
* http://hackage.haskell.org/package/fclabels
*/
object LensTest {
@daggerrz
daggerrz / UnfilteredTodoServer.scala
Created December 15, 2010 00:52
SproutCore Todos backend in Unfiltered Scala
package com.todos
import net.liftweb.json.JsonAST._
import net.liftweb.json.JsonDSL._
/**
* Non-persistent Unfiltered implementation of the SproutCore back-end.
* See <a href="http://wiki.sproutcore.com/w/page/12413020/Todos%2006-Building%20the%20Backend">SproutCore docs</a>
*/
@MichelBartz
MichelBartz / Comments.php
Created January 30, 2011 21:07
Nested Comments using Redis. Rely on the Owlient Redis extension
<?php
/**
* A Nested Comments manager using Redis only
* @author Michel Bartz <michel.bartz@manwin.com>
* @date 01/28/2011
*/
class Comments
{
private $_redis;
@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] {