Skip to content

Instantly share code, notes, and snippets.

@Avaq
Avaq / directories-my.sql
Last active February 16, 2019 21:23
Nested Directory Structure in SQL
-- Create our directories table.
CREATE TABLE `directories` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`lft` int(11) NOT NULL,
`rgt` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `directory_lft` (`lft`),
UNIQUE KEY `directory_rgt` (`rgt`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@Avaq
Avaq / algebraic-laws.md
Last active February 19, 2025 09:50
Algebraic Law Cheatsheet

Algebraic Law Cheatsheet

An overview of algebraic laws from the perspective of a functional programmer. I've used a Haskell-esque syntax for the definitions of the laws and examples.

General Laws

name definition example
Identity [¹][] f x = x add 0 42 = 42