Skip to content

Instantly share code, notes, and snippets.

View pedrofurla's full-sized avatar

Pedro Furlanetto pedrofurla

View GitHub Profile
@pedrofurla
pedrofurla / gist:f5e3da72188acae96bd5
Created June 2, 2014 19:17
Custom config and task for multiple initialCommands in SBT Scala console
val hconfig = config("hconfig").extend(Compile)
lazy val hconsole = taskKey[Unit]("hconsole")
lazy val destroySchema = taskKey[Unit]("destroySchema")
hconsole := (console in hconfig).value
val slickperf = project.in(file(".")).
configs(hconfig).
settings(inConfig(hconfig)(Defaults.configTasks) : _*)
@pedrofurla
pedrofurla / gist:6d852f856f3182a3104f
Created October 10, 2014 04:36
Sketch of a bunch of studies topics
title
Functional Programming

Fundamentals

Conception, evolution, and application of functional programming languages

The algebra of types

@pedrofurla
pedrofurla / gist:7860cc38d0acc4e929d3
Created January 16, 2015 18:58
Stylish CSS to improving the "readability" of the online Purescript by Example book
/* To be used with the online version of Purescript by Example https://leanpub.com/purescript/read */
#read-online { color:black }
#read-online .read { width:auto }
.sidebar {
position: absolute;
margin-left: 450px; /* this is to make sure the book add stays visible, probably there is more reliable way of doing this */
}
{-
From: https://gist.github.com/pedrofurla/12516a6998ca39520b14
Re-interpretation of the problem:
- An imaginary room of size N x M,
- Contains a robot that can move one unit (of the above scale) at a time.
- Attempting to cross the boundaries of the room has no effect.
- Certain positions contains patchs of dirty. If the robot gets to that position it is cleansed.
Program organization:
def title[A <: { def name:String }](a:A):A = { print(a.name); a}
suppose we have Company(name:String, address:String), Person(name:String, age:Int)
title(person).age
title(company).address
title(person).address // error
@pedrofurla
pedrofurla / sbt-prompt-git.scala
Last active November 21, 2015 06:43
Nice looks and git info into the sbt shell
addCommandAlias("git", "; sh git")
commands ++= Seq(
Command.args("sh", "<shell command>") { (state, args) =>
// using script here maintains ansi colors, see http://stackoverflow.com/a/13587964/467390
val ret = ("script -q /dev/null " ++ args.mkString(" ")) !;
state
}
)
function *gen(x) {
var i = yield(x + 1);
console.log(i, typeof i);
var y = 2 * i;
var z = yield (y/3);
return x + y +z
}
var g = gen(5)
@pedrofurla
pedrofurla / Tmp.scala
Last active June 11, 2016 15:06
Where String#+ comes from?
object Tmp {
"zzz" ++ "kkk" // Fails with -Yno-predef
// after typer the above is scala.this.Predef.augmentString("zzz").++[Char, String](scala.this.Predef.augmentString("kkk"))(scala.this.Predef.StringCanBuildFrom);
"aaa"+new Object() // Doesn't fail ever!
// after typer the above is "aaa".+(new java.this.lang.Object());
// Why didn't `+` desugar to something else?
new Object() + "aaa" // Fails with -Yno-predef
@pedrofurla
pedrofurla / chrome
Created July 8, 2016 15:42
Bash/AppleScripts to open or reload chrome
open /Applications/Google\ Chrome.app --args --allow-file-access-from-files --unlimited-quota-for-files
@pedrofurla
pedrofurla / tmorris-exercises.scala
Last active July 29, 2016 14:58
Tony Morris' Revised Scala Exercises
sealed trait List[+A] {
override def toString = {
def toScalaList(t: List[A]): scala.List[A] = t match {
case Empty => Nil
case Cons(h, t) => h :: toScalaList(t)
}
toScalaList(this).toString
}
}
final case object Empty extends List[Nothing]