Skip to content

Instantly share code, notes, and snippets.

@frgomes
frgomes / scala_base64_encode_decode.scala
Created July 28, 2017 12:39
Scala - Base64 encode/decode
// Base64 encode
val text = "This is plaintext."
val bytesEncoded = java.util.Base64.getEncoder.encode(text.getBytes())
// Base64 decode
val textDecoded = new String(java.util.Base64.getDecoder.decode(bytesEncoded))
println(textDecoded)
@sofoklis
sofoklis / customsi.scala
Last active January 10, 2018 10:01
Custom string interpolation
object Test {
// Implicit class is also a new feature in scala 2.10
implicit class CounterSC(val sc: StringContext) extends AnyVal {
// Define functions that we want to use with string interpolation syntax
def partsCount(args: Any*): Int = sc.parts.length
def argsCount(args: Any*): Int = args.length
def tokenCount(args: Any*): Int = sc.parts.length + args.length
def getParts(args: Any*): String =