Skip to content

Instantly share code, notes, and snippets.

View tomjemmett's full-sized avatar
😀

Tom Jemmett tomjemmett

😀
View GitHub Profile
library(igraph)
library(ggraph)
input <- readr::read_lines("inputs/actual/11.txt")
parse_line <- function(line) {
x <- stringr::str_split(line, ": ")[[1]]
node <- x[[1]]
edges <- stringr::str_split(x[[2]], " ")[[1]] |>
library(lpSolve)
solve_button_problem <- function(buttons, target, costs) {
n_buttons <- nrow(buttons)
n_positions <- ncol(buttons)
constraints_matrix <- t(buttons)
constraints_rhs <- target
constraints_dir <- rep("=", n_positions)
library(tidyverse)
library(sf)
input <- readr::read_lines("inputs/actual/09.txt")
points <- str_split(input, ",") |>
lapply(as.integer)
make_rectangle <- function(p1, p2) {
sf::st_polygon(list(rbind(
c(p1[1], p1[2]),
#' Get Azure Token
#'
#' This function retrieves an Azure token for a specified resource. It first attempts to get a managed token.
#' If that fails, it tries to retrieve a user token using the provided parameters.
#'
#' @param resource A string specifying the Azure resource for which the token is requested.
#' Defaults to `"https://storage.azure.com"`.
#' @param tenant A string specifying the Azure tenant. Defaults to `"common"`.
#' @param app A string specifying the application ID (client ID). If `NULL`, the function attempts to retrieve
#' the app ID from the AzureRMR token or prompts the user to log in to retrieve it.
library(stringr)
library(readr)
i <- read_file("inputs/day03.txt")
f <- function(i) {
str_extract_all(i, "(?<=mul\\()(\\d+),(\\d+)(?=\\))")[[1]] |>
str_split(",") |>
sapply(as.numeric) |>
apply(2, prod) |>
library(tidyverse)
library(janitor)
get_hes_summary_stats_csv <- function(url) {
url |>
readr::read_csv() |>
clean_names() |>
select(-"uid") |>
filter(
library(tidyverse)
library(igraph)
library(tidygraph)
library(ggraph)
input <- read_file("inputs/day25.txt") |>
stringr::str_trim() |>
str_split("\n") |>
pluck(1)
@tomjemmett
tomjemmett / tj-dracula.omp.json
Last active July 23, 2025 13:45
my oh my posh theme
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"final_space": true,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
@tomjemmett
tomjemmett / hrg_chapters.csv
Last active June 14, 2025 20:56
HRG Chapters and Subchapters
code description
A Nervous System
B Eyes and Periorbita
C Ear, Nose, Mouth, Throat, Neck and Dental
D Respiratory System
E Cardiac Surgery and Primary Cardiac Conditions
F Digestive System
G Hepatobiliary and Pancreatic System
H Musculoskeletal System
J Skin, Breast and Burns
@tomjemmett
tomjemmett / bipartite_matching_with_jaccard_similarity.qmd
Last active May 29, 2024 15:34
Fuzzy joining tables using string distance methods
---
title: "Fuzzy joining tables using string distance methods"
format: html
---
```{r setup}
suppressPackageStartupMessages({
library(tidyverse)
library(sf)
library(janitor)