Skip to content

Instantly share code, notes, and snippets.

View BigCatAccount's full-sized avatar
😺

Max P. BigCatAccount

😺
View GitHub Profile
object MyIteratee{
sealed trait Input[+E] {
}
object Input {
case class El[+E](e: E) extends Input[E]
case object EOF extends Input[Nothing]
}
trait Iteratee[E, A] {
@BigCatAccount
BigCatAccount / fpmax.scala
Created March 2, 2023 14:35 — forked from jdegoes/fpmax.scala
FP to the Max — Code Examples
package fpmax
import scala.util.Try
import scala.io.StdIn.readLine
object App0 {
def main: Unit = {
println("What is your name?")
val name = readLine()
@BigCatAccount
BigCatAccount / RecursionScheme.scala
Created March 1, 2023 16:05 — forked from zliu41/RecursionScheme.scala
Factorial computation with recursion schemes in Scala
import cats.Functor
import cats.implicits._
import scala.language.higherKinds
sealed trait StackR
final case class DoneR(result: Int = 1) extends StackR
final case class MoreR(acc: StackR, next: Int) extends StackR
sealed trait Stack[A]
object Main extends App {
trait Functor[F[_]] {
def map[A, B](fa: F[A])(f: A => B): F[B]
}
sealed trait Nat[A]
final case class Z[A]() extends Nat[A]
final case class S[A](a: A) extends Nat[A]
@BigCatAccount
BigCatAccount / continuation-monad.scala
Created February 23, 2023 15:40 — forked from nanne007/continuation-monad.scala
Continuation Monad in Scala
case class M[+A](in: (A => Any) => Any);
def unit[A](x: A) = M { k: (A => Any) => k(x) }
def bind[A, B](m: M[A], f: A => M[B]): M[B] =
M { k: (B => Any) =>
m.in { x: A =>
f(x).in(k)
}
}
@BigCatAccount
BigCatAccount / Cont.scala
Created February 23, 2023 12:42 — forked from kmizu/Cont.scala
A naive continuation monad implementation in Scala. It is useless. However, it maybe useful to understand continuation monad.
//This implementation is a porting of naive continuation monad in Haskell in "All About Monads" pages.
class Cont[R, +A](val runCont: (A => R) => R) {
def map[B](f: A => B): Cont[R, B] = {
new Cont[R, B](k => runCont(a => Cont.ret[R, B](f(a)).runCont(k)))
}
def flatMap[B](f: A => Cont[R, B]) :Cont[R, B] = {
new Cont[R, B](k => runCont(a => f(a).runCont(k)))
}
}
@BigCatAccount
BigCatAccount / Every possible TypeScript type.md
Created June 22, 2022 04:27 — forked from laughinghan/Every possible TypeScript type.md
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything except never is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@BigCatAccount
BigCatAccount / realfeel.py
Created September 4, 2021 17:10 — forked from mumblepins/realfeel.py
Accuweather Realfeel temperature calculator
# Based on patent https://www.google.com/patents/US7251579
# Not responsible if you use this for anything other than personal use
from math import sqrt
def realfeel(W, #windspeed mph
A, #pressure mb
T, # temperature F
UV, # UV Index
D, # Dew Point F
P2, # preciptation Factor from 0-5
#!/bin/bash
set -u
# Clones and softlinks a git repo, _if needed_.
# Summary of steps:
# 1. Checks that the provided repo is valid (SSH or HTTP)
# 2. Compares local and remote commit to see if there is a new version
# 3. Clones the remote commit in local, adding -<timestamp>-<commit> to the folder name
# 4. Deletes .git directory of the cloned repo