Skip to content

Instantly share code, notes, and snippets.

View faermanj's full-sized avatar

Julio Faerman faermanj

View GitHub Profile
@faermanj
faermanj / FiboFunc.scala
Created March 12, 2012 14:40
Testando Gist
object FiboFunc {
val fibs:Stream[BigInt] =
0 #:: 1 #:: (fibs zip fibs.tail).map{ case (a,b) => a+b }
def main(args: Array[String]) = println(fibs(1000));
}
@faermanj
faermanj / AtorCalculador.scala
Created March 15, 2012 12:16
Avaliando Scala
case object Calcule
case object Pare
class Calculador extends Actor {
val rand = new Random
var pi, in, cnt = 1.0
def act() {
while (true) {
receive { //aguarda uma mensagem
@faermanj
faermanj / CommonsCollections.scala
Created March 15, 2012 12:37
Avaliando Scala 2
object Colecoes extends Application {
val lista = List.range(-5, 5)
CollectionUtils.forAllDo(
CollectionUtils.collect(
CollectionUtils.select(lista,
new Predicate() {
def evaluate(obj: Object): Boolean =
return obj.asInstanceOf[Int] > 0;
}), new Transformer() {
@faermanj
faermanj / Complex.scala
Created March 28, 2012 13:42
exploring-scala-1
def + + [B>: A, That] (that: TraversableOnce [B]) (implicit bf: CanBuildFrom [List [A], B, That]): That
@faermanj
faermanj / CommonsCollections.scala
Created March 28, 2012 13:47
exploring-scala-2
object Colecoes extends Application {
val myList = List.range(-5, 5)
CollectionUtils.forAllDo(
CollectionUtils.collect(
CollectionUtils.select(myList,
new Predicate() {
def evaluate(obj: Object): Boolean =
return obj.asInstanceOf[Int] > 0;
}), new Transformer() {
@faermanj
faermanj / react-s3.js
Last active August 29, 2015 14:11
Reactive S3 File Upload
/*
Hello, this is a first attempt to write a reactive app.
It should deploy a static website to AWS S3.
After creating the bucket, it should put the public bucket policy,
configure the bucket website and upload the files in parallel.
putBucketPolicy
createBucket -> putBucketWebsite
uploadFiles -> upload index.html
@faermanj
faermanj / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
for((x,i) <- xs.view.zipWithIndex) println("String #" + i + " is " + x)
AmazonS3Client s3 = new AmazonS3Client();
String bucketName = "deleteversions-"+UUID.randomUUID();
//Creates Bucket
s3.createBucket(bucketName);
//Enable Versioning
BucketVersioningConfiguration configuration = new BucketVersioningConfiguration(ENABLED);
s3.setBucketVersioningConfiguration(new SetBucketVersioningConfigurationRequest(bucketName, configuration ));
import scala.collection.JavaConverters._
import com.amazonaws.services.s3.AmazonS3Client
import rx.lang.scala._
import rx.lang.scala.schedulers._
import com.amazonaws.services.s3.model._
/**
* @author jfaerman
*/