commit 5438a7ce3f94ff6b052f7f2b6263beb7100faa9c
parent 91e2aa5fd0cfc64aae22f9e3a9c3060e18f791e7
Author: ling0x <ling0x@users.noreply.github.com>
Date: Thu, 13 Aug 2026 12:33:55 +0100
notes
Diffstat:
9 files changed, 184 insertions(+), 0 deletions(-)
diff --git a/algorithms/combinatorics.txt b/algorithm/combinatorics.txt
diff --git a/algorithms/introduction_to_algorithms.txt b/algorithm/introduction_to_algorithms.txt
diff --git a/algorithms/probability.txt b/algorithm/probability.txt
diff --git a/commands/greek_letters.txt b/commands/greek_letters.txt
@@ -0,0 +1,35 @@
+===============================================================================
+Type Greek Letters Command in archlinux
+===============================================================================
+
+∑
+Ctrl+Shift+U, release, then type 2211, then Enter (or Space).
+
+⋅
+So Ctrl+Shift+U → 22c5 → Enter gives ⋅
+
+Codepoints you probably want
+
+Char Code Use
+⋅ 22c5 dot product / scalar mult (the correct one)
+· b7 middle dot — typographic, not math
+∘ 2218 Hadamard / function composition
+⊙ 2299 Hadamard (element-wise) product
+× d7 cross product
+⊗ 2297 Kronecker / tensor product
+ᵀ 1d40 transpose superscript
+‖ 2016 norm bars
+
+Superscripts
+
+ Chars Codes
+Digits ⁰¹²³⁴⁵⁶⁷⁸⁹ 2070, b9, b2, b3, then 2074–2079
+Signs ⁺ ⁻ ⁼ ⁽ ⁾ 207a 207b 207c 207d 207e
+Useful letters ᵀ ᴴ ⁿ ⁱ ᵏ ᵐ ᵗ ˣ 1d40 1d34 207f 2071 1d4f 1d50 1d57 2e3
+
+Subscripts
+
+ Chars Codes
+Digits ₀₁₂₃₄₅₆₇₈₉ 2080–2089 (contiguous)
+Signs ₊ ₋ ₌ ₍ ₎ 208a 208b 208c 208d 208e
+Letters ᵢ ⱼ ₖ ₗ ₘ ₙ ₚ ᵣ ₛ ₜ ₓ 1d62 2c7c 2096 2097 2098 2099 209a 1d63 209b 209c 2093
diff --git a/commands/psql.txt b/commands/psql.txt
@@ -1,4 +1,14 @@
+==========================================================================
PSQL
+==========================================================================
+
+Connect to remote database:
+
+psql "postgresql://doadmin:PASSWORD@db-postgresql-lon1-12345-do-user-1234567-0.b.db.ondigitalocean.com:25060/defaultdb?sslmode=require"
+
+==========================================================================
+
+Queries:
Show hidden/system schemas:
\dnS
@@ -18,6 +28,8 @@ SELECT nspname FROM pg_namespace ORDER BY nspname;
List all tables via SQL (including system):
SELECT schemaname, tablename FROM pg_tables ORDER BY schemaname, tablename;
+==========================================================================
+
Connect and execute:
psql -h localhost -U myuser -d mydb -c "SELECT * FROM users LIMIT 5"
@@ -26,3 +38,17 @@ psql -h localhost -U myuser -d mydb -c "SELECT * FROM users" --csv > users.csv
Batch Query (no header, comma separated):
psql -h localhost -U myuser -d mydb -t -A -F',' -c "SELECT id, email FROM users"
+
+==========================================================================
+
+Delete multiple things:
+
+BEGIN;
+DELETE FROM git_file_actor_sessions
+WHERE project_id IN (
+ SELECT p.id FROM projects p
+ JOIN departments d ON p.department_id = d.id
+ WHERE d.organisation_id = <org_id>
+);
+DELETE FROM organisations WHERE id = <org_id>;
+COMMIT;
diff --git a/data_structure/stack_and_queue.txt b/data_structure/stack_and_queue.txt
@@ -0,0 +1,31 @@
+===============================================================================
+Stack and Queue
+===============================================================================
+
+Stack is Last In First Out (LIFO) -> suitable for Breadth-first search
+
+Queue is First In First out (FIFO) -> suitable for Depth-first search
+
+---
+
+Depth-first search can be used for recursion.
+
+---
+Queue
+
+Queue is like a linked-list where each element link to the next, so each
+lookup will need to check allocation, i.e. O(n).
+
+To reach index k you start at the head and follow k pointers, so the cost is proportional to k, bounded by n. One traversal, one pass.
+
+Where O(n²) does show up is when you repeat that access in a loop:
+
+for i in 0..n {
+ print(list.get(i)); // each get is O(n)
+}
+
+---
+Vec
+
+Whereas a Vec is like an array with continguous memory allocation, so each
+lookup is O(1)
diff --git a/mathematic/greek_letters.txt b/mathematic/greek_letters.txt
@@ -0,0 +1,14 @@
+===============================================================================
+Greek Letters (Meaning)
+===============================================================================
+
+∑ is the summation sign — capital sigma, Greek for "S", standing for "sum". It's shorthand for "add up a bunch of terms."
+
+ n
+ ∑ aᵢ= a¹+a²+a³+...+aₙ
+i=1
+
+i is the index variable (a counter, like a loop variable)
+i = 1 below the sigma is where the counter starts
+n above is where it ends (inclusive)
+a_i is the term — the thing you evaluate at each value of i
+\ No newline at end of file
diff --git a/mathematics/subdivision-interactive.html b/mathematic/subdivision-interactive.html
diff --git a/memory_management/bump_allocator.txt b/memory_management/bump_allocator.txt
@@ -0,0 +1,76 @@
+===============================================================================
+Bump Allocator
+===============================================================================
+
+A bump allocator (also called an arena or region allocator) is about the
+simplest allocator you can build:
+
+1. You grab one big block of memory up front
+2. hold a pointer into it
+3. and every allocation just aligns that pointer and advances it past the
+ requested size
+
+struct Bump {
+ start: *mut u8,
+ end: *mut u8,
+ ptr: Cell<*mut u8>, // the "bump pointer"
+}
+
+fn alloc(&self, layout: Layout) -> Option<*mut u8> {
+ let cur = self.ptr.get() as usize;
+ let aligned = (cur + layout.align() - 1) & !(layout.align() - 1);
+ let new = aligned.checked_add(layout.size())?;
+ if new > self.end as usize { return None; }
+ self.ptr.set(new as *mut u8);
+ Some(aligned as *mut u8)
+}
+
+---------------
+
+/// Round `addr` up to the next multiple of `align`.
+/// `align` must be a power of two.
+fn align_up(addr: usize, align: usize) -> usize {
+ debug_assert!(align.is_power_of_two());
+
+ // For a power of two, `align - 1` is a mask of the low bits:
+ // align = 8 -> low_bits = 0b111
+ // An address is aligned exactly when those low bits are all zero.
+ let low_bits = align - 1;
+
+ // Clearing the low bits rounds DOWN to a multiple of align.
+ // Adding `low_bits` first turns that into rounding UP,
+ // while leaving already-aligned addresses untouched.
+ (addr + low_bits) & !low_bits
+}
+
+impl Bump {
+ fn alloc(&self, layout: Layout) -> Option<*mut u8> {
+ // Where the next allocation would start, as a plain integer.
+ // (Integers, not pointers, so the arithmetic below has no UB rules
+ // about staying inside one allocated object.)
+ let cursor = self.ptr.get() as usize;
+
+ // Step 1: move the cursor forward until it satisfies the
+ // alignment this type requires. Any bytes skipped are padding.
+ let object_start = align_up(cursor, layout.align());
+
+ // Step 2: work out where the object ends.
+ // `checked_add` guards against a huge `size` wrapping usize around
+ // to a small number, which would sneak past the bounds check below.
+ let object_end = object_start.checked_add(layout.size())?;
+
+ // Step 3: does it actually fit in what's left of the chunk?
+ // `end` is one-past-the-last byte, so landing exactly on it is fine.
+ let chunk_end = self.end as usize;
+ if object_end > chunk_end {
+ return None; // chunk exhausted — caller can grab a new one
+ }
+
+ // Step 4: commit. This is the only mutation; everything above
+ // was just arithmetic that we could still walk away from.
+ self.ptr.set(object_end as *mut u8);
+
+ // The caller's data lives in [object_start, object_end).
+ Some(object_start as *mut u8)
+ }
+}
+\ No newline at end of file