Skip to content

Instantly share code, notes, and snippets.

View BigCatAccount's full-sized avatar
😺

Max P. BigCatAccount

😺
View GitHub Profile
@BigCatAccount
BigCatAccount / curl.md
Created October 1, 2016 04:41 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@BigCatAccount
BigCatAccount / git-branches-by-commit-date.sh
Created January 5, 2017 15:06 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@BigCatAccount
BigCatAccount / linq.scala
Created August 7, 2019 03:31 — forked from SteveBate/linq.scala
Scala LINQ equivalents
// http://stackoverflow.com/questions/8104846/chart-of-ienumerable-linq-equivalents-in-scala
xs.Aggregate(accumFunc) -> xs.reduceLeft(accumFunc)
xs.Aggregate(seed, accumFunc) -> xs.foldLeft(seed)(accumFunc)
xs.Aggregate(seed, accumFunc, trans) -> trans(xs.foldLeft(seed)(accumFunc))
xs.All(pred) -> xs.forall(pred)
xs.Any() -> xs.nonEmpty
xs.Any(pred) -> xs.exists(pred)
xs.AsEnumerable() -> xs.asTraversable // roughly
xs.Average() -> xs.sum / xs.length
#!/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
@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

ELF Format Cheatsheet

Introduction

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

ELF

Compilation

@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.
@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 / 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)
}
}
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]