Skip to content

Instantly share code, notes, and snippets.

View ahjohannessen's full-sized avatar

Alex Henning Johannessen ahjohannessen

View GitHub Profile
@massie
massie / KryoRegistrator.scala
Created October 29, 2013 23:59
Here's an example of how to embed Avro objects into a Kryo stream. You only need to register each Avro Specific class in the KryoRegistrator using the AvroSerializer class below and you're ready to go.
/*
* Copyright (c) 2013. Regents of the University of California
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@pchiusano
pchiusano / retries.scala
Last active December 30, 2015 22:29
Combinator for retrying a `Process` multiple times, delaying between attempts
// FYI: some comments below refer to old version of this gist: https://gist.github.com/pchiusano/7894696/12201b92db57dff8ed6689fc55c15c3f1a136f86
package scalaz.stream
import scalaz.\/
import scalaz.concurrent.Task
object retries {
def dropWhileUnlessAtEnd[I](f: I => Boolean): Process1[I,I] = {
def go(prev: Option[I]): Process1[I,I] =
@noteed
noteed / docker-ovs.md
Last active December 29, 2023 07:07
Docker - Open vSwitch setup
@cameron
cameron / init.sh
Last active August 1, 2017 12:57
initialize a CoreOS vm with the latest docker and DNS service discovery via skydock
This gist is old. Check out http://gijs.github.io/blog/2014/09/09/docker-and-service-discovery/
anonymous
anonymous / gist:9323482
Created March 3, 2014 11:52
Nick's Arch Deps
$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:
@runarorama
runarorama / gist:9422453
Last active August 29, 2015 13:57
Suggestion for the new representation of `IO` in Scalaz.
import scalaz._
import \/._
import Free._
import scalaz.syntax.monad._
import java.util.concurrent.atomic.AtomicReference
import java.util.concurrent.CountDownLatch
object Experiment {
sealed trait OI[A] {
def map[B](f: A => B): OI[B]
@ezhulenev
ezhulenev / fromCallback.scala
Created April 12, 2014 19:41
scalaz-stream equivalent to Play Framework's Enumerator.fromCallback
import java.util.concurrent.atomic.AtomicInteger
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.concurrent.future
import scala.util.{Failure, Success}
import scalaz.concurrent.Task
import scalaz.stream.Process.End
import scalaz.stream._
import scalaz.{-\/, \/-}
@mattes
mattes / cloud-config.yaml
Last active November 2, 2016 16:37
CoreOS on Google Compute Engine: push systemd journal logs to logentries.com https://medium.com/coreos-linux-for-massive-server-deployments/defb984185c5
#cloud-config
write_files:
- path: /home/core/journal2logentries.sh
permissions: '0744'
owner: root:root
content: |
#!/usr/bin/env bash
# CoreOS on Google Compute Engine: push systemd journal logs to logentries.com
# get your private token from logentries.com, see https://logentries.com/doc/input-token
@noteed
noteed / docker-tinc.md
Last active August 1, 2025 14:09
Docker - Tinc setup
@milessabin
milessabin / gist:aae285025a32fac0f5c1
Last active August 26, 2017 10:28
Trivial type safe heterogenous map using only dependent method types, singleton-typed String literal keys and implicits.
scala> trait Assoc[K] { type V ; val value: V }
defined trait Assoc
scala> def mkAssoc[V0](k: String, v: V0): Assoc[k.type] { type V = V0 } =
| new Assoc[k.type] { type V = V0 ; val value = v }
mkAssoc: [V0](k: String, v: V0)Assoc[k.type]{type V = V0}
scala> implicit def nameAssoc = mkAssoc("Name", "Mary")
nameAssoc: Assoc[String("Name")]{type V = String}