Skip to content

Instantly share code, notes, and snippets.

View tbrown1979's full-sized avatar

Taylor William Brown tbrown1979

View GitHub Profile
@ChristopherDavenport
ChristopherDavenport / SingleRoutine.go
Last active March 31, 2024 14:26
SingleRoutine Failed Idea
package single_routine
import (
"log"
"sync"
"sync/atomic"
)
type deferred[B any] struct {
b B
@jsdevtom
jsdevtom / frontend-ws-connection.ts
Last active June 13, 2024 02:44
kubernetes-ingress websockets with nodejs
export const ws = webSocket<WebsocketMessage>(`wss://${location.hostname}:${location.protocol === 'https:' ? 443 : 80}/ws/`);
export const wsObserver = ws
.pipe(
retryWhen(errors =>
errors.pipe(
delay(1000)
)
)
);
@t3hnar
t3hnar / SerialRef.scala
Created January 9, 2019 16:37
SerialRef.scala
import cats.effect._
import cats.effect.concurrent.{Ref, Semaphore}
import cats.implicits._
trait SerialRef[F[_], A] {
def get: F[A]
def modify[B](f: A => F[(A, B)]): F[B]
@mpilquist
mpilquist / philosophers.scala
Last active April 28, 2023 23:31
Dining Philosophers with FS2
/*
scalaVersion := "2.12.7"
resolvers += Resolver.sonatypeRepo("snapshots")
libraryDependencies += "co.fs2" %% "fs2-core" % "1.0.1-SNAPSHOT"
*/
import cats._
import cats.implicits._
import cats.effect._
@ChristopherDavenport
ChristopherDavenport / ConcurrentSuccess.scala
Last active October 12, 2018 17:14
Currency Quick Evaluation
import cats.effect._
import cats.effect.implicits._
import cats.effect.concurrent._
import cats.implicits._
import cats._
import cats.temp.par._
object ConcurrentSuccess{
def parAttempt[G[_]: Traverse, F[_]: Par: MonadError[?[_], Throwable], A](xs: G[F[A]]): F[G[Either[Throwable, A]]] =
@ChristopherDavenport
ChristopherDavenport / EventAction.scala
Last active December 11, 2018 20:26
Fun Little Action Game
// fs2 1.0.0
import cats.effect._
import cats.effect.concurrent._
import cats.implicits._
import fs2._
import fs2.concurrent._
import scala.concurrent.duration._
object Main extends IOApp {
@Daenyth
Daenyth / Pull.md
Last active November 9, 2023 17:14
Designing an fs2 `Pull` from scratch

The problem

I have some data which has adjacent entries that I want to group together and perform actions on. I know roughly that fs2.Pull can be used to "step" through a stream and do more complicated logic than the built in combinators allow. I don't know how to write one though!

In the end we should have something like

def combineAdjacent[F[_], A](
 shouldCombine: (A, A) =&gt; Boolean,
<!DOCTYPE html>
<html>
<head>
<title>Fireside Chat</title>
<link rel="stylesheet" href="/style/style.css">
</head>
<body>
<h1>Fireside Chat</h1>
<div id="app">
<div v-if="state == 0">
package example.playground
import java.io.InputStream
import cats.effect.IO
import fs2._
import cats.implicits._
import java.util.concurrent.ScheduledExecutorService
import scala.concurrent.duration.FiniteDuration
package bannobankapp;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Bank {
public String bankName;
Map<String, User> userMap = new HashMap<String, User>();