Skip to content

Instantly share code, notes, and snippets.

View pedrofurla's full-sized avatar

Pedro Furlanetto pedrofurla

View GitHub Profile
@pedrofurla
pedrofurla / gist:8213d4242f9d1c0d387c
Created May 2, 2014 13:31
My SBT last night struggle
// The problem, I believe, was doing `inConfig(hconfig)(Defaults.defaultSettings + other settings) `, therefore kill the project
// setup in the hconfig. Btw, h stands for hibernate (ergh) config. I wanted a shell where it'd be easy to play with hibernate
project.in(file(".")).
configs(hconfig).
settings(inConfig(hconfig)(Defaults.configTasks) : _*)
.settings(
fork.in(hconfig,console) := true,
initialCommands in hconfig :=
"""
@pedrofurla
pedrofurla / gist:11373093
Created April 28, 2014 14:04
Playframework template WTF?
// FINE!
@reports.zip(exec.Comparisons2.totalTimeColors).map { case (r@ElapsedTimeOf(title, elapsed ),color) =>
@{oneSeries(elapsed.time, title, "column", color, 0)}
}.reduce(_ + (new Html(",")) + _)
---------------
// BAD! ->
@reports.zip(exec.Comparisons2.totalTimeColors).map {
@pedrofurla
pedrofurla / gist:11244893
Last active August 29, 2015 14:00
Get implicit resolution out of the companion object. Why not happening. See bottom of the file for error.
object Other2 {
import scalaz._
import Scalaz._
import scalaz.syntax._
case class ElapsedTime[A](time: A)
object ElapsedTime {
type O[CC[_]] = {
type λ[A]=ElapsedTime[CC[A]]
}
@pedrofurla
pedrofurla / gist:11161049
Last active August 29, 2015 14:00
ElapsedTime[A,CC[_]], Functor scalaz instance on CC[_] or NEL
object YetAnother2 {
import scalaz._
import Scalaz._
case class ElapsedTime[A, CC[_]](time: CC[A])
object ElapsedTime {
type ET_A[CC[_]] = {
type λ[A]=ElapsedTime[A, CC]
}
type NEL[A] = NonEmptyList[A]
case class ElapsedTime[CC[_]](time: CC[Chronon]) { type HK[a] = CC[a] }
object ElapsedTime {
class ETFunctor[CC[_]](implicit evf: Functor[CC])
extends Functor[({type λ[α]=ElapsedTime[CC]})#λ]
// Functor[ElapsedTime[CC]#HK]
{
def map[A, B](fa: ElapsedTime[CC])(f: Chronon => Chronon): ElapsedTime[CC] = ElapsedTime(evf.map(fa.time)(f))
}
}
trait EntityBase {
def id: String
}
trait Repository {
type Entity <: EntityBase
def get(id: String): Option[Entity]
}
@pedrofurla
pedrofurla / gist:10625689
Last active August 29, 2015 13:59
Playframework templates vs Javascript.
@reports map { case(r@Report(title, lines, _)) =>
{
name: '@title',
color: '#4070A0',
type: 'column',
yAxis: 0,
//data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6],
data: [ @lines.map{ case ReportLine(rows, time, timeUnit) => @time }.mkString(",") ],
tooltip: { valueSuffix: ' µs' }
}
@pedrofurla
pedrofurla / jpaperf.Main.txt
Last active August 29, 2015 13:58
Slick vs JPA -- the difference is kind of ridiculous - preliminary results
[info] Running jpaperf.Main
-- Inserting
[info] # of Rows: 1, totalTime: 39724 μs, time per row: 39724.0 μs
[info] # of Rows: 10, totalTime: 32630 μs, time per row: 3263.0 μs
[info] # of Rows: 20, totalTime: 55624 μs, time per row: 2781.2 μs
[info] # of Rows: 30, totalTime: 79954 μs, time per row: 2665.1333 μs
[info] # of Rows: 40, totalTime: 99999 μs, time per row: 2499.975 μs
[info] # of Rows: 50, totalTime: 118572 μs, time per row: 2371.44 μs
[info] # of Rows: 100, totalTime: 217274 μs, time per row: 2172.74 μs
[info] # of Rows: 200, totalTime: 420907 μs, time per row: 2104.535 μs
@pedrofurla
pedrofurla / jpaperf.Main.old.txt
Created April 5, 2014 17:39
Comparing slick vs jsa under mysql. Notice the file names. I consider the most revealing info being the "time per register". Also notice the re-rerun after 10,000 rows.
[info] Running jpaperf.Main
[info] Inserting users with one account each
[info] Rows: 1, totalTime: 39161 μs, time per register: 39161.0 μs
[info] Rows: 10, totalTime: 31550 μs, time per register: 3155.0 μs
[info] Rows: 20, totalTime: 58404 μs, time per register: 2920.2 μs
[info] Rows: 30, totalTime: 75291 μs, time per register: 2509.7 μs
[info] Rows: 40, totalTime: 93540 μs, time per register: 2338.5 μs
[info] Rows: 50, totalTime: 109259 μs, time per register: 2185.18 μs
[info] Rows: 100, totalTime: 206513 μs, time per register: 2065.13 μs
[info] Rows: 200, totalTime: 418894 μs, time per register: 2094.47 μs
@pedrofurla
pedrofurla / gist:9917123
Created April 1, 2014 15:59
HList map doesn't like defaults...
scala> val sample = "A" :: 1 :: 2L :: HNil
sample: shapeless.::[String,shapeless.::[Int,shapeless.::[Long,shapeless.HNil]]] = A :: 1 :: 2 :: HNil
scala> object bleh4 extends Poly1 {
| implicit val caseInt = at[Int](_.toString);
| implicit val caseLong = at[Long](_.toString);
| implicit val caseStr = at[String](_.toString);
| }
defined module bleh4