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 / alyfish.nasm
Created February 29, 2024 20:05
Linux AMD64 ELF
BITS 64
org 0x00010000
ehdr:
db 0x7F, "ELF"
db 2 ; 64 bits
db 1 ; LE
db 1 ; ELF v1
db 0 ; SysV
@s5bug
s5bug / 01a.md
Last active May 9, 2024 03:41
Advent of Code solved in Hex Casting

Accepts input as a list of UTF-32 codepoints and returns a Number.

High-Level

let isNewline: Number -> Boolean =
  (x: Number) -> x == 10

let isDigit: Number -> Boolean =
  (x: Number) -> (x >= 48) && (x < 58)
@s5bug
s5bug / kh2vm_notes.txt
Last active December 26, 2023 04:14
Kingdom Hearts 2 AI VM Language notes
???? ???? ???? 0000:
[TODO: document special cases related to Xemnas]
???? ???? ??0? 0000:
???? ???? ??00 0000 iiii iiii iiii iiii iiii iiii iiii iiii:
load immediate INT
push to TP
???? ???? ??01 0000 ffff ffff ffff ffff ffff ffff ffff ffff:
load immediate FLOAT
push to TP
iiii iiii ii1m 0000 oooo oooo oooo oooo:
@s5bug
s5bug / note.md
Created September 9, 2023 10:26
Inclusive Volume Spell (HexCasting)

High-level Immutable Algorithm

val volumeWithin: (Vec3, Vec3) -> List[Vec3] = (a: Vec3, b: Vec3) -> {
  val Vec3(ax, ay, az) = a
  val Vec3(bx, by, bz) = b
  
  val (minX, maxX) =
    if(ax <= bx) (ax, bx)
    else (bx, ax)
@s5bug
s5bug / 0_initial_brainstorming.md
Last active May 9, 2024 03:41
Hex Casting compiler ideas

Basic Control Flow

Given an arbitrary program:

@main def lcm(a: Int, b: Int): Int =
  if(a < b) (a * (b / gcd(b, a))
  else (b * (a / gcd(a, b))

def gcd(a: Int, b: Int): Int =
  if(b == 0) a
@s5bug
s5bug / 1-fluffy.scala
Last active October 10, 2022 03:34
20 intermediate exercises: Scala edition
// show Fluffy instances
trait Fluffy[F[_]] {
def furry[A, B](fa: F[A])(f: A => B): F[B]
}
// Exercise 1
// Relative Difficulty: 1
implicit def fluffyList: Fluffy[List] = new Fluffy[List] {}
// Exercise 2
@s5bug
s5bug / worksheet.scala
Last active March 8, 2024 19:40
Monads are Monoids in the category of Endofunctors: Scala 3
// Author: Aly Cerruti
// Please follow along in Scastie, so you can see the output of statements:
// https://scastie.scala-lang.org/CLmK5tLuRd6rxXuEnba0rQ
// A Category
trait Category[
// A collection of objects
Obj <: AnyKind,
// A constraint on those objects (Scala lacks dependent typing, so i.e. `Val = [A] =>> Monoid[A]` makes the category of Monoids)
Val[_ <: Obj],
@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