Skip to content

Instantly share code, notes, and snippets.

View hekailiang's full-sized avatar
:octocat:
Focusing

Henry.He hekailiang

:octocat:
Focusing
View GitHub Profile
@hekailiang
hekailiang / osx-setup.md
Created May 2, 2017 11:17 — forked from zenorocha/.hyper.js
Setup macOS Sierra (10.12)

Setup macOS

I'm in a hospital in Spain and my MacBook was stolen.

Hospital Commit

Now I bought a new one and need to configure it. I have an AirPort Time Capsule that backs up everything using Time Machine, but I don't want all the crap I had in the old one. So let's get our hands dirty!

1. Update OS to latest version

Rough Notes about CQRS and ES

Once upon a time…

I once took notes (almost sentence by sentence with not much editing) about the architectural design concepts - Command and Query Responsibility Segregation (CQRS) and Event Sourcing (ES) - from a presentation of Greg Young and published it as a gist (with the times when a given sentence was heard).

I then found other summaries of the talk and the gist has since been growing up. See the revisions to know the changes and where they came from (aka the sources).

It seems inevitable to throw Domain Driven Design (DDD) in to the mix.

#!/bin/bash
sudo apt-get update
sudo apt-get -y install linux-image-extra-$(uname -r)
sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -"
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\ > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get -y install lxc-docker
@hekailiang
hekailiang / gist:bdcff9e17be240e3c0c0
Created February 11, 2015 02:32
TerminateOnDemandTest
package org.squirrelframework.foundation.fsm;
import org.junit.Test;
import org.squirrelframework.foundation.fsm.annotation.ContextInsensitive;
import org.squirrelframework.foundation.fsm.impl.AbstractStateMachine;
import static org.junit.Assert.assertEquals;
/**
* Created by kailianghe on 2/11/15.
import spray.routing.{AuthenticationFailedRejection, HttpService}
import akka.actor.{Props, ActorSystem, Actor, ActorRefFactory}
import spray.routing.authentication._
import scala.concurrent.Promise
import spray.routing.AuthenticationFailedRejection.CredentialsMissing
import akka.io.IO
import spray.can.Http
class MinifiedService extends Actor with HttpService {
val identity_cookie_name = "session_id"

Extremely bare example of Spray routing authentication using session cookies and XSRF tokens

This code was quickly ripped out of an active project to serve as an example. It will not compile in any way!

Any questions? Add them to the comments!

Notes

  • the application uses a version of the cake pattern to compose the Spray routing application together from various traits
  • a lot of those traits should be pretty self-explaining based on their name but if requested I can paste them into this Gist
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.agent.Agent
import com.typesafe.config.ConfigFactory
import akka.event.Logging
import akka.actor.Props
import kafka.utils.Utils
import java.nio.ByteBuffer