Skip to content

Instantly share code, notes, and snippets.

View iamthiago's full-sized avatar

Thiago Pereira iamthiago

  • Stockholm, Sweden
View GitHub Profile
name := "project"
scalaVersion in ThisBuild := "2.11.8"
lazy val commonSettings = Seq(
organization := "com.mycompany",
version := "0.0.1",
test in assembly := {},
parallelExecution in Test := false
)
package com.vivareal.locations.domain.services.address
import com.vivareal.locations.domain.model.address.Address
import com.vivareal.locations.infrastructure.aws.elasticache.ElastiCache
import scala.concurrent.Future
class CacheBuilder {
private val cache: ElastiCache[Address] = new ElastiCache[Address]
package com.gatling.test
import com.typesafe.config.ConfigFactory
import com.webtrekk.cdb.cassandra.entity.AccessId
import com.webtrekk.cdb.cassandra.service.AccessIdService
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.collection.JavaConversions._
import scala.concurrent.Await
@iamthiago
iamthiago / UnfoldPages.scala
Created April 29, 2016 01:20 — forked from rrodseth/UnfoldPages.scala
Create akka-stream Source from a pagination, using Source.unfoldAsync
// Inspired by a tweet from @trautonen 1/13/2016
// Use Source.unfoldAsync to turn paginated database results into an akka-streams Source
// unfold is the inverse of fold
case class Page[T](pageNumber:Long, totalPages:Long, contents:List[T])
case class Thing(id: Long, name: String = "foo")
val totalPages = 5 //
val pageSize = 3
@iamthiago
iamthiago / EitherTest.scala
Created March 10, 2016 17:39
Showing some functional code in Scala
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
/**
* Created by thiago on 3/10/16.
*/
object EitherTest extends App {
//given a list of ids
@iamthiago
iamthiago / sbt-benchmark.sh
Created January 8, 2016 16:09 — forked from patriknw/sbt-benchmark.sh
Example of sbt launch script for akka benchmarks
#!/bin/sh
# Run the benchmark with this as sbt start script,
# but change the paths (/home/nordwall)
# ~/bin/sbt-benchmark.sh
# > project akka-actor-tests
# > test-only akka.performance.microbench.TellThroughputPerformanceSpec
export JAVA=/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
export FLAGS="-server -Dfile.encoding=UTF8 -XX:+UseNUMA -XX:+UseCondCardMark -XX:-UseBiasedLocking"
### DML ###
# Keyspace Name
keyspace: stresscql
# The CQL for creating a keyspace (optional if it already exists)
keyspace_definition: |
CREATE KEYSPACE stresscql WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
# Table name
@iamthiago
iamthiago / RouterApp.scala
Last active August 29, 2015 14:26 — forked from patriknw/RouterApp.scala
Mailinglist question about watching routees for termination
package question
import java.io.IOException
import scala.util.Random
import akka.actor.Actor
import akka.actor.ActorRef
import akka.actor.ActorSystem
import akka.actor.OneForOneStrategy
import java.util.UUID
import scala.annotation.tailrec
/**
* Created by Thiago Pereira on 8/4/15.
*/
case class Employee(id: UUID, name: String, parent: Option[Employee])
object TailRecTest {
package org.example
import akka.actor._
import akka.camel.{ CamelMessage, Consumer, CamelExtension }
import org.apache.activemq.camel.component.ActiveMQComponent
class CdrLogConsumer extends Actor with Consumer {
def endpointUri = "activemq:FOO.BAR"
def receive = {