Skip to content

Instantly share code, notes, and snippets.

View CodeByAidan's full-sized avatar
💻
i love HPC/DL

Aidan CodeByAidan

💻
i love HPC/DL
View GitHub Profile
@CodeByAidan
CodeByAidan / LightningRodBaseCoverage.py
Created September 6, 2024 19:02
just some snippet IPython code to test lightning rod coverage, dimension of base, midpoint of base, on my minecraft base
In [1]: import math
In [2]: #given coordinates of the two corners
...: point_A = (-17.524, 61.000, 19.521)
...: point_B = (8.568, 61.000, -24.552)
In [3]: # Calculate the dimensions of the rectangle
...: length_x = abs(point_B[0] - point_A[0])
...: length_z = abs(point_B[2] - point_A[2])
9036908-dirty
esp32-arduino-lib-builder
06:09:28
Mar 26 2021
v3.3.5-1-g85c43024c
AppCtrl
/littlefs
/.sys
V3.2.17EN
Booting...
@CodeByAidan
CodeByAidan / load-jquery-minified.javascript
Created August 21, 2024 15:03
bookmarklet to load jquery to use in a browser console
javascript:(function(){var script = document.createElement('script');script.src = "https://code.jquery.com/jquery-latest.min.js";document.getElementsByTagName('head')[0].appendChild(script);console.log("jQuery injected");})()
@CodeByAidan
CodeByAidan / lambda_annotate.py
Last active August 20, 2024 20:55
Enforce type checking for a lambda/callable object. Automatically adds a function signature, and doc using dunder/magic methods! (Python 3.12+)
from collections.abc import Callable
from functools import wraps
class typed[T, U]:
"""
A decorator class that enforces type checking for callable objects.
This class takes in a callable and ensures that the arguments passed to the callable
match the specified types. It returns the callable with the same type signature, but
@CodeByAidan
CodeByAidan / get_excel_column_letter.py
Last active August 15, 2024 13:57
Convert column index to Excel column letter
def get_excel_column_letter(col_idx: int) -> str:
letter = ""
while col_idx > 0:
col_idx, remainder = divmod(col_idx - 1, 26)
letter: str = chr(65 + remainder) + letter
return letter
# EX:
# >>> get_excel_column_letter(49)
# 'AW'
@CodeByAidan
CodeByAidan / Discord-Gateway.py
Created August 12, 2024 13:15
Connect to Discord Gateway via websockets. Statically typed, slightly optimized, and color coded.
import asyncio
import json
import logging
from typing import NoReturn
import websockets
import websockets.exceptions
from colorama import Fore, init
init(autoreset=True)
@CodeByAidan
CodeByAidan / int_to_byte_state_machine.py
Last active August 8, 2024 19:19
Int to Byte (big endian) State Machine, in Python, type annotated.
class StateMachine:
def __init__(self, value: int) -> None:
self.value: int = value
self.state = "START"
self.byte_list: list[int] = []
def run(self) -> bytes:
while self.state != "END":
self.transition()
return bytes(self.byte_list[::-1])
@CodeByAidan
CodeByAidan / Center-No-Vert-Bar-H1-H2.md
Last active October 6, 2024 08:34
No vertical bar for h1 and h2 with GitHub Markdown, fixed!

    Hi, I'm Aidan

Keybase proof

I hereby claim:

  • I am codebyaidan on github.
  • I am codebyaidan (https://keybase.io/codebyaidan) on keybase.
  • I have a public key whose fingerprint is 52F2 5B80 BC0F 597C A204 851A FABF 7402 790A 0641

To claim this, I am signing this object:

@CodeByAidan
CodeByAidan / Remove-Duplicates-Path.ps1
Created August 7, 2024 13:29
Remove duplicates entries from your path on windows, using PowerShell.
$semiColon = ';'
$pathArray = $env:PATH -split $semiColon
$uniquePathArray = $pathArray | Select-Object -Unique
$newPath = ($uniquePathArray -join $semiColon)
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::User)
# Verify changes using $env:PATH -split $semiColon | ForEach-Object { $_ }