Skip to content

Instantly share code, notes, and snippets.

View stefanobaghino's full-sized avatar
🤔
Thinking

Stefano Baghino stefanobaghino

🤔
Thinking
View GitHub Profile
@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] {
@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 / KafkaFeed.scala
Last active April 11, 2023 07:57
Pipe a Kafka consumer to a WebSocket on Play! Framework.
package controllers
import java.util.Properties
import com.typesafe.config.ConfigFactory
import kafka.consumer.{Consumer, ConsumerConfig, ConsumerConnector, Whitelist}
import kafka.serializer.StringDecoder
import play.api.libs.iteratee.{Enumerator, Iteratee}
import play.api.mvc.{Controller, WebSocket}
true match {
case _ if (condition1) => expression1
case _ if (condition2) => expression2
}
@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];
package warboys
import akka.actor._
object WarBoyActor {
def props: Props = Props(new WarBoyActor)
case object WitnessMe
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
}

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: