commit 7fd8a5e43f27e39cc419814e56f01f9d24294464 parent c553e487107edf14add19cdaf849c67ac1f69c4c Author: ling0x <ling0x@users.noreply.github.com> Date: Sat, 20 Jun 2026 11:50:53 +0100 refactor Diffstat:
15 files changed, 202 insertions(+), 27 deletions(-)
diff --git a/caching/mem_files.txt b/caching/mem_files.txt @@ -0,0 +1,70 @@ +MemFiles + +An in-memory, editable view of the single file on disk. + +The text is held in a `ropey::Rope` which is an in-memory file tree +that allows cheap inserts and deletes without copying the whole +buffer on every key stroke. + +`MemFile` is the thing an editing session mutates; disk only ever +sees the results of a save. + +pub struct MemFile { + /// The current text of the file, including any unsaved edits. + data: ropey::Rope, + + /// The path on disk this buffer reads from and writes back to. + path: std::path::PathBuf, + + /// Number of single character edits applied since the last save. + /// Reset to zero every time the buffer is flushed to disk. + ops_since_save: usize, +} + ++--------+ +| user 1 |---------------+ ++--------+ | + | ++--------+ +---------------+ +--------------+ +| user 2 |-----------| MemFile |-----| file on disk | ++--------+ | (ropey::Rope) | +--------------+ + +---------------+ (saves every 5 ops) + | ++--------+ | +| user 3 |---------------+ ++--------+ + +*This works exactly like how the virtual DOM in React works. +*ropey::Rope is a utf8 text rope. + + +==================================================================== + +The MemFileGuard owns everyfile an editing session has open in +memory at once. + +pub struct MemFileGuard { + /// The live buffers, keyed by the path each one reads from + /// and writes back to. One entry per file currently open in + /// this session. + pub file_map: HashMap<std::path::PathBuf, MemFile> +} + +==================================================================== + +How the actor gets spun up (the chain UP) + +WebSocket/HTTP API endpoint (e.g. api/files/load.rs) + └─→ Allocator actor git_management/actors/allocator/actor.rs + └─→ register() allocator/processes/register.rs:48 + └─→ git_files_actor_constructor() git_files/actor.rs:364 + └─→ git_files_actor() (the Tokio task) actor.rs:42 + └─→ MemFileGuard::default() actor.rs:91 + +When writing to MemFile: +1. Loads a file from disk into a new in-memory buffer MemFile +2. Insert it into the MemFileGuard +3. Match on transaction's operation type (Insert/Delete/Swap) +4. If its an insert, do insert_char or insert_text on the MemFile +5. Finally, open up the file from disk, write to its buffer, + and then flush it to write to the OS. +\ No newline at end of file diff --git a/commands/yay.txt b/commands/yay.txt @@ -17,3 +17,24 @@ yay -Sc Build from AUR: yay -S --build-deps <package_name> + +==================================================================== + +Go AUR packages: "Permission denied" on cache cleanup +When updating Go-based AUR packages (e.g. nats-server), yay may fail with: + rm: cannot remove '.../gopath/pkg/mod/...': Permission denied + error making: <package>: user defined signal 1 + +Cause: go mod download marks module cache files read-only (444/555). yay's +post-build cleanup cannot rm them, so the build aborts even though compile +may have succeeded. + +Fix before rebuilding: +chmod -R u+w ~/.cache/yay/<package>/src +rm -rf ~/.cache/yay/<package>/src/gopath +yay -S <package> + +Or wipe the whole package cache: +chmod -R u+w ~/.cache/yay/<package> +rm -rf ~/.cache/yay/<package>/src +yay -S <package> diff --git a/health/biomarkers.txt b/health/biomarkers.txt @@ -0,0 +1,33 @@ +Biomarkers + +-------------------------------- +Heart & Circulation +-------------------------------- + +LDL Cholesterol + +Non-HDL Cholesterol + +HDL Cholesterol + +Total Cholesterol + +Apolipoprotein B + +Apolipoprotein A1 + +Apolipoprotein B:A1 ratio + +TC: HDL Ratio + +Tryglycerides + +------------------------------- +Inflamation & Recovery +------------------------------- + +Uric Acid + +Creatine Kinase + +C-Reactive Protein +\ No newline at end of file diff --git a/food/chinese-tomato-chicken-soup.txt b/health/chinese-tomato-chicken-soup.txt diff --git a/food/cinnamon-ginger-tea.txt b/health/cinnamon-ginger-tea.txt diff --git a/food/coffee_and_cacao_comparison.txt b/health/coffee_and_cacao_comparison.txt diff --git a/food/dragon-breath-chai.txt b/health/dragon-breath-chai.txt diff --git a/food/garlic-antibiotic-resistance-and-infections.txt b/health/garlic-antibiotic-resistance-and-infections.txt diff --git a/food/lemony-chicken-green-olives.txt b/health/lemony-chicken-green-olives.txt diff --git a/food/liver-cakes.txt b/health/liver-cakes.txt diff --git a/food/nutrients.txt b/health/nutrients.txt diff --git a/food/pan-fried-king-prawns.txt b/health/pan-fried-king-prawns.txt diff --git a/food/salmon-muffins.txt b/health/salmon-muffins.txt diff --git a/web_development/crdt.txt b/web_development/crdt.txt @@ -0,0 +1,24 @@ +CRDT + +https://www.bartoszsypytkowski.com/the-state-of-a-state-based-crdts/ + +We can discrimitate CRDTs using two core categories: state-based (convergent) and operation-based (commutative) data types. No matter which one we talk about, they all consists of two parts: replication protocol and state application algorithms. + +- Replication Protocol +- State Application Algorithms + +Merge operation must conform to three properties: + +1. Commutativity (x . y = y . x) + +2. and Asociativity ((x . y) . z = x . (y . z)) which means that + we can perform out of order merge operations and still end up + with correct state + +3. Idempotency (x . x = x), so we don't need to care about potential + duplicates send from replication layer + +Those properties are not easy to guarantee, but you're going to see how far we can go only by using two basic operations, which meet those criteria: + +- union of two sets +- maximum of two values diff --git a/web_development/typescript.txt b/web_development/typescript.txt @@ -1,4 +1,5 @@ -# TypeScript +TypeScript +========== Remember, the whole point of using TypeScript is to use its typechecker to stop you from doing invalid things. @@ -8,47 +9,71 @@ TypeScript gives you error messages in your text editor, as you type. But we should use type annotations only when necessary, and let TypeScript work its inference magic for us whenever possible. -## Avoid using `any` as type -`any` makes your value behave like it would in regular JavaScript, and totally -prevents the typechecker from working its magic. When you allow `any` into your -code you're flying blind. Avoid `any` like fire, and use it only as a very very +Avoid using any as type +----------------------- + +any makes your value behave like it would in regular JavaScript, and totally +prevents the typechecker from working its magic. When you allow any into your +code you're flying blind. Avoid any like fire, and use it only as a very very last resort. -## `public` keyword in class constructor -```ts -class Person { - constructor(public firstname: string); -} -``` +public keyword in class constructor +----------------------------------- + + class Person { + constructor(public firstname: string); + } + +public is shorthand for this.firstName = firstName -`public` is shorthand for `this.firstName = firstName` -## Index signatures +Index signatures +---------------- -```ts -let a: { - b: number; - c?: string; - [key: number]: boolean; -}; -``` + let a: { + b: number; + c?: string; + [key: number]: boolean; + }; -The `[key: T]: U` syntax is called an index signature, and this is the way you +The [key: T]: U syntax is called an index signature, and this is the way you tell TypeScript that the given object might contain more keys. -```ts -a = { b: 1, c: "d", 10: true, 20: false }; -``` + a = { b: 1, c: "d", 10: true, 20: false }; For this object, all keys of type T must have values of type U. -## Type Alias + +Type Alias +---------- Type aliases are useful for DRYing up repreated complex types. -## Arrays -TypeScript supports two syntaxes for arrays: `T[]` and `Array<T>`. They are +Arrays +------ + +TypeScript supports two syntaxes for arrays: T[] and Array<T>. They are indentical both in meaning and in performance. + + +JavaScript Generator +-------------------- + +Append a * to function makes it a generator: + + function* countUpTo(max) { + let count = 1; + while (count <= max) { + yield count; // Yield the current count + count++; + } + } + + const counter = countUpTo(3); + console.log(counter.next().value); // 1 + console.log(counter.next().value); // 2 + console.log(counter.next().value); // 3 + console.log(counter.next().value); // undefined