Skip to content

Instantly share code, notes, and snippets.

View James-Ansley's full-sized avatar

James Ansley James-Ansley

View GitHub Profile
@James-Ansley
James-Ansley / questions.sty
Last active November 27, 2022 06:28
Simple LaTeX Question package
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{questions}
\RequirePackage{tcolorbox}
\RequirePackage{comment}
\RequirePackage{kvoptions}
\DeclareBoolOption{problems}
\DeclareBoolOption{solutions}
\ProcessKeyvalOptions*
@James-Ansley
James-Ansley / pi5_fan_controller.py
Last active July 9, 2024 21:05
Raspberry Pi 5 Auto Fan Controller
from enum import Enum
import time
TEMP_PATH = "/sys/devices/virtual/thermal/thermal_zone0/temp"
FAN_PATH = "/sys/class/thermal/cooling_device0/cur_state"
class FanSpeed(Enum):
OFF = 0
LOW = 1
@James-Ansley
James-Ansley / horse.js
Created December 1, 2023 22:27
Adds a horse.
const horse = document.createElement("pre");
horse.innerHTML = `\
.''
._,-、___,' (\`\\
//( ( \`'
'/ )\\ )、__, )
' <' \`\\ ._/\`\\
\` \\ \\\
`
horse.id = "horse";
@James-Ansley
James-Ansley / density_plot.R
Last active February 3, 2024 10:08
A simple density plot generator
library(tidyverse)
#' Returns a beautiful density plot
#'
#' @param data A data frame
#' @param x The x-axis variable as a string
#' @param group_on (optional) The variable to facet-wrap on as a string
#' @param title (optional) The title, if given will append "(n=<n>)"
#' @param limits (optional) a numeric vector of length 2 specifying the min and max values
#' @returns A ggplot2 plot
@James-Ansley
James-Ansley / sections.css
Last active July 20, 2024 00:01
Adds counters to section headings
h2 { counter-increment: h2; counter-reset: h3; }
h3 { counter-increment: h3; counter-reset: h4; }
h4 { counter-increment: h4; counter-reset: h5; }
h5 { counter-increment: h5; counter-reset: h6; }
h6 { counter-increment: h6; }
h2:before { content: counter(h2) ": " }
h3:before { content: counter(h2) "." counter(h3) ": " }
h4:before { content: counter(h2) "." counter(h3) "." counter(h4) ": " }
h5:before { content: counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) ": " }
@James-Ansley
James-Ansley / fortunes
Last active July 19, 2024 09:04
Quotes I like that I've added as Fortunes on my machine
If we have never met Herman but are told that he is 7 feet tall, we can imagine his height in
relation to ourselves without even having seen him.
-- Fenton & Bieman, "Software Metrics"
%
Some acted because they wanted to smash municipal machinery; some because they wanted to
smash something.
-- "Chesterton's Fence: A Lesson in Second Order Thinking"
%
@James-Ansley
James-Ansley / theme.css
Created February 27, 2024 10:57
Common primary/background colours I use so I don't forget
:root {
--primary: #192734;
--primary-alt: #384047;
--background: #f2f2f2;
--surface: #caccce;
}
:root[data-theme="dark"] {
--primary: rgba(255, 255, 255, 0.85);
--primary-alt: rgba(217, 217, 217, 0.85);