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
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@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.
@JaviSoto
JaviSoto / gist:6090085
Created July 26, 2013 16:06
Dynamic row height calculation in table view with cells implemented with nib + autolayout
//
// JSDynamicRowHeightTableViewController.h
//
// Created by Javier Soto on 7/25/13.
// Copyright (c) 2013 JavierSoto. All rights reserved.
//
#import <UIKit/UIKit.h>
/**
@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;