Skip to content

Instantly share code, notes, and snippets.

View ericacm's full-sized avatar

Some Dude ericacm

View GitHub Profile
#!/usr/bin/ruby
require 'json'
DESC_HEAD = /^\.([^\.\[]+)/
DEREF_HEAD = /^\[(\d+)\]/
def usage
$stderr.puts <<USAGE
usage: json descriptor
@aphyr
aphyr / zfs-sync
Created February 7, 2015 05:42
Sync ZFS filesystems, incrementally if possible.
#!/usr/bin/env ruby
# Synchronizes ZFS filesystems.
#
# Takes three args: source pool, destination pool, and filesystem name.
#
# Syncs most recent snapshot of filesystem from source to destination pool,
# using incremental transfer if possible.
# Take a snapshot line from zfs list -t snapshot and emit a struct
package com.rr.experiment
import org.specs2.ScalaCheck
import org.specs2.mutable._
import org.scalacheck._
import scalaz._
import scodec._

Reading SBT Credentials from OS X Keychain

In the following, replace the REPO_NAME value with the natural-language name of your repository, replace REPOSITORY with the domain name (e.g. repo1.maven.org) and replace USERNAME with your repository user.

credentials += {
  val Password = """.*password: "([^"]+)".*""".r
  var lines: String = ""
  val logger = new ProcessLogger {
 def info(s: =&gt; String) = {}
@kevinwright
kevinwright / scaladays2014.md
Last active March 8, 2018 20:25
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

@rbuckland
rbuckland / sealed-abstract-case-class-copy for Command messages.scala
Last active September 30, 2021 10:36
Sometimes you just want to call the copy method for the same "parameters", but not care about what underlying type it is.Because case class .copy() methods are auto generated per case class, you can't call copy on the abstract class, so this approach uses some scala foo to generate a scala Function that generates the correct magic for you.
package com.soqqo.luap.messages
import com.soqqo.luap.messages.ContextMetaData
import com.soqqo.luap.messages.NoContextMetaData
import com.soqqo.luap.messages.RegisterNewPerson
import io.straight.fw.model.Uuid
import scala.reflect.api.JavaUniverse
import scala.reflect.api
import io.straight.fw.jackson.JacksonBindingSupport._
import scala.Some
@mnadel
mnadel / DatabaseCallable.java
Last active May 18, 2018 13:43
Dropwizard + Hystrix + Hibernate
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.Callable;
/**
* A database session and transaction-aware Callable
*/
class DatabaseCallable<T> implements Callable<T>
@ryanlecompte
ryanlecompte / gist:9745983
Created March 24, 2014 18:18
lazily recurse files in a root directory
import java.io.File
/**
* Iterate all files in the given directory recursively.
* @param root the root directory to traverse
* @return an Iterator[File] of traversed files
*/
def listFiles(root: File): Iterator[File] = {
def rec(files: List[File]): Stream[File] = {
files match {
@jboner
jboner / how-akka-maps-to-eai-patterns.txt
Last active October 9, 2022 21:57
How Akka maps to EAI Patterns
# How Akka maps to EAI Patterns
Might be up for debate or just plain wrong. Just some notes I scribbled down some time ago.
-----------------------------------------------------------------------------------------------------------------
EAI PATTERN AKKA PATTERN REFERENCE
-----------------------------------------------------------------------------------------------------------------
Point to Point Channel Regular Actor Communication http://www.eaipatterns.com/PointToPointChannel.html
Event-Driven Consumer Regular Actor Receive http://www.eaipatterns.com/EventDrivenConsumer.html
Message Selector Actor with Stash http://www.eaipatterns.com/MessageSelector.html
@ericacm
ericacm / MessageSequence.scala
Last active August 22, 2017 16:49
Implements the Message Sequence pattern from EIP (http://www.eaipatterns.com/MessageSequence.html)
package akka.contrib.pattern
import akka.actor.{Cancellable, ActorLogging, ActorRef, Actor}
import java.util
import akka.serialization.SerializationExtension
import scala.concurrent.ExecutionContext
import scala.concurrent.duration._
import scala.util.{Try, Failure, Success}
import scala.language.existentials
import java.util.UUID