Giovanni's Diary > Subjects > Programming >

Programming Gists

Here is code snippets extracted from my other projects that can be easily reused, or implementation of simple algorithms, or just knowledge that I should remember.

  • C/set_signals.c: Setup an handler for various POSIX signals.
  • C/left_space.c: Get number of separator charactes from the left of a string in C99.
  • C/mandelbrot.c: Get the number of iterations of a point in the Mandelbrot set.
  • C/sdl_window.c: Create an SDL3 window and poll events.
  • C/clear_sceen.c: Clear the terminal screen using ANSI control sequences.
  • C/delta_time.c: Calculate the frame delta time and render a certain number of times per seconds in C99.
  • C/unix_server.c: Create an unix socket server that reads data sent to it.
  • C/inet_server.c: Create an inet server that reads data sent to it.
  • C/lcg.c: LCG algorithm for fast speudo random number generation. Not cryptographically secure but good enough and really fast for other use cases.
  • C/hash_djb2.c: Simple hash function for strings.
  • C/utils.h: Utility macros for C projects.
  • C/mmap_file.c: Read a file's contents using mmap. This is faster than read(2), and returns a pointer to the content of the file without needing to call read(2) each time.
  • C/traverse_dir.c: Traverse a directory recursively and call handle_file on each file.
  • C/CMakeLists.txt: Modern Cmake template for C++ projects.
  • C/Makefile: Simple Makefile template for C projects.
  • web/micro-style.css: Very simple css style for minimalistic websites.
  • config/init.lua: Simple Neovim configuration without too much bloat.
  • config/i3config: My configuration file for i3 window manager.
  • scripts/win2usb.sh: Copy the windows installer to an USB pen from Linux.
  • misc/hello_world.asm: Hello world x86-64 Linux assembly example.
  • misc/windows-commands.ps1: Useful Microsoft Windows commands.

Travel: Programming, Index