Skip to content

Instantly share code, notes, and snippets.

View iamthiago's full-sized avatar

Thiago Pereira iamthiago

  • Stockholm, Sweden
View GitHub Profile
@iamthiago
iamthiago / BigData.scala
Created April 24, 2017 17:36 — forked from davegurnell/BigData.scala
Slick database mapping of >22 columns using HLists
import slick.driver.MySQLDriver.simple._
import scala.slick.collection.heterogenous._
import scala.slick.collection.heterogenous.syntax._
import scala.slick.jdbc._
// This is the large case class we are mapping -- 25 string fields:
case class BigData(
field1: String,
field2: String,
field3: String,
@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 / 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
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 = {
import akka.actor.Actor
import akka.actor.ActorSystem
import akka.agent.Agent
import com.typesafe.config.ConfigFactory
import akka.event.Logging
import akka.actor.Props
import kafka.utils.Utils
import java.nio.ByteBuffer
case object Run
case object Msg
class Destination extends Actor {
def receive = {
case Msg sender ! Msg
}
}
class Client(
package model
import java.util.UUID
import play.api.libs.json.Json
case class Address(
id: Option[UUID],
address: Option[String],
number: Option[Int],
if [ ! -e /home/jenkins/.gvm/scripts/gvm ]
then
wget https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer
chmod +x gvm-installer
./gvm-installer
fi
source /home/jenkins/.gvm/scripts/gvm
gvm install go1