Skip to content

Instantly share code, notes, and snippets.

@akshaal
akshaal / .gitignore
Last active May 10, 2022 19:34
jdk11-scala-maven-plugin-overcompile
target
-- Based upon https://github.com/TimWolla/haproxy-auth-request/
-- http://w3.impa.br/~diego/software/luasocket/
local http = require("socket.http")
-- Doucmentation (if still works):
-- https://www.arpalert.org/src/haproxy-lua-api/1.9/index.html
-- Split 'str'-ing by 'pat'-tern
function splitString(str, pat)
@akshaal
akshaal / MoneyTransfer.scala
Created September 28, 2012 22:13
DCI MoneyTransfer in Scala
case class Account(var amount: Int)
import MoneyTransfer._
class MoneyTransfer private (src: Account with SourceRole,
dst: Account with DestinationRole,
amount: Int) {
def transfer(): Unit = {
src transfer amount
}
@akshaal
akshaal / macro.scala
Created August 18, 2012 17:59
Scala 2.10: annotated fields macro
/** Akshaal, 2012. http://akshaal.info */
import language.experimental.macros
import scala.reflect.macros.Context
import scala.annotation.Annotation
/**
* Macros for traversing over annotated elements.
*
* See http://www.akshaal.info/2012/08/scala-210-annotated-fields-macro.html for more information.
@akshaal
akshaal / scala_existential_map.scala
Created August 10, 2012 11:50
TypedKeyMap for scala
// ---------------------------------------------------------------------------------------------
// Here is the definition of TypedKeyMap
import scala.language.implicitConversions
import scala.language.higherKinds
import scala.language.existentials
import scala.collection.immutable.{ MapLike, HashMap }
trait TypedKey {
type Value