This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Entity } from "electrodb"; | |
import { client, table } from "../client"; | |
export const UserEntity = new Entity( | |
{ | |
model: { | |
version: "1", | |
entity: "user", | |
service: "default", | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Error | |
➜ ~ brew upgrade | |
Updating Homebrew... | |
==> Auto-updated Homebrew! | |
Updated Homebrew from e98a91378 to 4c8fe984c. | |
Updated 2 taps (homebrew/core and homebrew/cask). | |
==> New Formulae | |
dasel | |
Error: undefined method `ohai_stdout_or_stderr' for #<ReporterHub:0x00007fd88a968308> | |
Please report this issue: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example | |
import java.text.NumberFormat | |
import java.time.Instant | |
import cats.effect.{IO, Sync, Timer} | |
import fs2.{Chunk, Stream} | |
import monix.eval.Task | |
import monix.execution.Scheduler | |
import monix.reactive.Observable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TableManager[F[_]](guard: Semaphore[F],)(implicit F: Sync[F], TableOps: TableOps[F]) { | |
// this feels hacky | |
private val state = mutable.Map.empty[String, Table] | |
def tableFor(name: String, createIfMissing: Boolean): F[Table] = guard.withPermit { | |
state.get(name) match { | |
case Some(table) => table.pure[F] | |
case None => for { | |
newTable <- TableOps.open(buildPath(name), createIfMissing) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit val vehicleLikeTank = new VehicleLike[Tank] { | |
def drive: String = "driving a big big tank" | |
} | |
val tank = Tank(...) | |
val drivenTank: Tank = Dealership.driveAndReturn(tank) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vehicles._ // import car and bus implementations | |
val ford = Car("ford") | |
Dealership.driveAndReturn(ford) // vehicleLikeCar is already in scope due to the import |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait VehicleLike[A] { | |
def drive(a: A): String | |
} | |
object Vehicles { | |
implicit val vehicleLikeCar = ... | |
implicit val vehicleLikeBus = ... | |
} | |
object Dealership { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ford: Car = Car("ford") | |
// still a Car | |
val drivenFord: Car = driveAndReturn(ford) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit val vehicleLikeCar = ... | |
implicit val vehicleLikeBus = ... | |
def driveAndReturn[A](vehicle: A)(implicit vehicleLike: VehicleLike[A]): A = { | |
println(vehicleLike.drive(vehicle)); vehicle | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val ford = Car("ford") | |
val londonBus = Bus("red") | |
println(vehicleLikeCar.drive(ford)) | |
println(vehicleLikeBus.drive(londonBus)) |
NewerOlder