Skip to content

Instantly share code, notes, and snippets.

View innateessence's full-sized avatar
🏠
Working from home

Brenden Rice innateessence

🏠
Working from home
View GitHub Profile
@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):
@innateessence
innateessence / jest.py
Created April 25, 2024 21:06
jest syntax in python
#!/usr/bin/env python
# desired outcome:
# expect(1).toBe(equal(1)) # True
# expect(1).toBe(equal(2)) # False
# expect(1).toBe(lessThan(2)) # True
# expect(1).toBe(lessThan(1)) # False
@innateessence
innateessence / chainable.py
Last active April 8, 2024 15:32
chainable.py - Implement pipe operator + currying
#!/usr/bin/env python3
'''
Just a fun project one night after work.
I enjoy this syntax.
'''
from typing import Any
from collections.abc import Callable
#!/usr/bin/env python3
'''
This will just keep summoning until you get the desired outcome and give you the stats.
The results are pretty close to what you'd expect, but sometimes it's fun to simulate how much it would take for the desired outcome.
'''
import random
from argparse import ArgumentParser
from random import randint
# http://edspi31415.blogspot.com/2014/01/probability-odds-of-winning-at-slot.html
'''
Just the base logic I wrote for a take home assignment for a potential job
'''
class SymbolsMap:
# Using this structure, if we wanted, we could also display the slot above and below it. as if it was a real slot machine.
#!/usr/bin/env python
'''
This is just a simple script which will scrape a random bible verse
and then send it as a Text Message from your E-mail address.
Throw it in a cronjob or use windows task scheduler to get a daily verse.
destination number must be formatted like this: "{number}@{domain}"
@innateessence
innateessence / rotate-matrix.js
Created November 16, 2022 13:04
rotate a matrix
// started making a tetris game & ran into "How would I rotate this piece?"
// I liked this solution due to it's simplicity, albeit, I'm sure a more mathematical approach would have it's advantages.
// For something like tetris on modern hardware, this should be fine.
// To rotate it to the right, just rotate it left 3x, to rotate 180 degrees, either call it twice or possibly invert the order of the functions
function rotateTetriminoLeft(piece) {
function rows_to_columns(rows) {
let retval = []
for (let i = 0; i < rows.length; i++) {
#!/usr/bin/env python
# A simple python quine.
# A quine being a program which outputs it's source code when ran.
# This sounded more interesting in theory than it really is in practice.
import sys
fname = sys.argv[0]
with open(fname) as f:
@innateessence
innateessence / reloader.lua
Created November 6, 2022 20:29
A lunarvim cofig auto-reloader
M = {}
-- NOTE: Just use the built-in pattern matching instead of this.
-- This basically just parses your root lvim user config file
-- and makes additional autocommands to recompile & reload your
-- configs for lunarvim whenever any nested config files are altered.
-- without this, lvim will require a manual recompile and reload to
-- reflect changes in files other than config.lua (or whatever your root lvim user config file is)
@innateessence
innateessence / lvim.ps1
Last active September 18, 2022 10:58
WSL lvim as Unity External editor
#/usr/bin/env pwsh
# My gist: https://gist.github.com/JackofSpades707/730739e1d85dc6fc3c6eb4a4f1f41e7b
# Inspired by: https://damopewpew.github.io/nvim/wsl/godot/unity3d/vim/2020/02/29/wsl-nvim-as-external-editor.html
Write-Output "[*] Args: $args"
$file=$args[0]
$file=(wsl.exe wslpath "$file")
Write-Output "[*] wslpath: $file"
$basename=(Split-Path "$file" -leaf)