Skip to content

Instantly share code, notes, and snippets.

View ahjohannessen's full-sized avatar

Alex Henning Johannessen ahjohannessen

View GitHub Profile
// In a StructureMap registry somewhere (for us, it's in CoreRegistry.cs)
For<IObjectConverter>().Use<DovetailObjectConverter>();
// In another file, we set up some of our conversions and conversion families
public class DovetailObjectConverter : ServiceEnabledObjectConverter
{
public DovetailObjectConverter(IServiceLocator locator)
: base(locator)
{
public class EntityModelBinder : IModelBinder
{
private static readonly TypeConverter _converter = TypeDescriptor.GetConverter(typeof (Guid));
public bool Matches(Type type)
{
return type.CanBeCastTo<DomainEntity>();
}
@ahjohannessen
ahjohannessen / Prelude.cs
Created July 17, 2011 22:01 — forked from anonymous/Prelude.cs
Oh, you poor, poor imperative developers...
/* Prelude.cs : What happens when a haskell programmer learns C#.
Copyright (c) 2011 Clark Gaebel
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:
@ahjohannessen
ahjohannessen / routing.js
Created October 21, 2011 02:49 — forked from jmarnold/routing.js
An old js dsl example
jBus.routing = new (function() {
function lazy(builder) {
this.builder = builder;
this.buildWith = function(func) {
this.builder = func;
};
this.value = function() {
return this.builder();
};
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] {
import akka.actor._
import akka.persistence._
object EventsourcingExample extends App {
class EventsourcedProcessor extends Processor {
var events: List[Any] = Nil
var awaitStack: List[Actor.Receive] = Nil
def receive = {
case Persistent(event, _) if recoveryRunning ⇒ update(event)
#don't send the nginx version number in error pages and Server header
server_tokens off;
# config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
# to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
#Download Elementary OS from here:
#http://sourceforge.net/projects/elementaryos/files/stable/
#First you update your system
sudo apt-get update && sudo apt-get dist-upgrade
#Clean-up System
sudo apt-get purge noise
sudo apt-get purge software-center
sudo apt-get purge scratch-text-editor
#!/bin/bash
# An alternative to "links", run this script after starting or stopping any
# container. It's a hack to update the host machine (vagrant) /etc/hosts with
# the current active docker containers and tell dnsmasq to refresh.
#
# Then start each machine with "-dns ${DOCKER_HOST_IP}", e.g.
# $ docker run -d -name mycontainer1 -dns 10.0.3.1 MYPRODUCT
# You can't seem to set the DNS during "docker build".
#
# Diagnostic command to run in host or while logged into containers:
$packages = [ 'curl', 'terminator', 'jdk7-openjdk', 'chromium', 'virtualbox', 'git', 'zsh', 'networkmanager', 'network-manager-applet', 'ttf-dejavu', 'arandr',
'openssh', 'nm-applet', 'xscreensaver', 'volwheel' ]
$yaourtPackages = [ 'vagrant', 'sublime-text', 'dropbox', 'oh-my-zsh-git', 'intellij-idea-13-community', 'kalu' ]
$services = [ 'NetworkManager' ]
$stoppedServices = [ 'netctl' ]
package { $packages: