Skip to content

Instantly share code, notes, and snippets.

View aholmes's full-sized avatar

Aaron Holmes aholmes

View GitHub Profile
@aholmes
aholmes / drumeo_10min_exercise.R
Last active June 15, 2023 17:46
Horrible R code to chart Drumeo 10 minute exercise over a month.
# the csv data
# date,2023-04-08,2023-04-09,2023-04-10,2023-04-11,2023-04-12,2023-04-13,2023-04-14,2023-04-15,2023-04-16,2023-04-17,2023-04-18,2023-04-19,2023-04-20,2023-04-21,2023-04-22,2023-04-23,2023-04-24,2023-04-25,2023-04-26,2023-04-27,2023-04-28,2023-04-29,2023-04-30,2023-05-01,2023-05-02,2023-05-03,2023-05-04,2023-05-05,2023-05-06,2023-05-07,2023-05-08,2023-05-09
# 1min,120,120,125,130,130,135,140,145,145,145,146,147,150,152,155,155,156,157,158,158,158,157,158,158,158,158,158,158,160,160,160,161
# 2min,120,120,125,125,126,130,130,132,133,134,135,140,145,150,150,150,152,152,148,148,149,145,150,151,147,145,147,150,151,151,152,153
# 3min,120,120,122,123,125,127,130,131,132,133,135,136,140,140,142,143,144,145,144,145,146,140,146,146,140,135,145,146,146,146,147,148
# 4min,110,120,115,112,120,122,123,125,124,125,126,127,130,133,135,133,135,130,130,131,132,120,133,130,120,120,135,135,136,136,137,139
function(data, which) {
colors <- c("black","red","green","blue")
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
public class MyDictionary<T, V>: Dictionary<(string, T), V>
{
private IEnumerable<(string Name, T Value)> GetMembers(object obj)
{
var properties = obj.GetType().GetProperties(BindingFlags.Public).Select(o => (o.Name, Value: (T)o.GetValue(obj)));
from typing import List, Iterator
from markdown_it import MarkdownIt
from markdown_it.token import Token
class Node:
token: Token|None
nodes: 'List[Node]'
def __init__(self, token: Token|None=None) -> None:
self.token=token
@aholmes
aholmes / chatgpt_compiler.py
Last active December 8, 2022 00:49
A compiler generated by ChatGPT.
# This is a tokenizer, parser, and compiler that has been mostly generated by ChatGPT.
# A handful of errors have been corrected, as well as the addition of the ";" token
# and the ability to write multiple statements in a single line. This last part needed
# to be done by hand because ChatGPT lost the context of the BNF it created somewhere
# along the way, and was not able to regenerate a tokenizer/parser/compiler that
# worked with the original BNF.
#
# 94.42% of this code was created by ChatGPT (see differences.patch for more information).
#
# The conversation can be read here:
@aholmes
aholmes / consoleWrapper.cs
Created November 22, 2022 16:35
Wrapper for System.Console in C#
namespace aholmes.Writer
{
/// <summary>
/// Wraps System.Console
/// </summary>
public class ConsoleWrapper : IConsole
{
/// <inheritdoc/>
public void Write(string value) => Console.Write(value);
/// <inheritdoc/>
import cProfile
from functools import wraps
from logging import Logger
from random import choice
from string import ascii_letters
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any, Callable
@aholmes
aholmes / parsertiming.linq
Created October 11, 2022 00:22
Roslyn parser timing
void Main()
{
var file = @"path to file";
var sw = new Stopwatch();
sw.Start();
var fileContent = File.ReadAllText(file);
sw.Stop();
Console.WriteLine($"Time to read file: {sw.Elapsed.TotalMilliseconds}ms");
const int iterations = 10000;
@aholmes
aholmes / random_bitmap.py
Last active April 12, 2022 16:59
Generate a random black-and-white bitmap.
from math import trunc
from struct import pack
from typing import List
from random import random
def main():
# some hard-coded image attributes
# the width and height are 50 pixels
img_width = 50
@aholmes
aholmes / main.py
Created January 26, 2022 21:48
Behavior of @register in Python
import os
import threading
from multiprocessing import Pool
from atexit import register
from sys import exit
from typing import Union
@register
def term():
print("TERM!")
@aholmes
aholmes / flask_cookie.py
Last active January 22, 2022 00:38 — forked from babldev/decode_flask_cookie.py
Decrypt and encrypt Flask session cookies