Skip to content

Instantly share code, notes, and snippets.

View AlphaHot's full-sized avatar
🎯
Focusing

AlphaHot

🎯
Focusing
  • // TODO
  • Canada
View GitHub Profile
@AlphaHot
AlphaHot / Boolean Algebra for Programmers in a Nutshell.md
Created February 27, 2023 08:37 — forked from Ustice/Boolean Algebra for Programmers in a Nutshell.md
Boolean Algebra in a nutshell for JS/TS programmers
View Boolean Algebra for Programmers in a Nutshell.md

Boolean Algebra in a nutshell for JS/TS programmers

There are a lot of strategies that you will hear about in the Javascript community for keeping your conditionals from becoming a tangled mess. This isn't like them. This is someting different. MATH! Boolean Algebra to be exact. I use it all the time to simplify complex conditionals. There are two things that you need to know: de Morgan's Theorem, and Karnaugh (pronounced CAR-no) Maps. (Don't worry, there is no test)

de Morgan's Theorem

De Morgan's Theorem is great distributing nots (!), and for when you want to convert an && to an ||, or back. This is it:

 !(A && B) = !A || !B
@AlphaHot
AlphaHot / todd_coxeter.py
Created August 23, 2022 15:34 — forked from james-d-mitchell/todd_coxeter.py
An implementation of the Todd-Coxeter Algorithm for Semigroups and Monoids in python3
View todd_coxeter.py
#!/usr/bin/env python3
class ToddCoxeter:
def __init__(self):
self.nodes = [0]
self.edges = None
self.kappa = []
self.next_node = 1
self.R = []
@AlphaHot
AlphaHot / vimModeStateDiagram.svg
Created November 18, 2021 07:39 — forked from darcyparker/vimModeStateDiagram.svg
Vim Modes Transition Diagram in SVG https://rawgithub.com/darcyparker/1886716/raw/eab57dfe784f016085251771d65a75a471ca22d4/vimModeStateDiagram.svg Note, most of the nodes in this graph have clickable hyperlinks to documentation.
View vimModeStateDiagram.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View countingBits.py
def cntBit(num):
return len(bin(num)) - 2
print(cntBit(0xFFFFFFFF)) # 32
View efffff.cpp
free_entry **fe;
for (
fe = &first_free_entry;
(*fe)->next &&
(
reinterpret_cast <char *> ((*fe)->next) >
reinterpret_cast <char *> (e) + sz
);
fe = &(*fe)->next
@AlphaHot
AlphaHot / tesla-key-card-protocol.md
Created February 8, 2020 13:03 — forked from darconeous/tesla-key-card-protocol.md
Tesla Key Card Protocol
View tesla-key-card-protocol.md