Skip to content

Instantly share code, notes, and snippets.

View s5bug's full-sized avatar
📦
I have become an NPM package.

Aly Cerruti s5bug

📦
I have become an NPM package.
View GitHub Profile
@s5bug
s5bug / hw14_2.scala
Created December 12, 2020 07:15
Scala program for my CS 113 class that generates tracing for QuickSort in HW #14
import cats._, cats.data._, cats.syntax.all._
import scala.annotation.tailrec
object Main2 {
sealed trait Trace {
def show: String
}
object Trace {
implicit val showTrace: Show[Trace] = Show.show(_.show)
@s5bug
s5bug / hw14.scala
Created December 12, 2020 05:54
Scala program for my CS 113 class that generates LaTeX code for the Heapify problems in HW #14
import cats._, cats.data._, cats.syntax.all._
import scala.annotation.tailrec
object Main {
case class Snapshot(comparisons: Int, exchanges: Int, tikz: String)
def main(args: Array[String]): Unit = {
val vector: Vector[Int] = Vector(55, 50, 10, 40, 80, 90, 60, 100, 70, 80, 20, 50, 22)
val (snapshots, _, ()) = heapify[Int].runEmpty(vector).value
@s5bug
s5bug / 1-README.md
Last active August 20, 2020 23:41
Making Everest mods in FSharp

Making Everest mods in FSharp

Prerequesites:

  • Everest installed
  • Git
  • Visual Studio 2015 or newer with the .NET Framework 4.5.2 Targeting Pack

And either:

  • Visual Studio Code
  • Iodine for Visual Studio Code
@s5bug
s5bug / gcd.c
Last active July 11, 2020 01:59
C vs LLVM vs MCFASM
int gcd(int x, int y) {
if(x == y) {
return x;
} else if(x < y) {
return gcd(x, y - x);
} else {
return gcd(x - y, y);
}
}
@s5bug
s5bug / steffwrap.md
Created June 5, 2020 19:04
ScalablyTyped Effect Wrappers Draft

Say we want different flavors of effect wrappings:

  • Cats, over F[_]
  • Cats, over IO
  • ZIO
  • Monix

We introduce an enum for these:

sealed trait EffectWrappingFlavor
@s5bug
s5bug / id.zig
Last active March 27, 2020 03:31
Zig Monad Experiments
pub fn Id(comptime A: type) type { return A; }
pub fn identity(comptime A: type, a: A) A { return a; }
pub fn map(comptime A: type, comptime B: type, a: A, f: fn (_: A) B) B {
return f(a);
}
pub const MonadId = Monad(Id, identity, map);
@s5bug
s5bug / keybase.md
Created April 10, 2019 20:25
keybase.md

Keybase proof

I hereby claim:

  • I am sorenbug on github.
  • I am srnb (https://keybase.io/srnb) on keybase.
  • I have a public key ASCsrFx3MF3RYL9kOXp5kpVYQ4iGPbhpI3makF6lYRqsWQo

To claim this, I am signing this object:

@s5bug
s5bug / .XCompose
Created March 30, 2019 20:47
Greek Alphabet XCompose Extension
<Multi_key> <a> <c> : "α"
<Multi_key> <A> <bracketleft> : "Α"
<Multi_key> <b> <s> : "β"
<Multi_key> <B> <bracketleft> : "Β"
<Multi_key> <y> <y> : "γ"
<Multi_key> <L> <r> : "Γ"
<Multi_key> <d> <d> : "δ"
<Multi_key> <slash> <backslash> : "Δ"
<Multi_key> <e> <s> : "ε"
<Multi_key> <E> <bracketleft> : "Ε"
object Main extends IOApp {
val coordReg = """(\d+) (\d+)""".r
override def run(args: List[String]): IO[ExitCode] = {
implicit val ec: ExecutionContextExecutor = ExecutionContext.global
program[IO].compile.drain.as(ExitCode.Success)
}
def program[F[_]: Monad : ContextShift](implicit ec: ExecutionContext, sync: Sync[F]): Stream[F, Unit] = {
@s5bug
s5bug / fizzbuzz.sc
Last active June 7, 2020 19:59
Scala "Enterprize" Fizzbuzz
import eu.timepit.refined._
import eu.timepit.refined.api.Refined
import eu.timepit.refined.numeric._
import fs2._
def defaultMap[T](implicit numeric: Numeric[T]): Map[T Refined Positive, String] =
Map(
refineV[Positive](numeric.fromInt(3)).right.get -> "fizz",
refineV[Positive](numeric.fromInt(5)).right.get -> "buzz"
)