$ show agavrel/42_CheatSheet
This repository is a comprehensive educational reference and cheat sheet for 42 School's C programming curriculum. It contains extensive documentation covering C basics, common mistakes, clean coding practices, development tools, curated learning resources, and tutorials on optimization, graphics, and security. The repository also includes a collection of standalone C/C++ code examples demonstrating various programming techniques (SIMD vectorization, multithreading, bit manipulation, socket programming) and a set of remote coding challenges with automated testing. While not a deployable application, it serves as a valuable learning resource and provides reusable code snippets, particularly the SIMD abstraction header for fast word/line counting.
The LLM identified 5 files worth highlighting for reuse:
A highly reusable SIMD abstraction header that provides a uniform API for counting lines and words in text data using SSE2, AVX2, or AVX512 instructions, with a scalar fallback. It encapsulates platform-specific intrinsics behind macros and inline functions, allowing easy extraction and use in any C project requiring fast text processing. Demonstrates advanced SIMD programming, type abstraction, and fallback design.
A self-contained C program that benchmarks SIMD vectorization (using SSE 128-bit registers) against a scalar loop to compute min and max values in a large float array. The SIMD reduction uses shuffle and max/min operations to efficiently compute the result. This file can be extracted as a template for SIMD-based aggregation and demonstrates performance comparison methodology.
A C++ benchmark comparing multiple techniques to filter alphanumeric characters from a string: standard library algorithms, a lookup table, and a branchless approach using a precomputed bitmask. The branchless method (agavrel_style) uses arithmetic and bit operations to avoid conditional branches. This file serves as a reusable reference for string filtering optimization and demonstrates multiple implementation strategies with performance measurements.
A C program that benchmarks a branching character replacement versus a branchless version that uses arithmetic to avoid conditionals. The branchless method computes the replacement using a mask derived from equality comparison. This file can be extracted as a reusable pattern for efficient character substitution in tight loops and demonstrates a classic performance optimization technique.
A simple shell script that uses inotifywait to watch a source file for changes, then automatically recompiles and runs it. This is a reusable pattern for rapid development and testing of C programs, particularly useful during competitive programming or educational exercises. It demonstrates a lightweight continuous testing workflow.