Skip to content

Instantly share code, notes, and snippets.

View tkshill's full-sized avatar

Kirk Shillingford tkshill

View GitHub Profile
tkshill / minimal_connect_four.ts
Created March 6, 2023 18:16
Minimal version of connect 4 using Generators
// ------------ GAME LOGIC ----------
type Player = "PlayerOne" | "PlayerTwo"
type Maybe<T> = T | null
type Board = Maybe<Player>[][]
type ActiveState = { turn: Player, gameBoard: Board }
type CompleteState = { winner: Maybe<Player>, gameBoard: Board }
type State = ActiveState | CompleteState
tkshill / fibonacci.ts
Created March 6, 2023 18:15
Comparing multiple Fibonacci iterators
const fib = (n: number): number => n === 0 ? 0 : n === 1 ? 1 : (fib(n - 1) + fib(n - 2))
const fibgen = function* (n: number) {
if (n < 0) throw RangeError("number cannot be negative")
if (!Number.isInteger(n)) throw TypeError("number should be an integer")
tkshill / connect_four.ts
Created October 20, 2022 14:25
connect four game logic implementation using js generators
// ------------ GAME LOGIC ----------
You can go Here to run it
tkshill / wordle.elm
Created March 8, 2022 20:56
Wordle clone in Elm
module Main exposing (Model, Msg(..), init, main, subscriptions, update, view)
import Browser
import Debug exposing (log)
import Html exposing (Html, button, div, input, span, text)
import Html.Attributes exposing (class, placeholder, style, value)
import Html.Events exposing (onClick, onInput)
import List.Extra as Liste
import Task
import Time
tkshill /
Created June 7, 2021 23:15
Python 3.10 with Typing and MyPy
from typing import NewType, Literal, Union, Tuple
# Our standard grid is a 2d array of cells that are either a mine
# or not a mine
Mine = Literal["Mine"]
NotAMine = Literal["NotAMine"]
Cell = Union[Mine, NotAMine]
Grid = list[list[Cell]]
# Our annotated grid is a 2d array of cells that are either the number
tkshill /
Last active April 26, 2023 01:11
Solving the Exercism Diamond problem using Haskell


The diamond kata takes as its input a letter, and outputs it in a diamond shape. Given a letter, it prints a diamond starting with 'A', with the supplied letter at the widest point.


  • The first row contains one 'A'.
  • The last row contains one 'A'.
tkshill / Minesweeper.hs
Created April 19, 2021 00:48
Solving the exercism Minesweeper problem with Haskell
module Minesweeper (annotate) where
import Data.Char (intToDigit)
import Data.List.Split (chunksOf)
annotate :: [String] -> [String]
annotate [] = []
annotate [[]] = [[]]
annotate board =
toBoard $ zipWith toOutput flatboard $ bombCounts board
tkshill / _medianarrow.scss
Created December 10, 2020 15:59
this file is fine... until i try to wrap the stuff in a media query
/* MEDIA: only screen and (max-width: 42em), handheld ENDMEDIA */
@media only screen and (max-width: 42em) {
#outer {
background: #fff;
font-size: 0.875em;
position: relative;
h1, h2, h3 {
word-break: break-all;
tkshill /
Last active April 28, 2023 16:50
7 tech talks I love (and Why)

When I just started learning to code I was very obsessed and spent far too much time watching software development videos. I was determined to become the Best Python Developer In The World (don't do this) and I would spend the wee hours of the morning watching programming video after programming video searching for more grains of insight (don't do this either). I wanted to learn the Best Way to write code; the most powerful, idiomatic, robust, resilient, elegant solutions.

That was, in retrospect, not a bad ideal. But the way I went about it may have been a bit silly.

Real working software design is about tradeoffs, and providing solutions, even when those solutions are not as elegant as we would like. And no amount of videos can replace trying your hand at solving a problem. Fortunately I learned this before it was too late.

But I wouldn't call my time spent watching my contemporaries fruitless. Good developers learn from other developers. Whether through videos, articles, courses, pair pr

tkshill /
Last active November 10, 2020 22:21
Advent Of Code 2020 - 25 Language Challenge

The Progenitors

  1. Lisp
  2. C
  3. Smalltalk
  4. Cobol
  5. Ada

The Bash bros