Skip to content

Instantly share code, notes, and snippets.

View jdwebprogrammer's full-sized avatar

JD Web Programmer jdwebprogrammer

View GitHub Profile
@jdwebprogrammer
jdwebprogrammer / byte_address_table.py
Created September 25, 2025 18:40
Big/Little Endian Byte Representation of 0x12345678
import pandas as pd
import matplotlib.pyplot as plt
# Hex value to analyze
hex_value = 0x12345678
# Break into bytes (big-endian order)
bytes_big_endian = [(hex_value >> (i * 8)) & 0xFF for i in range(3, -1, -1)] # [0x12, 0x34, 0x56, 0x78]
bytes_little_endian = bytes_big_endian[::-1] # Reverse for little-endian: [0x78, 0x56, 0x34, 0x12]
@jdwebprogrammer
jdwebprogrammer / number_sys.py
Last active September 25, 2025 18:02
Number Systems: Decimal, Hex, Binary
import pandas as pd
import matplotlib.pyplot as plt
# List of numbers from 0 to 15 with decimal, hexadecimal, and binary representations
numbers = [
(i, f'0x{hex(i)[2:].upper().zfill(2)}', f'{bin(i)[2:].zfill(4)}')
for i in range(16)
]
# Create DataFrame
@jdwebprogrammer
jdwebprogrammer / conversion_table.py
Created September 25, 2025 17:37
A Python script to make Unit Conversions table image
import pandas as pd
import matplotlib.pyplot as plt
# List of common unit conversions
conversions = [
('Length', '1 inch', '2.54 cm'),
('Length', '1 foot', '0.3048 m'),
('Length', '1 mile', '1.60934 km'),
('Length', '1 meter', '3.28084 ft'),
('Length', '1 kilometer', '0.621371 mi'),
@jdwebprogrammer
jdwebprogrammer / metric_table.py
Last active September 25, 2025 17:01
SI Prefixes and Number Notations
import pandas as pd
import matplotlib.pyplot as plt
# List of SI prefixes with symbols and exponents, limited to zetta and below
prefixes = [
('zetta', 'Z', 21),
('exa', 'E', 18),
('peta', 'P', 15),
('tera', 'T', 12),
('giga', 'G', 9),
from CogFileFame import CogName
client = commands.Bot(command_prefix=".", intents=discord.Intents.all(), case_insensitive=True)
@client.event
async def on_ready():
await setup(client)
async def setup(client: commands.Bot):
await client.add_cog(Cogname(client))
@jdwebprogrammer
jdwebprogrammer / gist:837c305383e159dfe6fc8e7d3684dc2b
Created October 2, 2023 21:13
Python script: PNG to ICO Uncompressed
import win32ui
import win32con
import win32gui
from PIL import Image
def png_to_uncompressed_ico(input_file, output_file):
try:
# Open the PNG image
img = Image.open(input_file)
from PIL import Image
def png_to_ico(input_file, output_file):
try:
# Open the PNG image
img = Image.open(input_file)
# Convert it to an ICO icon
img.save(output_file, format="ICO")
@jdwebprogrammer
jdwebprogrammer / gist:9e07c82dbfca82ac041474529a93ab8c
Created October 2, 2023 02:45
Unsupervised ML - Topic Modeling NMF (Non-Negative Matrix Factorization) Class
import numpy as np
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.decomposition import NMF
class NMFTopicModel:
def __init__(self, n_topics=5, max_features=1000):
self.n_topics = n_topics
self.max_features = max_features
self.vectorizer = TfidfVectorizer(max_features=self.max_features, stop_words='english')
@jdwebprogrammer
jdwebprogrammer / gist:8dcdab14b3498d364b4725542ff39df1
Created October 2, 2023 02:44
Unsupervised ML - Topic Modeling LDA (Latent Dirichlet Allocation) Class
import numpy as np
import pandas as pd
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.decomposition import LatentDirichletAllocation
class LDATopicModel:
def __init__(self, n_topics=5, max_features=1000):
self.n_topics = n_topics
self.max_features = max_features
self.vectorizer = CountVectorizer(max_features=self.max_features, stop_words='english')
@jdwebprogrammer
jdwebprogrammer / gist:c0a2773f3ad7e38e01c8e03fe9dfdbf5
Created October 2, 2023 02:41
Unsupervised ML - VAEs (Variational Autoencoders)
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.keras.layers import Input, Dense, Lambda
from tensorflow.keras.models import Model
from tensorflow.keras.losses import mse
from tensorflow.keras import backend as K
class SimpleVAE:
def __init__(self, input_dim, latent_dim):