Exploring Reachability in Directed Graphs with Haskell
Exploring Reachability in Directed Graphs with Haskell Graphs are a natural way to represent systems of connections — from flight networks to dependencies in code or social networks. In directed graphs, edges have a direction, and not all nodes may be reachable from one another. This brings up a fascinating question: From which nodes can we reach all others? To explore this, I wrote a Haskell function that recursively discovers all directed paths in a graph, and identifies the nodes that can reach every other node. 1. The problem Given a directed graph represented as a pair ([nodes], [(from, to)]), we want to: Find all traversal paths starting from every node. Keep only the nodes that can reach all others. The function should therefore output a list of path groups…
functional-programmingHow Do They Display Trees — Three Layout Algorithms in Haskell
When you visualize data structures in a GUI — such as decision trees, syntax trees, or even neural networks — one key algorithmic problem hides behind the scenes: How do you determine where to draw each node? Many libraries in higher-level languages (like Python’s data science tools or visualization frameworks) rely on carefully designed tree layout algorithms to assign 2D coordinates to nodes. Problems 64 to 66 from the 99 Haskell Problems explore exactly that: how to compute node coordinates for different layout styles. In this article, we’ll go through three classic methods of visualizing trees — each one balancing symmetry, spacing, and readability differently. Here are the 3 type we'll discover: 1. Layout Algorithm #1 — Inorder Positioning (Problem 64) The first method assigns each node’s position based on…
functional-programmingConstructing All Spanning Trees in Haskell (Problem 83)
In graph theory, a spanning tree of a connected graph is a subgraph that includes all the nodes of the original graph, connected with the minimum number of edges (exactly n − 1 for n nodes) and without any cycles. I discovered this concept through Problem 83 of the 99 Haskell Problems series. The goal is to construct, by backtracking, all spanning trees of a given graph, and then use that logic to check if a graph is a tree or if it’s connected. 1. The problem Write a function spanningTree that constructs (by backtracking) all spanning trees of a given graph. Once we have that, we can easily define two related functions: is_tree(Graph) — determines if a graph is a tree. is_connected(Graph) — determines if a graph is connected.…
functional-programmingGraph Isomorphism in Haskell (Problem 85)
Graph isomorphism is one of the classic challenges in graph theory and computer science. It involves determining whether two graphs have the same structure — that is, whether one can be transformed into the other simply by relabeling its nodes. I first encountered this problem through the 99 Haskell Problems, specifically Problem 85. It’s an elegant exercise that brings together recursion, list manipulation, and combinatorics. 1. The problem Two graphs G₁(N₁,E₁) and G₂(N₂,E₂) are isomorphic if there exists a bijection f : N₁ → N₂ such that for any nodes X, Y ∈ N₁, X and Y are adjacent if and only if f(X) and f(Y) are adjacent. In other words, two graphs are isomorphic if they are structurally identical, regardless of how their nodes are labeled. Example Copy λ>…
functional-programmingIntroduction to Graph Theory in Haskell
Graph theory is one of the most fascinating areas of computer science and mathematics, forming the foundation for countless real-world applications: from social networks and routing systems to dependency trees in compilers. When learning Haskell, I was first introduced to graph theory through the 99 Haskell Problems — a collection of exercises that gradually expose you to elegant and expressive functional patterns. Problem 81, in particular, focuses on finding all acyclic paths between two nodes in a directed graph. 1. The challenge The problem is simple to state: Given two nodes a and b in a directed graph, return all possible acyclic paths from a to b. For example: Copy λ> paths 1 4 [(1,2),(2,3),(1,3),(3,4),(4,2),(5,6)] [[1,2,3,4],[1,3,4]] λ> paths 2 6 [(1,2),(2,3),(1,3),(3,4),(4,2),(5,6)] [] 2. Representing a graph in Haskell Before diving…
functional-programmingImplementing Huffman Encoding in Haskell
Huffman encoding is one of the foundational algorithms in data compression — elegant, efficient, and entirely based on simple mathematical principles. It converts symbols and their frequencies into binary codes where the most frequent symbols receive shorter codes. The algorithm is used in many compression systems, including ZIP and JPEG, and fits naturally into functional programming thanks to its recursive and tree-based nature. In this project, I implemented Huffman coding in Haskell from scratch. The goal was to explore tree construction, recursion, and symbol encoding rather than optimize for absolute performance. Interestingly, depending on input characteristics, my approach sometimes generates a code table that uses slightly fewer bits than a classic implementation — but that is highly input-dependent. 1. The problem setup Given a set of symbols and their frequencies:…
defaultThe Goldbach Conjecture and Its Recursive Implementation in Haskell
The Goldbach Conjecture is one of the oldest unsolved problems in mathematics. It states that every even integer greater than 2 can be expressed as the sum of two prime numbers. While no formal proof has been found, the conjecture has been verified by computers for very large numbers. In this post, we’ll explore how to express this idea recursively in Haskell — using an elegant search through the space of prime pairs. 1. Restating the problem For any even number x > 2, find two primes p1 and p2 such that: Copy p1 + p2 = x For example: 4 = 2 + 2 6 = 3 + 3 10 = 5 + 5 or 7 + 3 The challenge is to find such a pair efficiently — and…
functional-programmingUnderstanding Recursion Through Combinations, Permutations, and Trees in Haskell
Recursion often feels like a mysterious concept when you first encounter it — until you realize that it’s not about doing something repeatedly, but about breaking a problem into smaller, self-similar parts. In this post, we’ll explore how recursion allows us to generate combinations, random permutations, and even manipulate trees and graphs elegantly in Haskell. To begin, here’s how I once described it: “So when my program makes its first recursive call, what does it actually do? Does it launch another recursive call with a different input?” The answer is yes — it destructures the input string, taking its first element, say “a”. If we follow only that first recursive call, it will generate “abc”. But notice that when it took “a”, it also made another recursive call — this…
functional-programmingFinding the Optimal Path in Haskell: A Recursive Exploration
I will explain from my point of view the solution to the following problem here, we explore a recursive approach to solving an optimal path problem — where at each step, multiple paths are possible, and we must decide which route minimizes the total cost. The idea is to think of the problem as a sequence of blocks — each representing a segment of possible movements. Between these blocks, we must choose how to transition optimally while keeping track of cumulative costs along each possible path. 1. The block model and mental picture We can think of the system as three tracks: A, B, and C. Each block of the path has three values representing the cost of traveling along each of these tracks (or switching between them). We define…
functional-programmingUnderstanding the Haskell Type System: From Typeclasses to Data Structures
In this tutorial — inspired by my video “Structure de données et système de types en Haskell” — we dive into the heart of what makes Haskell so expressive: its type system. This article targets an intermediate audience: you already know what a function or a list is, but now you want to understand why types in Haskell feel so different — and powerful — compared to other languages. 1. Why types matter in Haskell In Haskell, types are not just annotations — they are first-class citizens that define how values behave and interact. The compiler (GHC) uses types to enforce correctness, optimize performance, and even help you reason about your program. Every value in Haskell has a type, and Haskell’s compiler infers those types automatically. But you can (and…
functional-programmingUnderstanding Parenthesis Tokenization in Haskell
Context Before building a full arithmetic calculator in Haskell, there was one key challenge I needed to solve first: understanding and tokenizing parentheses. Parenthesis tokenization may sound like a small detail, but it’s actually a necessary step for building my own calculator interpreter — the engine that later evaluates nested expressions like (3+(2*(5-1))) correctly, respecting operator precedence and nesting depth. 1. Why tokenization matters In an arithmetic expression, parentheses determine the order in which subexpressions are evaluated. To process them properly, a calculator must: Recognize where every ( and ) occurs Track how deeply nested each one is Know which pairs of parentheses match together Once we have this information, we can safely evaluate the innermost expressions first and work our way out — exactly how human math logic works.…
functional-programmingBuilding a Tiny Reverse Polish Notation (RPN) Calculator in Haskell
In this project, we’ll build a small expression evaluator using Reverse Polish Notation (RPN) — also called postfix notation. The idea is simple: instead of writing 3 + 4, you write 3 4 +. This lets you evaluate expressions without worrying about parentheses or operator precedence. The project is a fun and compact way to learn about: Recursion Pattern matching List manipulation with foldl Function composition 1. The goal We want a function that can take a string like "3 4 +" and return 7.0. Or more complex ones like "2 3 4 + *" → 14.0. We’ll also add support for basic arithmetic, powers, exponentials, logs, and even a factorial! 2. The full code Copy primitiveSolver :: String -> Double primitiveSolver expr = head . foldl funcNPI [] .…
functional-programmingLearning Haskell with Weird Goals
Sometimes, the best way to learn a language is by using a simple, even slightly “weird” goal as an excuse to explore its core concepts. Here, the goal is to extract the sides (apart from the hypotenuse) from a list of Pythagorean triples—but really, it’s just a reason to learn how pattern matching, recursion, and let blocks work in Haskell. 1. A simple pattern-matching refresher In Haskell, you can deconstruct tuples directly in function arguments. It’s an elegant and expressive way to “take apart” data structures. Let’s define three simple functions to get each element from a 3-tuple: Copy myFst :: (Int, Int, Int) -> Int myFst (x, _, _) = x mySnd :: (Int, Int, Int) -> Int mySnd (_, x, _) = x myThrd :: (Int, Int, Int)…
functional-programmingBrute-forcing Pythagorean Triples with Haskell List Comprehensions (up to 100)
We want all integer solutions (a,b,c) to the equation a^2 = b^2 + c^2 with 0 < a < 100. This is a great place to use Haskell’s list comprehensions: they’re concise, readable, and—when bounded carefully—surprisingly efficient. The goal (and a small symmetry trick) We’re after triples (a,b,c) that satisfy: a^2 = b^2 + c^2 0 < a < 100 to avoid duplicates from swapping legs, we enforce ordering: c < b < a That last line is key: every valid solution has one leg greater or equal to the other, so we arbitrarily choose b to be the larger leg and enforce c < b. This removes mirrored duplicates. Important list comprehension fact In a Haskell list comprehension, a variable can be used only if it’s defined earlier in…
software-computational-architectureA Structured, Visual Algorithm for Determinants up to 5×5
1. Introduction Determinants are fundamental objects in linear algebra, yet direct computation beyond 3×3 can be tedious. This article presents a structured, visual algorithm I designed in two days of focused exploration. It offers a systematic way to compute determinants of matrices up to 5×5 by enumerating 2×2 sub-determinants revealed through a simple column-exclusion scheme. Colored lines in accompanying diagrams denote columns that are “occupied” (i.e., excluded), guiding a stepwise traversal that is easy to follow by hand or implement in code. You can get the algorithm implementation in R here 2. Core Idea: Occupied Columns and 2×2 Submatrices The method is built on a concise principle: at the moment we form a 2×2 submatrix inside an n×n matrix, exactly n − 2 columns are excluded. Graphically, each exclusion is…
recreational-programmingTurning Blog HTML into RSS, the Low-Level Way (in C++)
If you publish long-form posts on the web, you’ve probably felt the friction of keeping your RSS feed in sync. I did too. So I wrote a tiny command-line tool in C++ that converts a finished blog post page (the raw HTML file itself, not just the body) into a ready-to-drop <item> block for your RSS feed. Because yes—CLI is fun, and C++ is low-level, baby. 🛠️ TL;DR What it does: Reads a full raw blog HTML page (not just the body) → emits a valid RSS <item> XML snippet. Why it’s useful: No separate markdown front matter or duplication. Your source of truth is the rendered page. How to use: ./a.out post.html rss.xml "My Title" "https://example.com/post" "2025-10-04" Where it lives: github.com/julienlargetpiet/automate_rss The Problem An RSS feed wants clean metadata…
recreational-programmingA New Way to Explore Your System on Linux
On Linux, productivity often comes from small but powerful tools. dmenu and rofi are great examples: minimalist application launchers that make your desktop more efficient. But I wanted to go further. Instead of just launching programs, what if I could explore my system, run scripts, and interact with the shell — without opening a terminal? That’s how I created dmenu_all, an extensible, open tool that transforms dmenu into a universal system navigator. What It Does Browse your files: Navigate directories quickly through a dmenu-driven menu. Launch applications: Use it like a classic launcher. Run scripts: Define your own actions and execute them from the same interface. Chain commands: Build workflows without typing shell commands manually. In short, dmenu_all makes dmenu (or rofi) a hub for your daily Linux tasks. How…
recreational-programmingAutomating YouTube Video Imports into My Website with One Magic Bash Line
Over the past months I’ve been downloading my own YouTube videos with yt-dlp. It’s a fantastic tool for archiving, and I’ve built up a folder full of .mp4, .webm, and .mkv files. But here’s the boring part: every time I wanted to put those videos on my personal website, I had to manually write <a> tags for each one. Copying file names, escaping spaces, renaming stuff… too much grunt work. So I decided to automate it. And the result is this single, magic line of Bash: Copy $ find . -type f \( -name "*.webm" -o -name "*.mp4" -o -name "*.mkv" \) -printf "%P\0" | xargs -0 -n1 bash -c 'X="$1"; clean=$(echo "$X" | sed "s/ /_/g"); echo "<a href="/assets/common_files/$clean">$X</a><br>"' X1 Breaking Down the Magic find . -type f \(…
recreational-programmingBuilding My Own Parser in R - A Custom Syntax Experiment
This was one of my older projects, a little bit eccentric but very educational. I wanted to see if I could design and implement a parser from scratch in R, complete with a brand-new syntax and functions to both read and write data. The project is part of my old data manipulation library written in R avaiable on this repo It wasn’t about reinventing JSON, XML, or YAML — it was about learning how parsing works at a low level, handling nested structures, and building a system that’s flexible enough to store and retrieve hierarchical data. The Custom Syntax I invented a compact bracket-based format to represent hierarchical data. It looks like this: Copy (ok(ee:56)) (ok(oui(rr((rr2:6)(rr:5))))(oui(bb(rr2:1)))(ee1:4)) The rules are simple: Each node is wrapped in parentheses (...). A node may…
system-designBuilding InFoEnd: An End-to-End Encrypted Chatroom in Go
InFoEnd is my first experiment with building a secure chatroom application in Go. The goal: create a real-time messaging system where messages are encrypted end-to-end, such that even the server cannot read them. To make it feel like a proper client, not just a toy, I added a terminal UI using the tview library and relied on the WebSocket protocol for message transport. The result is a multi-room chat platform that demonstrates encryption, networking, and terminal UI in one place. Architecture Overview The system consists of two roles: Admin (server) and Clients. Illustration images Server (Admin) Responsible for creating chatrooms. For each room, generates a unique 32-byte AES key. Distributes this AES key securely to clients via their RSA public keys. Once all clients of the chatroom have handshaked with…
defaultReimplementing diff in C++: A Minimalist Approach
Why Rebuild Something That Already Exists? The diff command is one of the cornerstones of the GNU/Linux ecosystem. It’s simple in appearance, yet behind the scenes it powers version control, code reviews, and collaborative software development. I wanted to reimplement diff myself — not because the world needs another diff tool, but because it’s a great exercise in understanding how file comparison works at a low level. Writing it from scratch in C++ forced me to think about edge cases, data handling, and performance, even for what seems like a “trivial” utility. Defining the Scope The real diff command is sophisticated. It can produce unified diffs, context diffs, side-by-side comparisons, and even patch-friendly outputs. My goal wasn’t to replicate all of that. Instead, I set out to create a minimalist…
defaultAutomatic Documentation for Any Codebase
When working with R, I loved how Roxygen lets you generate clean documentation directly from comments in your source code. But I often wished there was something similar for every language, not just R. That’s why I built simple_doc: a lightweight documentation tool that works on any codebase. The Idea Instead of maintaining separate README files, wiki pages, or doc websites, you can write structured comments directly in your code. simple_doc then parses those comments and generates clean, human-readable documentation automatically. How It Works In your code, you add special annotations (inspired by Roxygen style): Copy // @T dcauchy // @U std::vector<double> dcauchy(std::vector<double> // @U &x, double location = 0, double scale = 1) // @D Returns the probability distribution of the Cauchy distribution. // @A x : vector of…
software-computational-architectureReimplementing Cross-Validation for KNN in R (from Scratch)
After reimplementing K-Nearest Neighbors (KNN) from scratch, I wanted to take things a step further: build a cross-validation system entirely in base R. This meant re-creating folds, evaluating accuracy across them, and tuning both k (the number of neighbors) and the training proportion. No caret, no external frameworks — just my own code. The Fold Function The first step in cross-validation is creating training/test splits. For this, I wrote v_Rmach_fold, which generates n_fold pairs of train/test datasets. Each sample is stored in a small S4 class sample_Rmach with: train: the training dataframe test: the testing dataframe train_ids: row indices used for training test_ids: row indices used for testing Copy lst_test <- v_Rmach_fold(inpt_datf = iris[1:25,], train_prop = 0.7, n_fold = 4) print(lst_test$sample1@train) # Training set print(lst_test$sample1@test) # Test set This function…
software-computational-architectureReimplementing K-Nearest Neighbors (KNN) from Scratch in R
As part of my exploration of machine learning fundamentals, I decided to reimplement classic algorithms from scratch instead of relying directly on existing libraries. One of the first I tackled was K-Nearest Neighbors (KNN), a simple yet powerful classification method. Why KNN? KNN is often one of the first algorithms taught in machine learning because it’s intuitive: To classify a new point, look at the k closest points in your training data. Assign the most common class among those neighbors. No training phase, no model building — just distance comparisons. This makes it perfect for reimplementing from scratch. The Implementation I called my implementation knn_Rmach. It works with R data frames, allowing you to specify which columns are variables and which is the classification column. It also supports both numeric…
software-computational-architectureOptimizing the Exponential Function in Cherubin
Cherubin is my C++ library for computing very large numbers represented as strings. One of the hardest functions to implement efficiently in this context is the exponential exp(x). A naïve implementation using the Taylor series converges slowly, requires repeated big-number multiplications and divisions, and becomes impractical very quickly. With chexp3, I managed to dramatically reduce the execution time of the exponential function by splitting the input into its integer part and fractional part, and computing them separately. This way, the function avoids huge Taylor expansions and only uses lightweight operations when needed. The Optimization Strategy Here’s the core idea of chexp3: Step 1 — Separate integer and fractional parts: The input x (as a string) is split into partint and partflt. Example: x = "12.34" → partint = "12", partflt…
software-computational-architectureReimplementing the Cauchy Distribution in Fulgurance (C++ Statistics Library)
Introduction Fulgurance is my C++ statistics library where I reimplemented several probability distributions from scratch, including the Cauchy distribution. The goal of Fulgurance is to provide flexible statistical tools in modern C++, without relying heavily on external libraries. It’s also a playground to explore how distributions work internally, both mathematically and computationally. Why Reimplement Cauchy? The Cauchy distribution is a well-known heavy-tailed distribution, often used in physics, Bayesian inference, and robustness testing. Unlike the normal distribution, its mean and variance are undefined — which makes it a good candidate to test statistical implementations. Rebuilding it from scratch in C++ was a great exercise in both numerical computation and random number generation. The Four Building Blocks 1. dcauchy — Density Function The probability density function (PDF) of the Cauchy distribution is:…
software-computational-architectureCheating a Bit: Approximating atan, arccos, and arcsin in the Cherubin Library
This project is part of my Cherubin library — a C++ library for computing very large numbers represented as strings. Because Cherubin works outside the world of hardware floats and doubles, I couldn’t just call std::atan, std::asin, or std::acos. Instead, I had to invent approximations that made sense within the string-based arithmetic of Cherubin. ( GitHub link) The result is a set of small but clever tricks to approximate inverse trigonometric functions. They’re not mathematically perfect, but they get the job done and are fast enough to work with big numbers. Why Approximate? Standard math libraries are precise and optimized for floats, but Cherubin manipulates numbers as std::string or std::deque. Re-implementing full Taylor series everywhere would be very slow, so I turned to shortcuts: polynomial fits, hybrid methods, and even…
recreational-programmingSoundCutr: An Early Attempt at Voice Extraction in Audio Files
Think of this article as a small time capsule of my programming journey — proof that everyone starts somewhere, and that projects don’t need to be perfect to be fun and functional. Project Overview The goal of SoundCutr was to isolate the human voice from an audio track. This is useful for tasks like: Karaoke (removing or extracting vocals) Speech analysis Audio preprocessing for further machine learning tasks The approach is based on two key principles: Frequency filtering to focus on the human voice range (roughly 300 Hz – 3400 Hz). Block compartmentalization (time segmentation) to distinguish between real continuous speech and short transient sounds. How It Works The pipeline for processing audio files includes both spectral and temporal logic: Read the audio file (typically a .wav format). Apply filters…
defaultImplementing DataFrames in C++: A Custom Approach for High-Performance Data Manipulation
Introduction When working with data, Python and Pandas dominate the landscape. They provide an intuitive way to load, transform, and analyze datasets. But what if you need the same capabilities inside a C++ pipeline, without switching languages, and with full control over memory and type safety? That’s the motivation behind Tablo, my implementation of DataFrames in modern C++. This project provides a flexible and performant way to manipulate tabular data directly in C++ — including CSV parsing, type inference, missing value handling, and column/row operations. In this article, I’ll walk you through the architecture, features, and next steps of this implementation. Architecture Overview The core idea of this project is simple: Each column of the DataFrame is stored as a std::vector<T>, where T is the inferred type of the column.…
functional-programmingHow Haskell (and the Functional Mindset) Rewired the Way I Think About Code
I didn’t set out to “become a functional programmer.” I stumbled into Haskell after years of imperative and OOP work, mostly focused on getting features out the door. I knew about lambdas and “map/filter,” but those were just utilities, not a worldview. My real journey started with the excellent online book Learn You a Haskell for Great Good!. Its playful style made functional programming approachable, and soon I realized Haskell wasn’t just another language—it was a different way to think about programs: where state is explicit, effects are controlled, and types carry meaning. Why Haskell Was Created Haskell wasn’t born out of industry needs but out of academic curiosity and a desire for clarity. In the 1980s, researchers had designed many lazy functional languages, but the landscape was fragmented. To…
system-designBuilding an HTTP Server in Rust Without a Framework
All code excerpts below are highlights of the full implementation. See the complete source on GitHub: julienlargetpiet/HTTP_Server. Why write your own server? When you think of writing an HTTP server in Rust, the obvious choices are production-grade stacks like Hyper, Actix-Web, or Warp. They’re excellent—and in production you should likely use them. But building a server from first principles forces you to understand what actually happens: accepting sockets, parsing a protocol, and coordinating concurrency safely. Beginner-friendly intro: HTTP and Rust in 5 minutes What an HTTP server really does Listen on a TCP port for incoming connections. Parse each incoming byte stream into a structured HTTP request (method, path, version, headers, body). Respond with a valid HTTP response (status line, headers, body). Why Rust helps Ownership & borrowing ensure memory…
system-designBuilding an Encrypted Terminal Chatroom in C - A Personal Engineering Story
I built a tiny chatroom that runs entirely in the terminal, written in C, with all messages encrypted. This article is my engineering story: why I did it, how the design evolved, what broke (and why), and the practical lessons I’m taking to my next low-level project. The code lives here: github.com/julienlargetpiet/Chat. It’s a simple, scrappy program that uses sockets, pthread, ncurses for the TUI, SDL for a small “poke” sound, and OpenSSL’s EVP API for AES encryption. Why a chatroom in C, and why the terminal? I like C for the same reason some people like rebuilding engines: it’s brutally honest. If I forget to check a return code, leak a buffer, or mix up a length, I pay the price immediately. A chatroom touches a lot of systems…
recreational-programmingValidating JSON Syntax: A Conceptual Approach
In modern systems, JSON has become the de facto standard for exchanging structured data. Its popularity comes from its simplicity and readability. Yet, beneath this apparent simplicity lies a crucial question: how can we be sure that what we call “JSON” actually respects the rules of the format? Parsing alone is not enough — validation is essential. In this article, I share a way of thinking about JSON validation that goes beyond existing tools. The objective is not to provide a new parser or a piece of software, but to propose a conceptual algorithm for understanding what it really means to validate JSON. The Problem of Validation When we speak of JSON, we often assume that if a parser can read a string without raising an error, then the content…
software-computational-architectureEmulating Binary-Level Operations and Number Representations
At the heart of every computer lies a simple truth: everything is binary. Whether you are working with integers, floating-point numbers, or characters, all data is ultimately represented as sequences of 0s and 1s. To truly understand how computers operate, developers must go beyond high-level abstractions and study how numbers are represented and manipulated at the binary level. This article covers three pillars of low-level computation: Bitwise operations (AND, OR, XOR, NOT, shifts). Signed integer representations (one’s complement and two’s complement). Floating-point numbers (IEEE 754 standard). 1. Bitwise Operations Bitwise operators act directly on the binary digits of numbers. AND (&) Copy 1101 (13) 1011 (11) ---- 1001 (9) Use case: masking specific bits. OR (|) Copy 1101 (13) 1011 (11) ---- 1111 (15) Use case: setting specific bits. XOR…
defaultEditing My YouTube Videos the Weird Way: With Nothing but ffmpeg
Most people edit their YouTube videos with slick GUIs: Premiere, DaVinci Resolve, Final Cut Pro, even OBS + Shotcut for the open-source crowd. Me? I’m allergic to timelines and mouse-dragging. I prefer to edit in the most brutalist way possible: directly from the terminal, using nothing but ffmpeg. Yes, I’m basically editing like a robot with a text editor and command lines. It’s unusual, it’s nerdy, but it works. Let me walk you through my strange ritual. Step 1 — Recording the Chaos I start by summoning ffmpeg to record my microphone and my screen at the same time. One incantation later: Copy $ ffmpeg \ -f pulse -i alsa_input.usb-JMDZ_MICROPHONE_WOODBRASS_UM1_20211207-00.mono-fallback \ -f x11grab -s 1920x1080 -i :0.0 -f pulse tells ffmpeg to grab audio through PulseAudio, my sound system on…
software-computational-architectureUnsolved problem !!!
Statement and motivation (inspired from pb.93 of 99 Problems in Haskell) This problem originates from the motivation to find all possible results given a formula with `n` values, like: $$ X_1 + X_2 - X_3 \cdot X_4 $$ So here we are given a set of operators and a set of values. Basically there are n - 1 operators, one between each value. So it is trivial to find all possible results, we just have to use a cartesian product of all operators n - 1 times, then put the operators between each value, and calculate the result. In Haskell, to find all operators combinations, it would look like this: Copy sequence . replicate 3 $ "+-*/" But as you know, in each formula, comes the parenthesis. So it will…
recreational-programmingCustom Encoding For Integers
Ok, so i had to encode a structured data, a positive integer in this case representing the space for the server to reserve a byte slice for a file content, image, text... Basically, how to convert any positive integer to a vector of number that accepts value from 0 to 255. Encoding First solution, i just add 256, which will be 255 (from 0) in a vector, and the ending position value will be the rest of the integer minus the previous additions. But that is non optimal, because the vector is too long. Something that reduces more the size of the integer is of course a division, which will reduce a lot the size of the sending byte vector. Ok, so this is it for encoding: Copy func IntToByteSlice(x…
recreational-programmingAuthentication Without Cookies
Recently, i've been programming a simple cloud webserver in Go. And of course, it is unavoidable when including accounts, how to make sure a user is who he pretends to be when he connects to a page. Of course, there are authetication and session cookies, but in this blog we like to imagine another way to achive this. So let's implement a custom authentication mechanism that does not rely on cookies at all. Sounds cool. The projetc is available on this website Friendly_Cloud Or here on GitHub repo Method The credentials database consists of 3 columns: username password temp_password The password is only used in the login process, to verify that the users gives the right password. After validation, a randomly temporary password is generated, stored in the third column,…
system-designSimple Compression Algorithm
I've just finished implementing a simple text compression algorithm in C++, i will talk about its implementation in this article. The programm is available here repo Or on this website as a zip zip Compression overview A function will read the file to compress and will create a std::string of its content. After, it will look for recurrent patterns. Recurrent patterns A recurrent pattern as its name suggests is a sequence of character s that is present multiple times in the scaned std::string of the input file. We can choose the length of the pattern to find. For example a pattern of length 2 is more commun than a pattern of length 3. In a sentence, we more often see "ou" than "oup". Compression level Of course, the patterns frequence…
defaultImplement Core Operations
I have just finished developing a library for manipulating numbers so large and/or precise that no conventional datatype can encode them. You can find this library there: repo Or download on this website as zip: zip -Ok so if even a long unsigned int, double... can't represent my number, how do I? I'm not going to use vecteur, see a deque? In fact, if one is obliged, but it requires the complete reimplementation from zero of the fundamental operators ( +, -, *, /, %%, !, exp(x), log(x)...) taking into account the data structure with which we work. Addition For example, we do the addition and then we can do the multiplication and division. Example "12" * "0.4" = "12" + "12" + "12" + "12" then we moove the…
recreational-programmingSymetric Encryption Protocol
How i've implemented an original symetric encryption protocol with combinatorial mathematics repo Or download on this website as zip: zip It starts with this formula: n! / ((n-k)! * k!) It tells how many of k elements combinations can be created in a set of length n. For example, if we have: [1, 1, 0] We notice that the set has a length of 3 there are 2 elements inside. The possible combinations are: [1, 1, 0] [1, 0, 1] [0, 1, 1] It is intuitively made (easy for a set of length 3), but what tells the formula? 3! / ((3 - 2)! * 2!) = 6 / (1 * 2) = 3 We get the number of combinations. Won't be cool to have an algorithm returning the combinations…
recreational-programmingA ReGex Dialect
In this article i'm gonna present you a method to implement RegEx. Link: repo Or on this website: zip Before the explanation, what even is RegEx ? Regular Expressions are in fact a synthax allowing to find any pattern inside a text. A good RegEx dialect is Search Complete if it can, just by its synthax, find any pattern inside a text. I'm not a huge fan of the actual synthax in the majority of the RegEx dialects. I was inspired by these dialects but tried to simplify them, in C++. But first we have to define the characteristics of our dialect sensed to be Search Complete. Allow set definition as a condition This will be built by the introduction of a special character being - which will link the…
recreational-programmingAn Original Transformation Engine
In this article i will introduce you, in short, how i've implemented transformation engine XSLT like from scratch (with C++). repo Or download on this website: zip Which means requesting a value using its path in the data structure, the introduction of conditions, loops and sorting algorithms to generate a html page that the user describes inside a file with query instructions. Since i start from scratch, i have to create my own synthax to structure data. I remember of an algorithm i've created 1 year ago now allowing to tokenize pairs of parentheses inside a string. Bingo, for nested data XML, Json or even TOML like, pairs of parentheses design is great to describe their nesting. How it looks: Copy (destination: (restaurant: (menu: (size: (weight:150g) (size:small) ) (size: (weight:200g)…

