Skip to content

Instantly share code, notes, and snippets.

@flysand7
flysand7 / exec_windows.odin
Created January 24, 2024 13:48
Run shell commands and start processes on windows.
//+build windows
package bake
import "core:sys/windows"
import "core:strings"
import "core:slice"
/*
Starts the process.
Note: the first element of argv is the name of executable
@flysand7
flysand7 / pile-o-shit.ts
Created December 9, 2023 14:23
functional-typescript-test
import * as http from "http";
type Result<T, E> = readonly [T, null] | readonly [null, E];
function Ok<E, T>(value: T): readonly [T, null] {
return [value, null] as const;
}
function Err<E, T>(error: E): readonly [null, E] {
@flysand7
flysand7 / raylib5.diff
Last active November 18, 2023 13:56
Raylib v4.5.0 -> v5.0 diff
diff --git a/src/raylib.h b/src/raylib.h
index 4cd9e434..1c4c4a09 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -1,6 +1,6 @@
/**********************************************************************************************
*
-* raylib v4.5 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
+* raylib v5.0 - A simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
*
@flysand7
flysand7 / .bashrc
Created October 17, 2023 01:21
My bashrc
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
alias grep='grep --color=auto'
@flysand7
flysand7 / windows_console.c
Created March 13, 2023 17:27
win32 console/window app
// Sometimes there is a need to make an application that behaves like a GUI app when ran via
// explorer, but like console application when ran from console. This file implements such
// an application. On start, it will try to attach to a parent console. If that failed,
// that means that we ran from explorer, and we may want to allocate a console for debugging
// purposes. If we get a console either by attaching to it or by creating it, we will redirect
// std handles.
// At program termination we need to send enter to stdin in order to let the parent console
// know that we're done. I'm not sure why we need to do this but if it's not done, the parent
// will wait indefinately for user input.
@flysand7
flysand7 / work_queue.cs
Last active October 28, 2022 12:19
Simple Work Queue in C#
public delegate void DoWorkFunc<WorkItem>(WorkItem q);
public class WorkQueue<WorkItem> {
Thread[] workers;
DoWorkFunc<WorkItem> do_work_func;
Queue<WorkItem> work_items;
Semaphore n_work_items;
Semaphore n_free_items;
// Function that adds 64-bit floats implemented using bit magic
double fadd(double xf, double yf) {
const uint64_t exp_mask = ((UINT64_C(1)<<11)-1);
const int64_t exp_min = -1023;
const int64_t exp_max = 1022;
const uint64_t mant_mask = ((UINT64_C(1)<<52)-1);
// Extract fields from floats
union{uint64_t i; double f;} v;
int is_c99(void)
{
int r=0,b=1,c=2;
r = b //*kek*/c
;
return r;
}
// 16-bit and 32-bit modrm encoder in x86.
// nothing fancy
FILE *out;
// The bitness of the output
// within operating system code can change from one
// instruction to another instruction.
int bits;
@flysand7
flysand7 / fat32_boot_sector.asm
Created December 1, 2021 10:14
A fat32 bootloader within a single partition
org 0x0800
cpu 386
bits 16
;;___________________________________________________________________________;;
;; This file is Volume Boot Record that loads a single file from FAT32
;; onto the address 0x1000 and jumps to that address. I created this file
;; mainly for demonstration that one doesn't need additional sectors for
;; simple bootloaders.