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 / test_db_connection.py
Last active May 25, 2023 15:44
Test a database connection given a MySQL connection string
"""
pip install sqlalchemy pymysql
python test_db_connection.py "mysql+pymysql://username:password@dbhost:dbport/db_name"
- mysql+pymysql: This part specifies the type of database and the library (called a "dialect") used to connect to it. In this case, it's MySQL and PyMySQL.
- username: This is the username you use to log into your MySQL database.
- password: This is the password you use to log into your MySQL database.
- dbhost: This is the hostname or IP address of the machine where your MySQL database is running. If the database is running on the same machine where you're running the command, you can use localhost.
- dbport: This is the port number where your MySQL database is listening for connections. The default MySQL port number is 3306.
- db_name: This is the name of the specific database you want to connect to.
@CodeByAidan
CodeByAidan / diff-algorithm.php
Created May 28, 2023 01:06
A nice and easy diff algorithm with PHP. It is used for HTML, and simply you compare 2 strings, and it will substitute a `<del>` tag or a `<ins>` tag, respectively.
<?php
function diff($old, $new) {
$matrix = [];
$maxlen = 0;
foreach($old as $oindex => $ovalue) {
$nkeys = array_keys($new, $ovalue);
foreach($nkeys as $nindex) {
$matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ?
$matrix[$oindex - 1][$nindex - 1] + 1 : 1;
if($matrix[$oindex][$nindex] > $maxlen) {
@CodeByAidan
CodeByAidan / Coding-Ideas.md
Last active August 14, 2023 02:31
Unique Coding ideas - with reasoning and difficulty levels!

Project List

This is a list of projects, along with their descriptions, challenges, benefits, and difficulty levels. The difficulty level is indicated with color-coded badges - red for hard, orange for medium, and bright green for easy.

Project Description Difficulty Why? Tags
Nearest Map Find the map closest to a given country. EX. USA's flag is really similar to Liberia's flag. Hard Enhance your knowledge of geography, AI, and databases. Geography, AI, Database, Cloud, Python, Webdev
What can I do with x amount of money? Create a list of purchasable items for any given amount of money. Easy Learn about OOP and data management while dissuading gambling. Web-Dev, OOP, Python, Javascript, Database, Cloud
Music Genre Classifier Develop a machine learning model to cl
@CodeByAidan
CodeByAidan / fix.cpp
Last active October 6, 2023 04:11
valgrind fixture in c++... `main.py` contains many issues, I fixed all of them based off the `valgrind-warnings.txt`, with the final result in `fix.cpp`
void foo(int a) {
for (int i = 0; i < a; i++) {
int* p = new int;
delete p;
}
}
int main() {
int* y = new int(100);
int x = 0;
@bennyscripts
bennyscripts / discord_soundboard.py
Last active June 18, 2026 01:45
A very basic Python wrapper for Discord's new soundboard feature
import requests
import base64
import mimetypes
class Sound:
def __init__(self, name, sound_id, volume, emoji_id, override_path):
self.name = name
self.id = sound_id
self.volume = volume
self.emoji_id = emoji_id
@CodeByAidan
CodeByAidan / Encoded-Code-Execution.py
Last active August 14, 2023 00:57
This script demonstrates a method of encoding Python code as hexadecimal escape sequences, printing the encoded version, and then decoding and executing it using the `exec()` function.
def get_code_from_file(file_path):
try:
with open(file_path, 'rb') as file:
code = file.read()
except FileNotFoundError:
with open(file_path, 'w') as file:
file.write("print('hello world')")
with open(file_path, 'rb') as file:
code = file.read()
return code
@CodeByAidan
CodeByAidan / Output.txt
Last active August 16, 2023 23:47
Homomorphic Encryption/Decryption with Strings!
[+] Plaintext: Hello world
[+] Binary vectors: ['01001000', '01100101', '01101100', '01101100', '01101111', '00100000', '01110111', '01101111', '01110010', '01101100', '01100100']
[+] Ciphertexts: [(array([ 3296, 13456, 15634, 14777, 10896, 15177, 10592, 13847],
dtype=int64), array([14159, 10964, 15905, 6629, 6274, 12295, 13407, 9354],
dtype=int64)), (array([12139, 16291, 13995, 5986, 8645, 1677, 827, 5064],
dtype=int64), array([15644, 10943, 8481, 11957, 7078, 7555, 5060, 541],
dtype=int64)), (array([ 7409, 5827, 7906, 6283, 14195, 15299, 11102, 14620],
dtype=int64), array([14590, 7627, 12176, 1654, 9491, 112, 14304, 13908],
@CodeByAidan
CodeByAidan / BitwiseAdder.py
Last active August 22, 2023 00:53
Bitwise Adder Visualization using Matplotlib for 18 + 1 = 19
"""
Bitwise Addition: 18 + 1 = 19
Bit A: 1 0 0 1 0
Bit B: 0 0 0 0 1
Sum: 1 0 0 1 1
Carry: 0 0 0 1 0
Result: 1 0 0 1 1
"""
@CodeByAidan
CodeByAidan / NeuralNetwork.py
Created August 25, 2023 22:22
A simple neural network implementation in Python using NumPy and the sigmoid activation function for XOR classification (0, 1, 1, 0) with 100% accuracy.
import numpy as np
from typing import Any
from numpy import dtype, float64, ndarray
class NeuralNetwork:
def __init__(self, input_layer_size: Any, hidden_layer_size: Any, output_layer_size: Any):
self.input_layer_size: Any = input_layer_size
self.hidden_layer_size: Any = hidden_layer_size
self.output_layer_size: Any = output_layer_size
@CodeByAidan
CodeByAidan / Main.java
Created September 29, 2023 17:15
This Java code demonstrates basic object-oriented programming principles. It includes a `Main` class with methods to set and display object properties. The `Helper` class showcases object interaction, highlighting encapsulation and method usage.
public class Main {
int x;
public Main(int x) {
this.x = x;
}
public Main() {
this(10);
}