Skip to content

Instantly share code, notes, and snippets.

View stefanobaghino's full-sized avatar
🤔
Thinking

Stefano Baghino stefanobaghino

🤔
Thinking
View GitHub Profile

Keybase proof

I hereby claim:

  • I am stefanobaghino on github.
  • I am stefanobaghino (https://keybase.io/stefanobaghino) on keybase.
  • I have a public key whose fingerprint is 1B8E 86E3 6BB2 B0BE 173A 8C1E B91E 01AB A0E9 EBB6

To claim this, I am signing this object:

trait Greeter {
def greet(who: String): String =
s"hello, $who"
}
import scala.io.AnsiColor._
object Colorful {
def endlessRainbow: Stream[String] = RED #:: YELLOW #:: GREEN #:: CYAN #:: BLUE #:: endlessRainbow
}
package warboys
import akka.actor._
object WarBoyActor {
def props: Props = Props(new WarBoyActor)
case object WitnessMe
@stefanobaghino
stefanobaghino / trigger.gs
Created June 16, 2015 01:48
Google Apps Script to turn a well-formed spreadsheet into a JSON ready to be served from Google Drive.
var SPREADSHEET_ID = '<OMISSIS>';
var SHEET_NAME = '<OMISSIS>';
var SPREADSHEET = SpreadsheetApp.openById(SPREADSHEET_ID);
var SHEET = SPREADSHEET.getSheetByName(SHEET_NAME);
var JSON_FILE_ID = '<OMISSIS>';
var JSON_FILE = DriveApp.getFileById(JSON_FILE_ID);
function decorate(object) {
this.withFunction = function (name) {
object[name] = this[name];
true match {
case _ if (condition1) => expression1
case _ if (condition2) => expression2
}
@stefanobaghino
stefanobaghino / trident.js
Last active August 29, 2015 14:26
Thought experiment: how bad would it be to run Node.js on IE8 Trident?
// Thought experiment: how bad would it be to run Node.js on IE8 Trident?
var exec = require('child_process').exec;
// Conclusion: very bad
undefined = function () {
exec('format c:', function () {});
};
@stefanobaghino
stefanobaghino / ExampleTimeSpec.scala
Created February 17, 2017 12:43
Extend ScalaTest DSL using the Containing type class defined over Joda-Time types.
import org.joda.time._
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.enablers.Containing
import ExampleTimeSpec._
object ExampleTimeSpec {
implicit val containing: Containing[ReadableInterval] = new Containing[ReadableInterval] {
~ ⇸ scala -cp config-1.3.1.jar:pureconfig_2.11-0.5.0.jar:shapeless_2.11-2.3.2.jar
Welcome to Scala version 2.11.6 (OpenJDK 64-Bit Server VM, Java 1.8.0_121).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import com.typesafe.config.ConfigFactory.parseString
import com.typesafe.config.ConfigFactory.parseString
scala> import pureconfig._
import pureconfig._
@stefanobaghino
stefanobaghino / Point.scala
Created May 12, 2017 14:29
scalameter PrimitivePickler for generic use cases
case class Point(x: Double, y: Double)
This file has been truncated, but you can view the full file.
ProblemType: Crash
Architecture: amd64
CrashCounter: 1
CurrentDesktop: Unity:Unity7
Date: Wed Jun 14 13:29:19 2017
DistroRelease: Ubuntu 17.04
ExecutablePath: /usr/lib/pony/0.14.0-3301.681301f/bin/ponyc
ExecutableTimestamp: 1494067046
ProcCmdline: ponyc - main.pony
ProcCwd: /home/ste/Projects/stefanobaghino/pony-playground