Skip to content

Instantly share code, notes, and snippets.

@jgongo
jgongo / binaryResponseMarshaller
Created August 6, 2014 15:44
This is a ToResponseMarshaller able to stream a BinaryResponse object containing a content type and an Enumerator[Array[Byte]], using Spray chunked response streaming. I needed this to be able to serve files stored in a MongoDB database, using GridFS in a non blocking manner.
case class BinaryResponse(contentType: ContentType, data: Enumerator[Array[Byte]])
trait SharedJSONFormats extends DefaultJsonProtocol with MetaMarshallers with SprayJsonSupport {
implicit def binaryResponseMarshaller(implicit actorRefFactory: ActorRefFactory, executionContext: ExecutionContext, timeout: Timeout) = ToResponseMarshaller[BinaryResponse] { (value, toResponseMarshallingContext) =>
val responseStreamerActor: ActorRef = actorRefFactory.actorOf {
Props {
new Actor with ActorLogging {
object ChunkSent
@jgongo
jgongo / brew-doctor
Created October 11, 2013 13:52
brew install typesafe-activator failure
bash-3.2$ brew doctor
Your system is ready to brew.
@jgongo
jgongo / Assembly+CoreData.m
Last active December 14, 2015 10:59
Creation of simple Core Data stack using Typhoon 1.1.2
#import "Assembly+CoreData.h"
#import <Typhoon/Typhoon.h>
#import <CoreData/CoreData.h>
#pragma mark NSPersistentStoreCoordinator configuration
@interface NSPersistentStoreCoordinator (InjectedConfiguration)
- (void)configureStoreCoordinatorUsingDefaultComponentFactory;
- (void)configureStoreCoordinatorUsingDefaultComponentFactoryWithLightweightMigration;