### Implement NUnit tests in C# Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Demonstrates basic test class structure with setup and assertion examples. ```cs using System; using NUnit.Framework; public class Tests { [SetUp] public void Setup() { /* do something for setup (optional) */ } [Test] public void NameOfTheTest() { Assert.AreEqual("a", "a"); Assert.AreNotEqual("a", "b"); Assert.IsTrue(true); Assert.IsFalse(false); Assert.Throws(() => { This doesn't throw! }); } } ``` -------------------------------- ### Install chanim plugin Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/custom-objects-and-animations/index.md Command to install the chanim library for chemistry animations. ```text pip install chanim ``` -------------------------------- ### Install local or remote packages Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/intro-to-linux/pacman/index.md Use the -U flag to install packages from a specific file path or URL. ```text sudo pacman -U ``` -------------------------------- ### Install Manim Physics Plugin Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/custom-objects-and-animations/index.md Command to install the manim-physics plugin for physics-based animations. ```text pip install manim-physics ``` -------------------------------- ### Install WhisperX Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/automatic-subtitling-with-python/index.md Install WhisperX from source using pip. Requires CUDA-enabled GPU and PyTorch. ```bash pip install git+https://github.com/m-bain/whisperx.git ``` -------------------------------- ### Install Ollama via Shell Script Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/automatic-subtitling-with-python/index.md Installs the Ollama runtime on Unix-like systems. Review the script content before execution. ```fish curl -fsSL https://ollama.com/install.sh | sh ``` -------------------------------- ### Query package information Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/intro-to-linux/pacman/index.md Use the -Q flag to view details about installed packages. ```text pacman -Q ``` -------------------------------- ### Initialize Manim Physics Example Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/custom-objects-and-animations/index.md Boilerplate import for using the manim-physics plugin. ```python from manim import * # example from https://github.com/Matheart/manim-physics ``` -------------------------------- ### Install or upgrade packages with pacman Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/intro-to-linux/pacman/index.md Use the -S flag to synchronize and install packages from the official repositories. ```text sudo pacman -S vlc # install package sudo pacman -S community/audacity # install package from repository sudo pacman -S xorg-{xprop,xrandr} # install two similar packages ``` -------------------------------- ### Install Bilbo Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/bilbo/index.md Install the Bilbo package using pip. Note that this package includes heavy dependencies like Torch. ```fish pip install bilbo-audiobook ``` -------------------------------- ### Climbing YAML Data Structure Example Source: https://context7.com/xiaoxiae/slama.dev/llms.txt Example structure for the `data/climbing/climbing.yaml` file, organizing climbing sessions, walls, notes, and video details. ```yaml sessions: "2024-01-15": wall: Boulderhaus note: "Great session, sent the yellow project!" blue: new: 2 videos: - file: boulderhaus-blue-2024-01-15-abcdefgh.mp4 attempts: 1 - file: boulderhaus-blue-2024-01-15-ijklmnop.mp4 salmon: new: 1 videos: - file: boulderhaus-salmon-2024-01-15-qrstuvwx.mp4 sotm: true # Send of the month kilter: angle: 40 "V5": new: 1 videos: - file: kilter-V5-2024-01-15-yzabcdef.mp4 ``` -------------------------------- ### Jekyll File Structure Example Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/migrating-from-jekyll-to-hugo/index.md Example of a Jekyll file structure where assets are stored in a separate directory from the content. ```text _posts/ 2024-01-15-chess-...md assets/ └── images/ └── chess-.../ ├── benchmark.png └── cpw.webp ``` -------------------------------- ### Basic Animation in Motion Canvas Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/motion-canvas/introduction/index.md This is an introductory example demonstrating basic animation principles in Motion Canvas. It serves as a starting point for users familiar with Manim. ```typescript import { makeScene2D } from '@motion-canvas/2d'; import { all, delay, easeIn, tween } from '@motion-canvas/core'; export default makeScene2D(function* (view) { const rect = view.add( ); yield rect.position.x(() => -400, 1); yield rect.fill('#000', 1); yield rect.radius(0, 1); yield all( rect.position.x(400, 1, easeIn(0.5)), rect.fill('#ff0', 1, easeIn(0.5)), rect.radius(50, 1, easeIn(0.5)) ); yield delay(1); }); ``` -------------------------------- ### Pointcloud Rendering Example in Python Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/opengl-and-interactivity/index.md This Python snippet is part of an OpenGL example demonstrating pointcloud rendering. It's intended for inspiration and may require further investigation of the source code for detailed usage. ```python ```python {file="06-pointcloud-example.py"} ``` ``` -------------------------------- ### Implement Multi-camera Setup Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/motion-canvas/camera-and-shaders/index.md Configures multiple cameras by rendering a top-level node through Camera.Stage components. ```tsx ```tsx {file="multi-camera.tsx"} ``` ``` -------------------------------- ### Manim Animation Example Source: https://github.com/xiaoxiae/slama.dev/blob/main/layouts/partials/code-tabs.html Displays the source code for a Manim animation project. ```python {{- with .page.Resources.Get .manimFile -}} {{ highlight .Content "python" "" }} {{- end -}} ``` -------------------------------- ### Become Updater Example Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/groups-transformations-updaters/index.md Shows how to use the 'become' function within an updater to transform an object into a completely new one immediately. This differs from 'Transform', which is an animation. ```python from manim import * class BecomeUpdaterExample(Scene): def construct(self): circle = Circle() square = Square() # Updater function to change the circle into a square def become_updater(mob, dt): mob.become(square) self.play(Create(circle)) self.wait(1) # Apply the updater immediately circle.add_updater(become_updater) self.wait(2) circle.remove_updater(become_updater) self.wait(1) ``` -------------------------------- ### Render 3D Axes Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/plotting-and-3d-scenes/index.md Demonstrates the setup of a ThreeDScene with 3D axes. ```python ```python {file="04-axes3d-example.py"} ``` ``` -------------------------------- ### Search algorithm visualization Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/motion-canvas/introduction/index.md Visualizes a search algorithm. This example demonstrates creating arrows using `Line` objects with `startArrow` and using `createRefMap` for easier reference access. ```typescript import { Scene, Layout, Rect, Circle, Txt, Line, waitForRender, createRefMap, } from "@motion-canvas/2d"; export default function* () { const data = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]; const target = 50; const bars = data.map( (value) => new Rect({ height: value, width: 50, fill: "#42a5f5", radius: 5, }) ); const arrows = createRefMap(); const layout = new Layout({ direction: "row", gap: 10, alignItems: "end", }); bars.forEach((bar) => layout.add(bar)); yield* layout.apply(); await waitForRender(); // Linear search visualization (simplified) for (let i = 0; i < bars.length; i++) { const arrow = new Line({ points: [ [bars[i].position.x(), bars[i].bottom() - 20], [bars[i].position.x(), bars[i].bottom() - 50], ], arrow: true, stroke: "#fff", lineWidth: 4, }); arrows.add(arrow); layout.add(arrow); yield* arrow.stroke(1, 0.5); yield* waitForRender(); if (data[i] === target) { bars[i].fill("#ffeb3b"); // Highlight target yield* waitForRender(); break; } yield* arrow.stroke(0, 0.5); yield* waitForRender(); } await waitForRender(); } ``` ```python from manim import * class SearchExample(Scene): def construct(self): # Create a list of numbers nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] target = 50 # Create bars representing numbers bars = VGroup(*[Rectangle(height=num, width=0.5, color=BLUE) for num in nums]) bars.arrange(RIGHT, buff=0.1) self.add(bars) self.wait(1) # Linear search visualization for i, num in enumerate(nums): # Create an arrow pointing to the current bar arrow = Arrow(start=bars[i].get_bottom() + DOWN * 0.5, end=bars[i].get_bottom() + UP * 0.5, buff=0.1, color=WHITE) self.play(Create(arrow)) self.wait(0.2) if num == target: # Highlight the target bar self.play(bars[i].animate.set_color(YELLOW)) self.wait(1) break else: self.play(FadeOut(arrow)) self.wait(2) ``` -------------------------------- ### Render Image Partial Source: https://github.com/xiaoxiae/slama.dev/blob/main/layouts/partials/image.html Usage example for the image partial, requiring a source path and page context. ```Hugo {{ partial "image" (dict "src" "photo.jpg" "page" . "alt" "A photo" "caption" "My caption" "clickable" true "lightbox" true) }} ``` -------------------------------- ### Manim Rate Functions Example Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/camera-and-graphs/index.md Demonstrates the use of various rate functions to control the timing and easing of animations. This allows for fine-tuning the animation's speed and feel. ```python from manim import * class RateFuncExample(Scene): def construct(self): # Example of using a specific rate function square = Square() self.play(square.animate.shift(RIGHT * 2), rate_func=linear) self.play(square.animate.shift(LEFT * 2), rate_func=smooth) ``` -------------------------------- ### C# Ref Parameter Example Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Demonstrates the 'ref' keyword, which passes a variable by reference. This allows the called method to modify the original variable. The parameter must be initialized before being passed. ```cs void Inc(ref int x) { x += 1; } void f() { int val = 3; Inc(ref val); // val will be 4 } ``` -------------------------------- ### Animating object positions with save and restore Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/motion-canvas/introduction/index.md This example shows how to animate objects into their positions within a layout using `save` and `restore` functions to manage absolute positions. ```typescript import { Layout, Rect, Circle, Txt, waitForRender, save, restore, } from "@motion-canvas/2d"; export default function* () { const layout = new Layout({ direction: "column", gap: 20, alignItems: "center", }); const rect1 = new Rect({ size: 100, radius: 10, fill: "#42a5f5", }); layout.add(rect1); const rect2 = new Rect({ size: 80, radius: 10, fill: "#ef5350", }); layout.add(rect2); yield* layout.apply(); yield* rect1.position.y(100, 1, "ease-in-out"); yield* rect2.position.y(-100, 1, "ease-in-out"); yield* save(layout, () => { layout.direction("row"); layout.alignItems("start"); layout.justifyItems("start"); }); yield* restore(layout, 1); await waitForRender(); } ``` -------------------------------- ### Sorting algorithm visualization Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/motion-canvas/introduction/index.md This example visualizes a sorting algorithm using Motion Canvas. It utilizes `useRandom` for deterministic pseudo-random number generation, addressing the lack of seeding in JavaScript's Math.random(). ```typescript import { Scene, Layout, Rect, Circle, Txt, waitForRender, useRandom, } from "@motion-canvas/2d"; export default function* () { const random = useRandom(); const data = Array.from({ length: 10 }, () => random.nextInt(1, 100)); const bars = data.map( (value) => new Rect({ height: value * 5, width: 30, fill: "#42a5f5", radius: 5, }) ); const layout = new Layout({ direction: "row", gap: 10, alignItems: "end", }); bars.forEach((bar) => layout.add(bar)); yield* layout.apply(); await waitForRender(); // Basic bubble sort visualization (simplified) for (let i = 0; i < bars.length - 1; i++) { for (let j = 0; j < bars.length - 1 - i; j++) { if (bars[j].height() > bars[j + 1].height()) { // Swap bars const temp = bars[j]; bars.splice(j, 1); bars.splice(j + 1, 0, temp); yield* layout.apply(); yield* waitForRender(); } } } await waitForRender(); } ``` ```python from manim import * import random class SortExample(Scene): def construct(self): # Generate random numbers nums = [random.randint(1, 10) for _ in range(10)] # Create bars bars = VGroup(*[Rectangle(height=num, width=0.5, color=BLUE) for num in nums]) bars.arrange(RIGHT, buff=0.1) self.add(bars) self.wait(1) # Bubble sort visualization for i in range(len(nums) - 1): for j in range(len(nums) - 1 - i): if nums[j] > nums[j+1]: # Swap numbers nums[j], nums[j+1] = nums[j+1], nums[j] # Swap bars visually bar1 = bars[j] bar2 = bars[j+1] # Animate swap self.play(bar1.animate.move_to(bar2.get_center()), bar2.animate.move_to(bar1.get_center()), run_time=0.2) self.wait(0.05) # Update VGroup arrangement after swap bars.become(VGroup(*bars[j+1], bars[j], *bars[j+2:])) bars.arrange(RIGHT, buff=0.1) self.wait(2) ``` -------------------------------- ### Serve the website locally Source: https://github.com/xiaoxiae/slama.dev/blob/main/README.md Run this command to preview changes locally. Note that the site may appear broken due to missing static assets. ```bash ./site serve ``` -------------------------------- ### Get String Length in C# Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Access the Length property to get the number of characters in a string. ```cs s.Length; ``` -------------------------------- ### Display manual page for a command Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/intro-to-linux/man/index.md Opens the documentation window for the specified command. ```bash man ls ``` -------------------------------- ### Class Constructor Initialization Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Demonstrates how field initializers are translated into constructor bodies. ```cs class A { int x = stuff; A () {} } ``` ```cs class A { A () { int x = stuff; } } ``` -------------------------------- ### Hugo Page Bundle Structure Example Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/migrating-from-jekyll-to-hugo/index.md Example of a Hugo page bundle structure where assets are stored alongside the content file. ```text content/ └── chess-.../ ├── index.md ├── benchmark.png └── cpw.webp ``` -------------------------------- ### Instantiate Objects with Properties Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Syntactic sugar for object initialization using property setters. ```cs A a = new A { x = 3; y = 6 }; // is literally the same as A a = new A(); a.x = 3; a.y = 6; ``` -------------------------------- ### Flexbox layout example Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/motion-canvas/introduction/index.md Demonstrates the use of flexbox layouts in Motion Canvas for arranging elements. This example introduces scene hierarchy and layout nodes. ```typescript import { Scene, Layout, Rect, Circle, Txt, waitForRender, } from "@motion-canvas/2d"; export default function* () { const layout = new Layout({ direction: "column", gap: 20, alignItems: "center", }); const rect1 = new Rect({ size: 100, radius: 10, fill: "#42a5f5", }); layout.add(rect1); const rect2 = new Rect({ size: 80, radius: 10, fill: "#ef5350", }); layout.add(rect2); const rect3 = new Rect({ size: 60, radius: 10, fill: "#66bb6a", }); layout.add(rect3); yield* layout.apply(); await waitForRender(); } ``` -------------------------------- ### Add Climbing Videos to Session Source: https://context7.com/xiaoxiae/slama.dev/llms.txt Adds new videos from the 'videos' folder to the current day's climbing session. Specify the wall name (e.g., Boulderhaus, Crimp). ```bash uv run scripts/climbing.py add Boulderhaus ``` ```bash uv run scripts/climbing.py add Crimp ``` -------------------------------- ### Remove packages with pacman Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/intro-to-linux/pacman/index.md Use the -R flag to remove installed packages from the system. ```text sudo pacman -R ``` -------------------------------- ### Combine Bitboards for Piece Selection in Rust Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/prokopakop/a-chess-engine-commit-by-commit/index.md Demonstrates how to combine bitboards using bitwise operations to efficiently query for specific pieces of a certain color. This is a core technique for fast move generation in chess engines. ```rust self.color_bb[Color::White] & ( self.piece_bb[Piece::Rook] | self.piece_bb[Piece::Bishop]); ``` -------------------------------- ### Binomial Distribution Simulation Solution Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/plotting-and-3d-scenes/index.md Provides the author's implementation for the Galton board simulation. ```python {{< details "Author's Solution" "04-binomial-distribution-simulation.py" >}}{{< /details >}} ``` -------------------------------- ### Define a C# Property Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Standard syntax for defining a property with custom get and set logic. ```cs T Property { get { /* stuff to do */ } set { /* stuff to do (with a variable {{< inline_highlight "cs" >}}value{{< /inline_highlight >}}) */ } } ``` -------------------------------- ### Motion Canvas Animation Example Source: https://github.com/xiaoxiae/slama.dev/blob/main/layouts/partials/code-tabs.html Displays the source code for a Motion Canvas animation project. ```tsx {{- with .page.Resources.Get .mcFile -}} {{ highlight .Content "tsx" "" }} {{- end -}} ``` -------------------------------- ### Training Algorithm Steps Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/introduction-to-machine-learning/index.md Outlines the training loop for a neural network, including initialization, forward pass, backward pass, and weight updates. ```pseudocode 1. init (B_l) randomly (explained later) 2. for t = 1, ..., T 1. forward pass -- for i in batch - z_0 = [1, X_i] - for l = 1, ..., L, compute + store z_l, z_l along the way 2. backward pass: Delta B_l = 0, for i in batch - compute z_L - for l = L, ..., 1, compute - Delta B_l += z_{l - 1}^T * z_l - z_{l - 1} = z_l * (B_l^{(t - 1)})^T * diag(phi'_{l - 1}(z_{l - 1})) 3. update: B_l^{(t)} = B_l^{(t - 1)} - tau Delta B_l ``` -------------------------------- ### Calculate Full Jacobian Matrix Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/robotics-1/index.md The resulting Jacobian matrix for the planar 2D arm example. ```math J = \begin{pmatrix} z_0 \times p_{0,EE} & z_1 \times p_{1, EE} \\ z_0 & z_1 \end{pmatrix} = \begin{pmatrix} -a_1 s_1 - a_2 s_{12} & -a_2 s_{12} \\ a_1 c_1 + a_2 c_{12} & a_2 c_{12} \\ 0 & 0 \\ 0 & 0 \\ 0 & 0 \\ 1 & 1\end{pmatrix} ``` -------------------------------- ### Create and Initialize an Integer Array Statically in C# Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Shows how to declare and initialize an integer array with predefined values directly in the code. This is useful for arrays with known, fixed content. ```cs int[] array = {1, 2, 3}; ``` -------------------------------- ### Clear Pacman Cache Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/intro-to-linux/pacman/index.md Use this command to remove cached packages that are no longer installed. This helps free up disk space. ```text sudo pacman -Sc ``` -------------------------------- ### Create and Use VGroup in Manim Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/groups-transformations-updaters/index.md Demonstrates the creation and basic usage of VGroup for managing multiple mobjects as a single unit. ```python from manim import * class VGroupExample(Scene): def construct(self): # Create some shapes circle = Circle() square = Square() triangle = Triangle() # Group them together group = VGroup(circle, square, triangle) # Position the group group.arrange(DOWN, buff=0.5) self.play(Create(group)) self.wait(2) # Move the entire group self.play(group.animate.shift(RIGHT * 2)) self.wait(2) # Scale the entire group self.play(group.animate.scale(0.5)) self.wait(2) ``` -------------------------------- ### Aligning objects with align_to Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/motion-canvas/introduction/index.md Use `align_to` to align objects based on their anchors. This example shows alignment in Motion Canvas. ```typescript import { Layout, Rect, Circle, Txt, waitForRender, } from "@motion-canvas/2d"; export default function* () { const layout = new Layout(); const rect = new Rect({ size: 100, radius: 10, fill: "#42a5f5", }); layout.add(rect); const circle = new Circle({ size: 80, fill: "#ef5350", }); layout.add(circle); yield* layout.apply(() => { rect.position.x(0); rect.position.y(0); circle.position.x(0); circle.position.y(0); circle.alignTo(rect, "top-left"); }); await waitForRender(); } ``` ```python from manim import * class AlignToExample(Scene): def construct(self): rect = Rectangle(height=2, width=4, color=BLUE) circle = Circle(radius=1, color=RED) circle.align_to(rect, DOWN) self.play(Create(rect), Create(circle)) self.wait(2) ``` -------------------------------- ### Sample Man Page Source (nroff format) Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/intro-to-linux/man/index.md This is a sample man page source file written in nroff format. It includes macro definitions for title, section, name, synopsis, and description. Note that it's auto-generated by help2man. ```text .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.3. .TH LS "1" "March 2020" "GNU coreutils 8.32" "User Commands" .SH NAME ls \- list directory contents .SH SYNOPSIS .B ls [\fI\,OPTION\/\fR]... [\fI\,FILE\/\fR]... .SH DESCRIPTION .\" Add any additional description here .PP List information about the FILEs (the current directory by default). Sort entries alphabetically if none of \fB\-cftuvSUX\fR nor \fB\-\-sort\fR is specified. .PP Mandatory arguments to long options are mandatory for short options too. .TP \fB\-a\fR, \fB\-\-all\fR do not ignore entries starting with . .TP \fB\-A\fR, \fB\-\-almost\-all\fR do not list implied . and .. ``` -------------------------------- ### Positioning objects with move_to Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/motion-canvas/introduction/index.md The `move_to` method positions an object at a specific point. This example demonstrates its use in Motion Canvas. ```typescript import { Layout, Rect, Circle, Txt, waitForRender, } from "@motion-canvas/2d"; export default function* () { const layout = new Layout(); const rect = new Rect({ size: 100, radius: 10, fill: "#42a5f5", }); layout.add(rect); const circle = new Circle({ size: 80, fill: "#ef5350", }); layout.add(circle); yield* layout.apply(() => { rect.position.x(0); rect.position.y(0); circle.position.x(100); circle.position.y(50); }); await waitForRender(); } ``` ```python from manim import * class MoveToExample(Scene): def construct(self): rect = Rectangle(height=2, width=4, color=BLUE) circle = Circle(radius=1, color=RED) circle.move_to(RIGHT * 3) self.play(Create(rect), Create(circle)) self.wait(2) ``` -------------------------------- ### Add and Remove Mobjects from Scene Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/groups-transformations-updaters/index.md Demonstrates adding and removing mobjects from the scene using `add`, `remove`, `bring_to_front`, and `bring_to_back`. ```python from manim import * class AddRemoveExample(Scene): def construct(self): # Create some mobjects circle = Circle(color=BLUE) square = Square(color=RED) # Add them to the scene self.add(circle, square) self.wait(1) # Bring the circle to the front self.bring_to_front(circle) self.wait(1) # Remove the square self.remove(square) self.wait(1) # Add the square back self.add(square) self.wait(1) # Bring the square to the back self.bring_to_back(square) self.wait(2) ``` -------------------------------- ### Constructor Inheritance Compilation Error Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Example of a scenario where a class fails to compile due to a missing parameterless constructor in the base class. ```cs // THIS WON'T COMPILE! class A { public A(int x) { } } class B : A { } ``` -------------------------------- ### Example of Warp Divergence Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/gpu-computing/index.md Illustrates a kernel implementation that causes warp divergence due to conditional branching based on thread index. ```cpp __global__ badKernel (...) { id = threadIdx.x; // not a great idea, use < instead! if ( id % 32 == 0 ) out = complex_function_call(); else out = 0; } ``` -------------------------------- ### StringBuilder Usage in C# Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Use StringBuilder for mutable string operations. Call .ToString() to get a proper string; no copying occurs initially. ```cs .ToString() ``` -------------------------------- ### Git Commit Message Example Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/prokopakop/nnues-and-where-to-find-them/index.md A sample git commit message indicating a change made to prevent the engine from being overly cautious about king safety. ```text * 3d536e8 | 2025-09-30 | xiaoxiae | make the engine not schizophrenic ``` -------------------------------- ### Method Overriding and Hiding with Virtual and New Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/notes/the-cs-programming-language/index.md Illustrates the difference between overriding a virtual method and hiding a method using the new keyword. ```cs class A { public virtual void f() { Console.WriteLine("A"); } public virtual void g() { Console.WriteLine("A"); } } class B : A { public override void f() { Console.WriteLine("B"); } // new is optinal, suppresses a warning public new void g() { Console.WriteLine("B"); } } (new B()).f(); // prints B (new B()).g(); // prints B ((A)(new B())).f(); // prints B ((A)(new B())).g(); // prints A ``` -------------------------------- ### Create and manipulate objects in Manim Source: https://github.com/xiaoxiae/slama.dev/blob/main/content/manim/introduction/index.md Demonstrates the use of method chaining for object creation and transformation in Manim. ```python # this square = Square(color=RED) square.shift(LEFT * 2) # is the same as this square = Square(color=RED).shift(LEFT * 2) ```