Skip to content

Instantly share code, notes, and snippets.

View kthompson's full-sized avatar
😀

Kevin Thompson kthompson

😀
View GitHub Profile
type AsyncState<T> = {
status: 'pending'
} | { status: 'resolved', data: T } | { status: 'idle' } | { status: 'rejected', error: unknown }
type AsyncAction<T> = { type: 'pending' } | { type: 'resolved'; data: T } | { type: 'rejected', error: unknown }
const asyncReducer = <T>(state: AsyncState<T>, action: AsyncAction<T>) => {
switch (action.type) {
var lines = File.ReadAllLines("day1.txt");
var state = lines.Aggregate(new State(new ElfCalories(0, 0), new ElfCalories(0, 0)), (state, line) =>
{
if (line == string.Empty)
{
return NextState(state);
}
@kthompson
kthompson / install_stuff.cmd
Last active August 21, 2024 23:01
Install stuff via winget
:: https://www.tenforums.com/tutorials/95008-dism-add-remove-drivers-offline-image.html#Part1
:: https://github.com/microsoft/winget-cli/releases/latest
:: https://www.nerdfonts.com/font-downloads
:: utilities
winget install Microsoft.WindowsTerminal
winget install AgileBits.1Password
winget install DominikReichl.KeePass
winget install 7zip.7zip
type CBool[A] = (=> A, => A) => A
type CNumber[A] = (A => A, A) => A
def ctrue[A](t: => A, f: => A): A = t
def cfalse[A](t: => A, f: => A): A = f
def cond[A](c: CBool[A], x: => A, y: => A): A = c(x, y)
def c0[A](f: A => A, x: A): A = x
import $ivy.`com.lihaoyi::mill-contrib-artifactory:$MILL_VERSION`
import $ivy.`com.lihaoyi::mill-contrib-scoverage:$MILL_VERSION`
import $file.build_lib.AnalyticsLibrary, AnalyticsLibrary._
import $file.build_lib.Dependencies, Dependencies._
import mill._, contrib._, scalalib._, publish._
/** NOTES:
*
* run scoverage with:
@kthompson
kthompson / deepMap.js
Created December 17, 2019 00:50
Rambda.js deepMap
const deepMap = (fn) => R.cond([
[R.is(Array), o => R.map(deepMap(fn))(o)],
[R.is(Object), o => R.compose(fn, R.map(deepMap(fn)))(o)],
[R.T, R.identity],
]);

Keybase proof

I hereby claim:

  • I am kthompson on github.
  • I am mrunleaded (https://keybase.io/mrunleaded) on keybase.
  • I have a public key ASDv2p8r0X-R03ErTG3KbDidhEhHjz_VAzSR7OsqlfNbnwo

To claim this, I am signing this object:

@kthompson
kthompson / install.cmd
Last active March 4, 2020 22:02
Install from cli
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
scoop install sudo
sudo scoop install 7zip git --global
scoop install firefox chrome
:: alacritty
scoop bucket add extras
sudo scoop install extras/vcredist2017
@kthompson
kthompson / SaveWarningsPlugin.scala
Last active July 30, 2018 16:14
SBT Plugin to save warnings to a file as well as cap max warnings for a project
import java.io.{BufferedWriter, FileWriter}
import java.util.Calendar
import sbt.{Def, _}
import sbt.Keys._
import sbt.internal.inc.Analysis
import sbt.plugins.JvmPlugin
import xsbti.Problem
import scala.util.{Random, Try}
@kthompson
kthompson / print_hex.asm
Last active August 15, 2022 15:52 — forked from jsutlovic/print_hex.asm
Assembly print hex
[org 0x7c00]
mov dx, 0x1fb7 ; Set the value we want to print to dx
call print_hex ; Print the hex value
jmp $ ; Hang once we're done
%include "print_string.asm"
; Prints the value of DX as hex.
print_hex: