Skip to content

Instantly share code, notes, and snippets.

@havocp
havocp / gist:3b4866ea03e4545a7e2a
Created September 25, 2014 23:56
CanLoadSimpleProject failure
This file has been truncated, but you can view the full file.
Using worker: worker-linux-12-1.bb.travis-ci.org:travis-linux-14
travis_fold:start:git.1
travis_time:start:15381587
$ git clone --depth=50 git://github.com/sbt/sbt-remote-control.git sbt/sbt-remote-control
Cloning into 'sbt/sbt-remote-control'...
remote: Counting objects: 3100, done.
remote: Compressing objects: 0% (1/1066) 
remote: Compressing objects: 1% (11/1066) 
remote: Compressing objects: 2% (22/1066) 
@havocp
havocp / mockup-viewer.py
Created July 1, 2015 13:27
pygtk app to extract pixel sizes and colors from mockups
#! /usr/bin/python
# this script is Copyright 2006, Red Hat, Inc. Licensed under the GNU
# General Public License, version 2 or any later version.
import gtk
import sys
import cairo
import struct
@havocp
havocp / OpenSourceLab.md
Created August 31, 2011 16:48
Dreamforce Open Source Lab

This quickstart will get you going with Scala and the twitter-finagle web library on the Cedar stack. Prerequisites

  • Basic Scala knowledge, including an installed version of sbt 0.10.x and a JVM.
  • Basic Git knowledge, including an installed version of Git.
  • Your application must be compatible with sbt 0.10.1 or higher and scala 2.8.1.
  • Your application must run on the OpenJDK version 6.
  • An installed version of Ruby.

Install the Heroku Command-line Client

@havocp
havocp / HelpAndLint.scala
Created December 17, 2011 05:41
Hacky build-lint and new-help commands
package com.typesafe.sbthelp
import _root_.sbt._
import Project.Initialize
import Keys._
import Defaults._
import Scope.GlobalScope
import Load.BuildStructure
import scala.annotation.tailrec
@havocp
havocp / EnhancedURI.scala
Created April 5, 2012 02:10
Lame URI manipulation
/**
* Copyright (C) 2012 Typesafe, Inc <http://typesafe.com>
*/
import java.net.URI
import java.net.URLDecoder
import java.net.URLEncoder
object EnhancedURI {
implicit def uri2enhanced(uri: URI) = new EnhancedURI(uri)
}
@havocp
havocp / SafeActor.scala
Created April 23, 2012 14:02
Use actor state from Future callbacks
package com.ometer.akka
import akka.actor.Actor
import akka.dispatch.ExecutionContext
import akka.actor.ActorRef
import akka.dispatch.Promise
import akka.dispatch.Future
import akka.dispatch.DefaultPromise
class Example extends SafeActor {
@havocp
havocp / future-bound-to-context.patch
Created May 2, 2012 17:28
Support binding a future to an ExecutionContext for Java
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala
index bd58b3a..b218bf8 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -534,6 +534,25 @@ trait Future[+T] extends Awaitable[T] {
p.future
}
+ /**
+ * Obtain a `scala.concurrent.FutureWithExecutionContext` where
@havocp
havocp / dispatch-tasks.patch
Created May 2, 2012 20:35
don't batch tasks across executors, and consolidate some closures and Runnables into one Task object
diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala
index 957f9cf..0dcfa87 100644
--- a/src/library/scala/concurrent/impl/Future.scala
+++ b/src/library/scala/concurrent/impl/Future.scala
@@ -44,13 +44,11 @@ private[concurrent] object Future {
}
def boxedType(c: Class[_]): Class[_] = if (c.isPrimitive) toBoxed(c) else c
-
- def apply[T](body: =>T)(implicit executor: ExecutionContext): Future[T] = {
@havocp
havocp / common-package.scala
Created May 8, 2012 22:50
Play result composition
/* Caution: untested code. Allows composing Result objects in Play 2.0 */
import play.api.mvc._
import play.api.http.HeaderNames
package object common {
def mapPlain(result: Result, f: PlainResult => Result): Result = {
result match {
@havocp
havocp / binding.scala
Created May 10, 2012 02:26
Binding implicits
trait CacheContext
trait Cache {
def lookup(query: String)(implicit context: CacheContext): String
def store(id: String, value: String)(implicit context: CacheContext): Unit
}
class BoundCache(private val delegate: Cache)(implicit private val context: CacheContext) {
def lookup(query: String): String =
delegate.lookup(query)