Skip to content

Instantly share code, notes, and snippets.

View darkfrog26's full-sized avatar
🦊
Crazy like a fox

Matt Hicks darkfrog26

🦊
Crazy like a fox
View GitHub Profile
import cats.effect.{Deferred, IO}
import java.util.concurrent.ConcurrentHashMap
trait WorkCache[Key, Result] {
private val map = new ConcurrentHashMap[Key, Deferred[IO, Result]]
protected def persisted(key: Key): IO[Option[Result]]
protected def work(key: Key): IO[Result]
import cats.effect.IO
import cats.effect.unsafe.implicits.global
import scala.concurrent.duration._
object Maintenance {
def schedule(schedule: FiniteDuration,
initialDelay: Option[FiniteDuration] = None)
(action: IO[TaskResult]): MaintenanceTask = {
var normalSchedule = schedule
package live.prepared
import cats.data.EitherT
import cats.effect._
import cats.implicits._
import fabric.parse.Json
import fabric.rw._
import fs2.Chunk
import org.http4s._
import org.http4s.dsl.Http4sDsl
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class Screen {
final String key;
final Nav? nav;
final Widget Function() createWidget;
Screen({
required this.key,
import 'package:flutter/material.dart';
import 'package:get/get.dart';
void main() {
runApp(MyApp());
}
class MyNavModel {
static final Map<String, MyNavModel> urls = {};
final IconData icon;
/*
Allows me to write MUnit tests like:
"Such and such" should {
"do something" in {
value should be(123)
}
}
*/
inline def fromMapElems[A <: Product, T <: Tuple, L <: Tuple](map: Map[String, Value], index: Int, arr: Array[Any]): Unit = {
inline erasedValue[T] match
case _: (hd *: tl) =>
inline erasedValue[L] match
case _: (hdLabel *: tlLabels) =>
import fabric.rw.given
val hdLabelValue = constValue[hdLabel].asInstanceOf[String]
val hdValueOption = map.get(hdLabelValue)
val hdWritable = summonInline[Writer[hd]]
val valueOption = hdWritable.map(_.write(hdValue))
package hierarchical.rw
import hierarchical.*
import hierarchical.rw.*
import scala.deriving.*
import scala.compiletime.*
trait CompileRW {
implicit val stringR: Readable[String] = stringRW
import java.util.concurrent.ConcurrentLinkedQueue
import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{ExecutionContext, Future, TimeoutException}
import scala.util.{Failure, Success}
trait ParallelIterator[T] extends Iterator[T] { iterator =>
private val buffer = new ConcurrentLinkedQueue[T]
private var finished = false
private var failure: Option[Throwable] = None
@js.native
@JSGlobal("BlotEmbed")
class BlotEmbed extends js.Object {
var blotName: String = js.native
var tagName: String = js.native
var className: String = js.native
def create(data: js.Object): html.Element = js.native
def setDataValues(element: html.Element, data: js.Object): html.Element = js.native