Skip to content

Instantly share code, notes, and snippets.

@RaphGL
RaphGL / CONTRIBUTING.md
Created October 30, 2025 13:22
My default contributor guidelines for projects. This should evolve over time as I run into more issues with bad faith contributions

Contributor Guidelines

Make sure your code actually works.

LLMs are ok as a helper as long as the actual code is written and vetted by you, but if you're just going to use LLMs to "solve the issue" mindlessly, don't!!! Just create an issue and I will fix the problem.

If you still make AI slop PRs that don't even work. You will be blocked globally by me as I have limited time to maintain my projects and bad faith contributions take the limited time I could've used on more productive endeavors and I can't really be sure that you won't do it again in the future.

@RaphGL
RaphGL / .clang-format
Created October 5, 2025 13:01
My default format style for C/C++ projects
---
Language: C
BasedOnStyle: WebKit
BreakBeforeBraces: Attach
ColumnLimit: 100
IndentWidth: 3
IndentPPDirectives: BeforeHash
PointerAlignment: Right
...
@RaphGL
RaphGL / detect_original_user.c
Last active November 28, 2024 13:55
Detect what is the actual user running the comamnds. This can be used to detect if user is running sudo or running commands as any other user in the system.
#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
int main(void) {
// getuid retrieves the UID for the current user, the user can pretend to be another user,
// thus the UID is not necessarily attached to the current user running.
uid_t user_id = getuid();
// getpwuid retrieves the `struct passwd` which stores many some information about the user,
@RaphGL
RaphGL / linked_list.cpp
Created May 16, 2024 23:43
A linked list in C++ cause reasons???
#include <cstddef>
#include <initializer_list>
#include <iostream>
#include <stdexcept>
template <typename T> struct LLNode {
T val{};
LLNode<T> *next{nullptr};
};
@RaphGL
RaphGL / install_odin.sh
Last active October 2, 2024 17:21
Install Odin compiler and LSP
#!/bin/env sh
USER_HOME=$(getent passwd $SUDO_USER | cut -d: -f6)
# where to put the odin repos
REPO_DIR=${USER_HOME}/Documents
if [ "$EUID" -ne 0 ];
then echo "Please run as root"
exit
fi
@RaphGL
RaphGL / textbuffer.odin
Last active December 29, 2023 15:26
Bug printing textbuffer window with ncurses
package main
import "core:c"
import "core:fmt"
import "core:os"
import "core:slice"
import "core:strings"
import nc "ncurses/src"
TextBuffer :: struct {
@RaphGL
RaphGL / static_array_indices.md
Last active November 13, 2023 15:57
Static array indices in Modern C

Static Indices

C99 adds static indices letting you preserve size information for array parameters. This means that there's a guarantee that an array will never be null and has to have at least the specified number of items instead of just decaying into pointer.

So say we have this function signature:

void print_msg(char msg[10]);

You could call it this way:

@RaphGL
RaphGL / rle.c
Created September 20, 2023 15:14
Run-length encoding written in C11
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
size_t times;
char chr;
} RLEChar;
// Run length Encoding
@RaphGL
RaphGL / sorting.js
Last active September 20, 2023 19:43
Sorting Algorithms in JavaScript
function bubbleSort(myArr) {
for (let j = myArr.length - 1; j > 0; j--) {
let biggest = myArr[j];
for (let i = 0; i < j; i++) {
const item1 = myArr[i];
const item2 = myArr[i + 1];
if (item1 > item2) {
myArr[i] = item2;
myArr[i + 1] = item1;
@RaphGL
RaphGL / FlappyBird.ch8
Created June 22, 2023 12:26
Flappy Bird for the Chip8. It uses Wernsey's Chip8 assembler: https://github.com/wernsey/chip8
define x v0
define y v1
define tube_x v2
define tube_y v3
define px v4
define py v5
define k_flap v6
define score v7
define x2 v8
define arg1 va