Skip to content

Instantly share code, notes, and snippets.

View innateessence's full-sized avatar

Brenden Rice innateessence

View GitHub Profile
@innateessence
innateessence / hashmap.py
Last active July 4, 2024 19:09
hashmap.py - custom python hashmap
#!/usr/bin/env python3
from typing import Any
# Consider using the same binary approach a `switch` statement in C/C++ uses
class VoidType:
"""
This is designed to mimic the `None` type as closely as possible
@innateessence
innateessence / trace.py
Last active July 3, 2024 01:26
Quick and Dirty custom python tracer ; trace all function calls for only the functions you wrote ; written in less than 10 minutes
#!/usr/bin/env python3
import os
import re
import sys
'''
Example of how to dynamically trace all function calls for your python project, and not any other python code.
use case:
@innateessence
innateessence / compare.ts
Created June 29, 2024 07:26
Javascript is hacky and I wanted a convenient way to compare objects in a predictable way so I wrote this
// Object comparison lib/functions.
// These are intended to behave as one would expect vanilla JS to behave if JS wasn't so hacky.
export const isObject = (a: any): boolean => {
// Strictly check if something is an object.
// Javascript is such a hacky language... -_-
return typeof a === "object" && a !== null && !Array.isArray(a);
};
export const isObjectOrArray = (a: any): boolean => {
@innateessence
innateessence / wikiwand-redirect.js
Created June 29, 2024 07:19
Redirect wikipedia URLs to wikiwand URLs [userscript]
// ==UserScript==
// @name WikiWand Redirect
// @namespace InnateEssense.wikiwand
// @version 0.1
// @description Automatically redirects wikipedia urls to wikiwand for a better UX
// @author InnateEssense
// @license MIT
// @source TODO
// @match en.wikipedia.org/wiki/*
// @icon TODO
@innateessence
innateessence / walmart-colorize-order-fee.js
Created June 29, 2024 07:18
Colorize Walmart Small Order Fee [userscript]
// ==UserScript==
// @name Walmart Colorize Small Order Fee
// @namespace InnateEssense.wallmart-fee-colorizer
// @version 0.1
// @description Automatically colors the minimum order fee red for order under $35 with a $7 fee.
// @author InnateEssense
// @license MIT
// @source TODO
// @match www.walmart.com/*
// @icon TODO
@innateessence
innateessence / bypass-medium-paywall.js
Created June 29, 2024 07:16
Bypass Medium.com paywall [userscript]
// ==UserScript==
// @name Bypass Medium Paywall
// @namespace InnateEssense.bypass_medium_paywall
// @version 0.1
// @description Automatically bypasses medium.com's articles paywalls
// @author InnateEssense
// @license MIT
// @source TODO
// @match medium.com/*
// @icon TODO
@innateessence
innateessence / verify-zeros.sh
Last active June 28, 2024 01:48
Script to verify your storage device is writing bits correctly
#!/usr/bin/env bash
file=${1-zeros}
function write(){
dd if=/dev/zero bs=4M count=1 2> /dev/null > "$file" # Write zeros
}
function verify(){
while IFS= read -r line; do
@innateessence
innateessence / verify-ones.sh
Last active June 28, 2024 01:48
Script to verify your storage device is writing bits correctly
#!/usr/bin/env bash
file=${1-ones}
function write(){
dd if=/dev/zero bs=4M count=1 2> /dev/null | tr "\0" "\377" > "$file" # write ones
}
function verify(){
while IFS= read -r line; do
@innateessence
innateessence / permissions.py
Last active June 18, 2024 23:10
Binary Permission System Snippet
from django.db import models
class Permission:
# Random permissions added here
# Follow binary pattern 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, ...
VIEW = 1
EDIT = 2
EXECUTE = 4
MANAGE_OTHERS = 8
@innateessence
innateessence / useEffect.py
Last active April 25, 2024 21:20
Reacts' useEffect hook, written in python [naive implementation]
#!/usr/bin/env python3
class Observable:
def __init__(self, value):
self._value = value
self._subscribers = []
@property
def value(self):