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 / 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);
@James-Ansley
James-Ansley / fortunes
Last active June 7, 2024 09:02
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"
%
You will go into darkness before your death. When you are stretched out in that little room
with the pain screaming through you like a voice, let me tell you what you will think. First:
"How can man do this to man?" Then "How can God allow it?" Then "There can be no God." The
voice of your pain will grow stronger and your resolution weaker.
@James-Ansley
James-Ansley / sections.css
Created February 5, 2024 23:05
Adds counters to section headings
h2 { counter-increment: h2; }
h3 { counter-increment: h3; }
h4 { counter-increment: h4; }
h5 { counter-increment: h5; }
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 / 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 / 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 / pi5_fan_controller.py
Last active May 27, 2024 10:21
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 / 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*