Skip to content

Instantly share code, notes, and snippets.

View marvhus's full-sized avatar
🎯
Focusing

Martin marvhus

🎯
Focusing
View GitHub Profile
@marvhus
marvhus / simp_moving_camera_example.jai
Last active January 27, 2025 21:40
Jai example of how to have a moving camera using the Simp library
#import "Math";
#import "Simp";
#import "Basic";
#import "Input";
#import "Window_Creation";
window_width : s32 = 1280;
window_height : s32 = 720;
quit : bool = false;
the_window : Window_Type;
@marvhus
marvhus / build.py
Last active February 10, 2025 17:51
Python script to generate Ninja build script.
#!/usr/bin/env python3
import os
# settings
src_dir = "src"
bin_dir = "bin"
target_name = "exe"
file = open("build.ninja", "wt")
@marvhus
marvhus / Example Project.focus-config
Last active December 20, 2024 13:20
Focus config
[6] # Version number. Do not delete.
[[workspace]]
/home/mvh/source/marvhus/example
/home/mvh/opt/jai
[ignore]
/home/mvh/source/marvhus/example/.git/**
@marvhus
marvhus / enum_array.jai
Last active December 7, 2024 19:19
Enum array in Jai
Player :: enum {
ONE;
TWO;
}
player_colors :: #run -> []Color {
colors: [#run enum_max_value(type_info(Player)) + 1]Color;
colors[Player.ONE] = .{1, 0, 0};
colors[Player.TWO] = .{0, 1, 0};
return colors;
};
# write is for writing N newlines to a file.
# count is from counting the newlines in a file.
CC := gcc
CFLAGS := -Wall -Wextra -Werror \
-std=c11 -pedantic
TARGETS := count \
write

Ref

A small Jai library for making it easy to share pointers/references to the same data, while making it easy to get rid of the pointer/reference when it is no longer needed.

How to use

Creating a Ref variable

You just create a variable using with the Ref(T) type, where you replace T with your type. For example Ref(int).

Initializing

Then you initialize it with init(*ref_variable) where ref_variable is your variable,

@marvhus
marvhus / README.md
Last active April 23, 2024 18:51
Floating Point Precision in x86-64 Assembly

Floating Point Precision in x86-64 Assembly

The lack of precison you get with floating point numbers isn't a language problem, it's a problem with floating point nubers themselves, so it even shows up as low as x86-64 assembly.

The assembly in the file bellow is the code I have written to showcase this.

To compile it you have to do this:

$ nasm floats.asm -o floats.o -f elf64
@marvhus
marvhus / mu4e.md
Last active February 9, 2024 23:21 — forked from A6GibKm/mu4e.md
Read your emails with mu4e

Connecting emacs and Protonmail Bridge

This guide will cover the basics on how to integrate emacs with protonmail-bridge using

Configuring mbsync

@marvhus
marvhus / AoC_2023_day_09.hs
Created December 10, 2023 18:01
Day 9 of AoC 2023 in Haskell. No bullshit, just standard stuff.
getPairs :: [Int] -> [(Int, Int)]
getPairs [] = []
getPairs [_] = []
getPairs (x:y:xs) = (x,y) : getPairs (y:xs)
getDiff :: [(Int, Int)] -> [Int]
getDiff [] = []
getDiff ((x1, x2):xs) = (x2 - x1) : getDiff xs
generate :: [Int] -> [[Int]]
@marvhus
marvhus / .xinitrc
Created November 25, 2023 01:47
startx script for starting DWM and KDE
#!/usr/bin/bash
setxkbmap -option caps:ctrl_modifier no &
do_dwm ()
{
slstatus &
picom -b &
nitrogen --restore &
dunst -font "iosveka" &