Skip to content

Instantly share code, notes, and snippets.

View warriordog's full-sized avatar

Hazel Koehler warriordog

View GitHub Profile
@warriordog
warriordog / MyProject.cs
Last active December 6, 2022 01:16
This was entirely generated by ChatGPT with just a few minutes of conversation. The only manual change is corrected indentation.
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using SQLServerConnectionTest;
using System;
using System.Data.SqlClient;
using Xunit;
namespace MyProject
@warriordog
warriordog / find-suspicious-logs.mjs
Last active June 15, 2022 16:36
Scan log files for suspicious strings
/* This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* IMPORTANT! This version is outdated!
* This script has been completely rewritten and upgraded, and is now available here: https://github.com/warriordog/little-log-scan
* You should strongly consider using the upgraded version instead of this prototype script.
*/
@warriordog
warriordog / AOC_2020-25.js
Created December 25, 2020 21:52
Solution to Advent of Code 2020 Day 25
const publicKeys = [ 12232269, 19452773 ]; // PROD input
//const publicKeys = [ 5764801, 17807724 ]; // TEST input 1
function runLoop(subject, loopSize) {
let value = 1;
for (let i = 0; i < loopSize; i++) {
value *= subject;
value %= 20201227;
}
return value;
@warriordog
warriordog / AOC_2020-24.js
Created December 24, 2020 23:49
Solution to Advent of Code 2020 Day 24
const INPUT_FILE = 'day24-input.txt';
const DAYS = 100;
/**
* A hash set that provides proper equivalence semantics for any data type.
* For an object type, override the toString() method to return a unique, identifying string.
* Values must be effectively immutable - updates to objects after being stored will NOT be reflected and will result in undefined behavior.
* @template TValue Type of value to store
*/
class MapSet {
@warriordog
warriordog / AOC_2020-23-2_ArrayOnly.js
Created December 23, 2020 18:51
Solution to Advent of Code 2020 Day 23 Part 2, using only an array and no linked list for performance.
//const INPUT = [ 3, 8, 9, 1, 2, 5, 4, 6, 7 ]; // TEST input
const INPUT = [ 1, 6, 7, 2, 4, 8, 3, 5, 9 ]; // PROD input - expect 21986479838
const MOVES = 10000000;
const cups = (function () {
const numbers = Array.from(INPUT);
// init circle
for (let idx = 0; idx < 1000000; idx++) {
let nextIdx = idx + 1;
@warriordog
warriordog / AOC_2020-23-2.js
Last active December 24, 2020 02:26
Solution to Advent of Code 2020 Day 23 Part 2
//const INPUT = [ 3, 8, 9, 1, 2, 5, 4, 6, 7 ]; // TEST input
const INPUT = [ 1, 6, 7, 2, 4, 8, 3, 5, 9 ]; // PROD input
const MOVES = 10000000;
/**
* @typedef {object} Cup
* @property {number} label
* @property {Cup} clockwise
* @property {Cup} counterClockwise
*/
@warriordog
warriordog / AOC_2020-23-1.js
Created December 23, 2020 16:45
Solution to Advent of Code 2020 Day 23 Part 1
//const INPUT = [ 3, 8, 9, 1, 2, 5, 4, 6, 7 ]; // TEST input
const INPUT = [ 1, 6, 7, 2, 4, 8, 3, 5, 9 ]; // PROD input
const MOVES = 100;
/**
* @typedef {object} Cup
* @property {number} label
* @property {Cup} clockwise
* @property {Cup} counterClockwise
*/
@warriordog
warriordog / AOC_2020-22-2.js
Created December 22, 2020 15:42
Solution to Advent of Code 2020 Day 22 Part 2
const INPUT_FILE = 'day22-input.txt';
// Load dependencies and utilities
const { Axis } = require('../utils/axis');
const NodeFS = require('fs');
// Parse input
const initialPlayers = NodeFS.readFileSync(INPUT_FILE, 'utf-8').split(/(?:\r{2}|\n{2}|(?:\r\n){2})/g)
.map(player => Axis.from(player.split(/(?:\r\n|\r|\n)/g).slice(1).map(card => parseInt(card.trim()))))
;
@warriordog
warriordog / AOC_2020-22-1.js
Created December 22, 2020 15:41
Solution to Advent of Code 2020 Day 22 Part 1
const INPUT_FILE = 'day22-input.txt';
// Load dependencies and utilities
const { Axis } = require('../utils/axis');
const NodeFS = require('fs');
// Parse input
const players = NodeFS.readFileSync(INPUT_FILE, 'utf-8').split(/(?:\r{2}|\n{2}|(?:\r\n){2})/g)
.map(player => Axis.from(player.split(/(?:\r\n|\r|\n)/g).slice(1).map(card => parseInt(card.trim()))))
;
@warriordog
warriordog / AOC_2020-21.js
Created December 21, 2020 13:50
Solution to Advent of Code 2020 Day 21
const { parseInputFile } = require('../utils/parser');
const INPUT_FILE = 'day21-input.txt';
/**
* @typedef {object} Food
* @property {string[]} ingredients
* @property {string[]} allergens
*/