Skip to content

Instantly share code, notes, and snippets.

View terjesb's full-sized avatar

Terje Sten Bjerkseth terjesb

  • Outnordic
  • Norway
View GitHub Profile
@terjesb
terjesb / AkkaUnfilteredSample.scala
Created March 6, 2012 18:32 — forked from chrsan/AkkaUnfilteredSample.scala
Akka 2.0 unfiltered RESTful sample
package akka.unfiltered
import akka.actor._
import akka.dispatch.Future
import akka.pattern.ask
import akka.util.duration._
import akka.util.Timeout
import unfiltered.Async
import unfiltered.request._
@terjesb
terjesb / EC_KestrelClient.php
Created March 6, 2012 18:34 — forked from shupp/EC_KestrelClient.php
Kestrel Client Decorator
<?php
/**
* A thin kestrel client that wraps Memcached (libmemcached extension)
*
* @author Bill Shupp <hostmaster@shupp.org>
* @copyright 2010-2011 Empower Campaigns
*/
class EC_KestrelClient
{
/**
@terjesb
terjesb / EC_Producer.php
Created March 6, 2012 18:35 — forked from shupp/EC_Producer.php
Kestrel Producer
<?php
/**
* Interface for adding jobs to a queue server
*
* @author Bill Shupp <hostmaster@shupp.org>
* @copyright 2010-2011 Empower Campaigns
*/
class EC_Producer
{
/**
@terjesb
terjesb / consumer_cli.php
Created March 6, 2012 18:35 — forked from shupp/consumer_cli.php
CLI harness for EC_Consumer
#!/bin/env php
<?php
// External application bootstrapping
require_once __DIR__ . '/cli_init.php';
// Instantiate and run the consumer
$consumer = new EC_Consumer($argv);
$consumer->run();
@terjesb
terjesb / EC_Consumer.php
Created March 6, 2012 18:35 — forked from shupp/EC_Consumer.php
Kestrel Consumer
<?php
/**
* Enterprise queue consumer interface, called by bin/consumer_cli.php
*
* @author Bill Shupp <hostmaster@shupp.org>
* @copyright 2010-2011 Empower Campaigns
*/
class EC_Consumer
{
@terjesb
terjesb / gist:1988062
Created March 6, 2012 18:35 — forked from shupp/gist:960980
Example call to producer
<?php
$producer = new EC_Producer();
$producer->addJob('hello_world', 'HelloWorld', array('foo' => 'bar'));
?>
// https://github.com/scalaz/scalaz/blob/master/core/src/main/scala/scalaz/Lens.scala
case class Lens[A,B](get: A => B, set: (A,B) => A) {
def apply(a: A) = get(a)
// ...
}
@terjesb
terjesb / gist:2689144
Created May 13, 2012 16:18 — forked from phillro/gist:1126799
Easy Document Searching with Jquery, jquery-templates and Elastic Search
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<script id="searchResultTemplate" type="text/x-jquery-tmpl">
{{each(i,result) hits}}
@terjesb
terjesb / gist:2724077
Created May 18, 2012 08:57 — forked from swannodette/gist:2719676
unify_datums.clj
(ns datomic-play.core
(:use [datomic.api :only [db q] :as d])
(:require [clojure.core.logic :as l]
[clojure.pprint :as pp]))
(def uri "datomic:dev://localhost:4334/hello")
(defprotocol IUnifyWithDatum
(unify-with-datum [u v s]))
@terjesb
terjesb / restrict-map.clj
Created May 30, 2012 14:38 — forked from cgrand/restrict-map.clj
Restricting nested maps to keys of interest
;; I could have used a closed dispatch (aka cond) but you may find this version more enjoyable
;; the spec format is the one provided by BG
(defprotocol Selector
(-select [s m]))
(defn select [m selectors-coll]
(reduce conj {} (map #(-select % m) selectors-coll)))
(extend-protocol Selector