Skip to content

Instantly share code, notes, and snippets.

View amast09's full-sized avatar

Aaron Mast amast09

View GitHub Profile
amast09 / Order.scala
Created February 17, 2023 17:48
Foundations of Functional Programming in Scala: Redesigned Order
case class OrderId(value: String)
case class ItemId(value: String)
case class Item(id: ItemId, quantity: Int, unitPrice: Double)
sealed trait Order {
val id: OrderId
val createdAt: Instant
val orderStatus: OrderStatus
amast09 / async-examples.js
Created October 2, 2017 03:27
Examples referenced in async js blog post
// `series` Method Example
function eatFreeBread (bread, callback) {
setTimeout(function () {
console.log('Just ate some ' + bread + ' bread');
callback(null, {breadRating: 8});
}, 3000);
import scala.concurrent.Future
import{ActorMaterializer, KillSwitch, KillSwitches, ThrottleMode}
import{Keep, Sink, Source}
import scala.concurrent.duration._
import scala.util.Random
final case class StockQuote(symbol: String, price: Int)
amast09 / ForComprehensions.scala
Last active July 30, 2017 21:58
Advanced Scala for comprehensions
import scala.concurrent.Future
import scala.concurrent.Await
import scala.concurrent.duration._
import java.util.Calendar
case class Movie(name: String, year: Int, rating: BigDecimal, directorId: Int)
case class Director(id: Int, name: String, yearBorn: Int)