Skip to content

Instantly share code, notes, and snippets.

View fwbrasil's full-sized avatar

Flavio Brasil fwbrasil

  • Nubank
  • San Francisco Bay Area, California
View GitHub Profile
@fwbrasil
fwbrasil / PrevaylerJr.scala
Created April 6, 2012 20:01
PrevaylerJr in Scala
import java.io._
class PrevaylerJr[T <: Serializable](initialState: T, pStorageFile: File) {
private val storageFile = new File(pStorageFile.getAbsolutePath + ".tmp")
private val system = {
val fileToRead = if (pStorageFile.exists) pStorageFile else storageFile
if (fileToRead.exists) {
val input = new ObjectInputStream(new FileInputStream(fileToRead))
@fwbrasil
fwbrasil / Nolan.scala
Created September 4, 2012 12:23
Nolan test...
package nolan
import net.fwbrasil.activate.ActivateContext
import net.fwbrasil.activate.migration.Migration
import net.fwbrasil.activate.storage.mongo.MongoStorage
object MongoContext extends ActivateContext {
def contextName = "mongoContext"
val storage = new MongoStorage {
override val authentication = Option(("activate_test", "activate_test"))
@fwbrasil
fwbrasil / gist:3783157
Created September 25, 2012 17:02
Subtrate rest
trait Person extends Entity {
var name: String
def nameAsUpperCase =
name.toUpperCase
}
object Person {
def personsWhereNameStartsWith(string: String) =
select[Person] where (_.name like string + "%")
}
class NaturalPerson(var name: String, var motherName: String) extends Person {
@fwbrasil
fwbrasil / ActivateGraph.scala
Created November 22, 2012 17:06
Activate graph database support spike
package com.example.foo
import activateExampleContext._
class Person(
var name: String)
extends Vertex
class Knows(
val from: Person,
package net.fwbrasil.sReflection
object CascadeImplicits {
implicit def toYourself[T](value: T): Yourself[T] = new Yourself(value)
implicit def toCascade[T](value: T): Cascade[T] = new Cascade(value)
class Yourself[T](value: T) {
def yourself = value
}
@fwbrasil
fwbrasil / gist:4743435
Last active December 12, 2015 08:19
SMirror - invoking a no-arg constructor
scala> import net.fwbrasil.smirror._
import net.fwbrasil.smirror._
scala> implicit val mirror = runtimeMirror(getClass.getClassLoader)
mirror: reflect.runtime.universe.Mirror = JavaMirror with scala.tools.nsc.interprete...
scala> case class Shop(store: String, item: String, cost: Int) {
| def this() = this(null, null, 0)
| }
defined class Shop
import net.fwbrasil.smirror._
trait Foo {
@deprecated("foo is a terrible name! what were you thinking?", "0.1")
def foo(i: Int) = i
}
class Bar extends Foo {
}
@fwbrasil
fwbrasil / CrudTest.scala
Last active December 17, 2015 00:19 — forked from b0c1/CrudTest.scala
package hu.finesolution.sepia.test.core.controller
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.mock.MockitoSugar
import org.scalatest.{FunSuite, BeforeAndAfter}
import org.scalatra.test.scalatest.ScalatraSuite
import org.scalatra.ScalatraServlet
ubuntu@ip-10-152-186-104:~/FrameworkBenchmarks$ toolset/run-tests.py -u ubuntu --test play-activate-mysql -i ~/.ssh/id_rsa.pub --max-threads 20
=====================================================
Preparing Server, Database, and Client ...
=====================================================
bash: cpu0/cpufreq/scaling_governor: No such file or directory
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ubuntu@ip-10-152-186-104:~/FrameworkBenchmarks$ toolset/run-tests.py -u ubuntu --test play-activate-mysql -i ~/.ssh/id_rsa --max-threads 5 --max-concurrency 16
=====================================================
Preparing Server, Database, and Client ...
=====================================================
bash: cpu0/cpufreq/scaling_governor: No such file or directory
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-40-virtual x86_64)
* Documentation: https://help.ubuntu.com/