Skip to content

Instantly share code, notes, and snippets.

@nraychaudhuri
nraychaudhuri / TypedAkkaActorRef.scala
Last active August 29, 2015 14:05
Typed Akka actor ref
//PLEASE NOTE: Typing actor refs are really hard problem(take a look at the discussions in Akka mailing list regarding this subject). This is no way a complete solution. This will only work if you know all the possible
//messages an actor can handle (that means no become/unbecome business).
package experiment
import akka.actor.{Props, ActorSystem, Actor, ActorRef}
case class TypedActorRef[A](actorRef: ActorRef) extends AnyVal {
def ![B](msg: B)(implicit ev: A <:< B, sender: ActorRef = Actor.noSender) = actorRef ! msg
}
@ryankennedy
ryankennedy / Audited.java
Created September 24, 2013 17:48
Example of adding audited REST endpoints to a Dropwizard service.
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Audited {
}
@marete
marete / http.go
Created November 10, 2012 20:24
In Go/Golang, authenticate all HTTP connections in one place (No code duplication)
package main
import "net/http"
import "io"
import "runtime"
import "log"
type authHandler func(http.ResponseWriter, *http.Request)
func allowed(r *http.Request) bool {
@xaviershay
xaviershay / LdapAuthenticator.java
Created July 24, 2012 03:27
LDAP Authentication for dropwizard
package com.squareup.alcatraz.auth;
import com.google.common.base.Optional;
import com.unboundid.ldap.sdk.Filter;
import com.unboundid.ldap.sdk.LDAPConnection;
import com.unboundid.ldap.sdk.LDAPException;
import com.unboundid.ldap.sdk.ResultCode;
import com.unboundid.ldap.sdk.SearchRequest;
import com.unboundid.ldap.sdk.SearchResult;
import com.unboundid.ldap.sdk.SearchResultEntry;