Skip to content

Instantly share code, notes, and snippets.

View akingdom's full-sized avatar

Andrew Kingdom akingdom

  • Australia
View GitHub Profile
@akingdom
akingdom / maths.md
Last active April 7, 2024 02:27
A few maths (re)discoveries I've made

Some maths[^a] things I've found over the years.

By Andrew Kingdom. (I'll update the details when I have time.)

The four-colour theory states that any map can be coloured in using a maximum of four colours without using the same colour for neighbouring regions. This has been proven using a computer.

My discovery was a partial-geometric method (collapsing all combinations down to a single set of incomplete-shapes) to prove all combinations on paper, which I believe hadn't been done previously. This can also be done using a divided 2D toroidal (donut) shape series, but I'm not 100% sure it covers all possibilies.

@akingdom
akingdom / macos-kill-process.md
Last active March 11, 2024 21:49
Killing processes on MacOS

In MacOS here are two ways to kill processes in one hit. I'll use Google Drive as an example.

List process IDs (optional, useful to query beforehand or verify afterwards):

ps aux | grep "Google Drive" | awk '{print $2}'

Kill:

ps aux | grep "Google Drive" | awk '{print $2}' | xargs kill -9
@akingdom
akingdom / stereograph-swapLR,flipL.html
Created February 21, 2024 16:03
Swap cross-eye-stereograph image halves, optionally flipping one half horizontally. This is useful for incorrectly created stereo images.
<!DOCTYPE html>
<html lang="en">
<!--
HTML/JavaScript
Intent: Swap cross-eye-stereograph image halves, optionally flipping one half horizontally.
This is useful for incorrectly created stereo images.
By Andrew Kingdom
CC-BY license
@akingdom
akingdom / Useful Xcode debugger commands.md
Last active December 17, 2023 11:47
Useful Xcode debugger commands

Useful Xcode debugger commands

Command Description Example
Value Inspection
po Print the value of an expression po myVariable.count
po [object description] Print a detailed description of the object. po [myView debugDescription]
ptype Print the type of an expression ptype myArray
quick look Display a visual preview of an object in the debug pane
kvc path: "<key path>" Access nested properties using Key-Value Coding from the current context kvc path: "user.profile.name"

Source Control - what is it

Term Definition
Source A written recipe (programming code) and ingredients (data resources) from which an app is built.
Version Source Control A way to keep track of all the changes you make and easily go back to any previous version if you make a mistake.
Git A version source control system that distributes a full copy to each developer. Originally created to manage the Linux project.
GitHub One commercial provider of a Git service. Backed by Microsoft.
Repository Storage for all the different versions of your project's files.
@akingdom
akingdom / ReadLine.swift
Last active September 28, 2023 19:27
Read a single line string from a file
// Swift
//
// Intent: Read a single line string from a file, with some memory efficiency.
// This could be improved by use of an (unsafe) memory buffer
//
// By Andrew Kingdom
// MIT license
//
class ReadLineTool {
// Swift
//
// Intent: Process a simple memory-resident ASCII-style string in UTF8 format.
//
// Reads Data as a string, line by line,
// similar to how FileHandle works with a file pointer index.
// There are better ways to do this.
//
// By Andrew Kingdom
// MIT license
@akingdom
akingdom / concertina-collapsible.js
Last active September 19, 2023 08:39
This is an example of implementing headings with collapsible content. This doesn't currently recalculate height if content changes as I don't need that.
// Implements clickable headings with collapsible content.
// This doesn't currently recalculate height if content changes as I don't need that.
//
// Copyright (C) Andrew Kingdom 2023. all rights reserved.
//
// Heading elements must include class 'heading'.
// Content elements must include class 'collapsibleContent' and be the node sibling immediately after the Headiing.
//
//
// If HTML is in a separate file,
@akingdom
akingdom / ColorExtensions.cs
Last active September 7, 2023 07:00
Convert an HTML-style web hexadecimal color string to/from a Unity C# Colour instance. See also Swift version.
// C#
// Color from a web-style hex string
//
// By Andrew Kingdom
// MIT license
//
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;