Skip to content

Instantly share code, notes, and snippets.

View ChaunceyHoover's full-sized avatar

Chauncey Hoover ChaunceyHoover

View GitHub Profile
@ChaunceyHoover
ChaunceyHoover / nanorc
Created June 10, 2021 05:31
My nanorc
## This is a system-wide configuration file for the nano editor.
##
## Each user can save his own configuration to ~/.nanorc
##
## See the nanorc(5) man page for details.
## Sample initialization file for GNU nano.
##
## Please note that you must have configured nano with --enable-nanorc
## for this file to be read! Also note that this file should not be in
@ChaunceyHoover
ChaunceyHoover / minimal-logger.js
Last active July 12, 2021 16:10
My bare minimum logger. Nothing fancy, no extra features, just something to log output with fancy colors.
const { inspect } = require('util');
const chalk = require('chalk');
class Output {
#l = 0;
#c = chalk.grey;
constructor(level, color) {
this.#l = level;
this.#c = color;
@ChaunceyHoover
ChaunceyHoover / US-States.xml
Last active September 15, 2021 18:38
Minimal list of all 50 states in the US with name and abbreviation. Use it for a DataSource in Visual Studio or something idk.
<?xml version="1.0" encoding="UTF-8"?>
<states>
<state name="Alabama" value="AL" />
<state name="Alaska" value="AK" />
<state name="Arizona" value="AZ" />
<state name="Arkansas" value="AR" />
<state name="California" value="CA" />
<state name="Colorado" value="CO" />
<state name="Connecticut" value="CT" />
<state name="Delaware" value="DE" />
@ChaunceyHoover
ChaunceyHoover / US-States.json
Created September 15, 2021 18:40
Minimal list of all 50 states in the US with name and abbreviation. Use it instead of storing it in a database or hard coding it or something idk.
[
{
"name": "Alabama",
"value": "AL"
},
{
"name": "Alaska",
"value": "AK"
},
{
@ChaunceyHoover
ChaunceyHoover / data-align.js
Created October 25, 2021 20:05
Align any given number to the nearest specified amount of bits or bytes
/**
* Returns a number that is n-bits aligned, where n is the number of bits specified
* @param x The input number to be aligned
* @param bits The amount of bits to align the number to
* @returns `x` aligned to the nearest n-bits, where `n` is the specified amount of bits
*/
function alignToBits(x, bits) {
return (x + (bits - 1)) & (-1 * bits);
}
@ChaunceyHoover
ChaunceyHoover / index.js
Created March 23, 2022 20:55
Wordle Solver
// NOTE: requires file "words.txt", which is a JSON array of every possible word guessable (i.e. both answers and valid guesses that will never be answers)
// see next file for word list
const fs = require('fs');
const data = fs.readFileSync('words.txt').toString();
const words = JSON.parse(data);//data.split('\r\n'); // if using 1 word per line
const candidates = [];
// NOTE: Capitalize all letters in these values. I got lazy.
@ChaunceyHoover
ChaunceyHoover / PermissionNode.cs
Last active August 11, 2023 19:46
Period separated, string-based nodes to a C# parent-child / tree-like node list
public class PermissionNode : List<PermissionNode> {
/// <summary>
/// Represents each text-based node inside of a permission string
/// </summary>
public string Key { get; set; }
/// <summary>
/// The original, non-split permission string for this node
/// </summary>
public string Original { get; set; }