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 / 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"
)
@s5bug
s5bug / hello world
Created February 13, 2019 05:15
Scala's hello world as braille
object Main {
def main(args: Array[String]): Unit = {
println("Hello World!")
}
}
object ,main _<
@s5bug
s5bug / speakmid.scala
Last active February 9, 2019 23:24
Script that generates a set of speaker-test commands from a MIDI
import java.io.File
import com.sun.media.sound.StandardMidiFileReader
import javax.sound.midi.spi.MidiFileReader
import javax.sound.midi.{MidiSystem, ShortMessage, Track}
import scala.io.Source
object Main {
@s5bug
s5bug / mega.sh
Last active February 9, 2019 23:10
every day we stray farther from god
note() {
sleep `echo "$1" | bc -l`s
( speaker-test --frequency $2 --test sine )& pid=$!
sleep `echo "$3" | bc -l`s
kill -9 $pid
}
note 0.004883583279477237 293.6647679174076 0.13967048179304897 &
note 0.14504242340047394 293.6647679174076 0.11378749041181963 &
note 0.26664364705945715 587.3295358348151 0.09767166558954474 &