Skip to content

Instantly share code, notes, and snippets.

View ahjohannessen's full-sized avatar

Alex Henning Johannessen ahjohannessen

View GitHub Profile
$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:
@ahjohannessen
ahjohannessen / systemd
Created April 17, 2014 15:48
Systemd files for docker + skydns/dock
docker.service ->
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
After=network.target
[Service]
ExecStart=/usr/local/bin/docker -d -D -r=false -s btrfs -dns 172.17.42.1 -H unix:// -H tcp://0.0.0.0:4243
Restart=on-failure
@ahjohannessen
ahjohannessen / OddSpray.scala
Last active August 29, 2015 14:00
Spray and Scala 2.11 not best friends?
import scala.concurrent.Future
import akka.actor.ActorSystem
import spray.routing.SimpleRoutingApp
import spray.httpx.marshalling._
object Demo extends App with SimpleRoutingApp {
implicit val system = ActorSystem("demo")
implicit val _ = system.dispatcher
startServer(interface = "0.0.0.0", port = 8080) {
# install latest docker
wget --no-check-certificate https://get.docker.io/builds/Linux/x86_64/docker-latest -O docker
chmod +x docker
# systemd for the new docker
sudo tee /media/state/units/docker-local.service > /dev/null <<EOF
[Unit]
Description=docker local
[Service]
object parser {
private val parsers = Seq("d/M/yyyy", "dd/MM/yyyy")
.map(DateTimeFormatter.ofPattern)
.map(f ⇒ (d:String) ⇒ Try(LocalDate.parse(d, f)))
def parse(date: String) = {
parsers.map(_(date)).flatMap(_.toOption).head
}
/*
The code below is not intended to be a general purpose approach, but rather a
simple CmdHandler / EventHandler model prototype that illustrates a concept of
how to share an Eventsourced Processor stream among many child actors of
same type.
Snapshotting is important for children in order to get quick start up and avoid
filtering too many sibling events.
/* Morphing */
trait Picker[I <: HList, O <: HList] {
def apply(i: I): O
}
object Picker {
implicit def hnilPicker[I <: HList]: Picker[I, HNil] = new Picker[I, HNil] {
def apply(i: I) = HNil
}
@ahjohannessen
ahjohannessen / gist:c32d97a211bf889e444b
Last active August 29, 2015 14:04
AtLeastOnceDelivery
override protected[akka] def aroundReceive(receive: Receive, message: Any) = message match {
case RedeliveryTick ⇒ redeliverOverdue()
case RecoveryCompleted ⇒ redeliverOverdue(); super.aroundReceive(receive, message)
case _ ⇒ super.aroundReceive(receive, message)
}

Easy Kubernetes Installation on CoreOS

At Timeline Labs, we are continuously looking at new technologies to see what fits our needs. We are especially excited about Kubernetes from Google to manage our services atop Docker and CoreOS.

This process for installing Kubernetes on CoreOS uses Flannel for Kubernetes networking and should be cloud provider agnostic. To deploy the Kubernetes master functionality into the cluster, it uses fleetctl.

Thanks to Kelsey Hightower and his blog posts! They served as a great starting point for this process.

How do I get this running?

Add the cloud config below to your own and bring up your cluster. Once you can fleetctl list-machines, go ahead and fleetctl start the three Kubernetes master units in the fleet section below. At this point, you can ssh to the machine where the Kubernetes master units deployed,

@ahjohannessen
ahjohannessen / bug
Created October 13, 2014 10:52
Compile error when using Shapeless 2.0 and Scala 2.11.3
[error] missing or invalid dependency detected while loading class file 'PolyDefns.class'.
[error] Could not access type Aliases in package scala.reflect.macros,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'PolyDefns.class' was compiled against an incompatible version of scala.reflect.macros.
[trace] Stack trace suppressed: run last compile:compile for the full output.
[error] (compile:compile) scala.reflect.internal.Types$TypeError: missing or invalid dependency detected while loading class file 'PolyDefns.class'.
[error] Could not access term whitebox in package scala.reflect.macros,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)