Skip to content

Instantly share code, notes, and snippets.

@jdegoes
jdegoes / fpmax.scala
Created July 13, 2018 03:18
FP to the Max — Code Examples
package fpmax
import scala.util.Try
import scala.io.StdIn.readLine
object App0 {
def main: Unit = {
println("What is your name?")
val name = readLine()
@jdegoes
jdegoes / afp-examples.scala
Last active February 12, 2019 19:50
Example code from Applied Functional Programming with Scala
package lambdaconf.introfp2
// import scalaz._
// import Scalaz._
object functions {
object totality {
///def f[A]: A = null
def g[A]: A = throw new Error

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@jeffjohnson9046
jeffjohnson9046 / UuidHelper.java
Last active July 14, 2024 12:38
Convert UUID to byte array and vice versa. Useful for when UUIDs are stored in MySQL tables as VARBINARY(16)
import java.nio.ByteBuffer;
import java.util.UUID;
public class UuidAdapter {
public static byte[] getBytesFromUUID(UUID uuid) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(uuid.getMostSignificantBits());
bb.putLong(uuid.getLeastSignificantBits());
return bb.array();
package com.wixpress.quotes.common
import java.util.UUID
object CQRS {
////////////////////////////////////////////////////////////////////////////////
// Example application
////////////////////////////////////////////////////////////////////////////////