Skip to content

Instantly share code, notes, and snippets.

@angusjf
angusjf / solution.js
Last active October 4, 2023 10:34
A Simplistic TCP Finite State Machine (FSM) - Javascript Solution
/*
The "transition table" from the instructions:
CLOSED: APP_PASSIVE_OPEN -> LISTEN
CLOSED: APP_ACTIVE_OPEN -> SYN_SENT
LISTEN: RCV_SYN -> SYN_RCVD
LISTEN: APP_SEND -> SYN_SENT
LISTEN: APP_CLOSE -> CLOSED
@angusjf
angusjf / nested.html
Last active August 30, 2023 19:17
nested checkboxes w/ indeterminate state
<ul>
<li>
<label><input type="checkbox">Electronics</label>
<ul>
<li><label><input type="checkbox">Laptops</label></li>
<li><label><input type="checkbox">TVs</label></li>
<li>
<label><input type="checkbox">Electronics</label>
<ul>
<li><label><input type="checkbox">Laptops</label></li>
import Data.List
import Data.Fixed
import Graphics.Gloss
import Graphics.Gloss.Data.Color
import Graphics.Gloss.Data.Picture
import Graphics.Gloss.Data.ViewPort
type Vector3 = (Float, Float, Float)
type Model = [Vector3]
@angusjf
angusjf / countryFlagsNamesAndDialCodes.json
Last active October 19, 2023 22:33
Country Emoji Flags, Names and Dial Codes JSON Mapping
{
"ad": {
"flag": "🇦🇩",
"name": "Andorra",
"dialCode": "+376"
},
"ae": {
"flag": "🇦🇪",
"name": "United Arab Emirates",
"dialCode": "+971"
@angusjf
angusjf / bonsai
Last active February 13, 2022 11:08
prints a color text image of a bonsai tree. not mine but i can't remember where i found it
#!/bin/bash
# prints a color text image of a tree
echo -e " \033[0;32m&&"
echo -e " \033[0;32m&&&&&"
echo -e " \033[0;32m&&&\/& &&&"
echo -e " \033[0;32m&&\033[0;33m|,/ |/\033[0;32m& &&"
echo -e " \033[0;32m&&\033[0;33m/ / /_\033[0;32m& &&"
echo -e " \033[0;33m\ { |_____/_\033[0;32m&"
echo -e " \033[0;33m{ / / \033[0;32m&&&"
echo -e " \033[0;33m.\`. \\{___\________\/_\}"
@angusjf
angusjf / bonsai
Last active December 21, 2017 12:34
#!/bin/bash
#prints a color text image of a tree
if [ "$1" = "-slow" ]
then
timer=0.1
else
timer=0.0
fi
echo -e " &&"
sleep $timer
@angusjf
angusjf / makefile
Created March 17, 2017 21:17
A Makefile for lwjgl
all: comp run
comp:
javac -cp "lib/*" -d bin src/HelloWorld.java
run:
# -XstartOnFirstThread is needed for macOS (tells the JVM to use thread 0)
java -XstartOnFirstThread -cp "bin:lib/*" HelloWorld
@angusjf
angusjf / makefile
Created January 20, 2017 10:49
Java Makefile
all: comp run
comp:
javac *.java
run:
java -cp .:+libs/* Main
clean:
rm *.class
fonts.styles {
colors [$WINDOWS||$LINUX] {
basefont "Roboto"
condensed "Roboto Condensed"
medium "Roboto Medium"
}
colors [$OSX] {
basefont "Roboto Regular"