Skip to content

Instantly share code, notes, and snippets.

View diegovar's full-sized avatar

Diego Varese diegovar

View GitHub Profile
import com.twitter.util.{Future => TwFuture}
import scala.concurrent.{Future => ScFuture, promise => ScPromise}
implicit def twFutureToScala[T](twFuture: TwFuture[T]): ScFuture[T] = {
val prom = ScPromise[T]
twFuture.onSuccess { res: T =>
prom.success(res)
}
twFuture.onFailure { t: Throwable =>
prom.failure(t)
}
@gclaramunt
gclaramunt / HTree.scala
Created August 14, 2012 14:13
Heterogeneous tree toy example
trait HTree
case class HTNode[T, LT <: HTree,RT <: HTree](node:T, lt:LT, rt:RT ) extends HTree
case class HTNil() extends HTree
/*
exmaple:
scala> HTNode ( 1, HTNode("a",HTNode(1.0,HTNil(),HTNil()), HTNode('z',HTNil(),HTNil())), HTNode(List(1,2,3),HTNil(),HTNil()))
@diegovar
diegovar / playlistsync.js
Created February 21, 2012 19:29
Playlist sync in node.js
var fs = require('fs'),
util = require('util'),
_path = require('path');
var sourceFolder = 'sourceFolder',
playlistPath = 'sync.m3u',
destinationFolder = 'destFolder';
console.log('-- Playlist copy application --\n');
console.log('Copying from ' + sourceFolder + ' to ' + destinationFolder + '\n');
@peplin
peplin / recipe.rb
Created July 10, 2010 01:30
S3 File Resource for Chef
# Source accepts the protocol s3:// with the host as the bucket
# access_key_id and secret_access_key are just that
s3_file "/var/bulk/the_file.tar.gz" do
source "s3://your.bucket/the_file.tar.gz"
access_key_id your_key
secret_access_key your_secret
owner "root"
group "root"
mode 0644
end