Skip to content

Instantly share code, notes, and snippets.

View AlphaHot's full-sized avatar


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

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 /
Created August 23, 2022 15:34 — forked from james-d-mitchell/
An implementation of the Todd-Coxeter Algorithm for Semigroups and Monoids in python3
#!/usr/bin/env python3
class ToddCoxeter:
def __init__(self):
self.nodes = [0]
self.edges = None
self.kappa = []
self.next_node = 1
self.R = []
AlphaHot / vimModeStateDiagram.svg
Created November 18, 2021 07:39 — forked from darcyparker/vimModeStateDiagram.svg
Vim Modes Transition Diagram in 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.
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 /
Created February 8, 2020 13:03 — forked from darconeous/
Tesla Key Card Protocol