This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// depends on stb_image and stb_image_write | |
// build using cc dither.c -o dither -lm | |
#include <stdio.h> | |
#define STB_IMAGE_IMPLEMENTATION | |
#include "stb_image.h" | |
#define STB_IMAGE_WRITE_IMPLEMENTATION | |
#include "stb_image_write.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stddef.h> | |
// An uint64_t can't hold more than 18446744073709551616 and 21! is very huge | |
// just store a table of these values upto 20 | |
static uint64_t factorial_table[21] = { | |
1, | |
1, | |
2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; this bootloader only loads and runs the kernel | |
; this does not load an initrd so the kernel will kernel panic stating it failed to mount the rootfs | |
; build instructions | |
; nasm -f bin slkboot.asm | |
; running instructions | |
; cat slkboot kernel_file > fun | |
; qemu-system-x86_64 -hda fun | |
[BITS 16] | |
ORG 0x7c00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This works on Windows 11 Build 25290.1010 as well | |
#include <stdio.h> | |
#include <windows.h> | |
// Ripped out from ReactOS | |
typedef struct _CHWIDTHINFO // Based on FD_DEVICEMETRICS | |
{ | |
LONG lMinA; | |
LONG lMinC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from datetime import date | |
def parse_line(line): | |
if line[0] == "#": | |
if line[1] == "#": | |
return f"</div><div><h2>{line[2:]}</h2>" | |
return f"</div><div><h1>{line[2:]}</h1>" | |
if line[0] == "!": | |
text_to_use = line[line.index('[') + 1:line.index(']')] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
noreturn void enter_in_el1_without_paging(uint64_t entry, uint64_t sp, uint64_t target_x0); | |
static void macho_highest_lowest(struct macho_header* mh, uint64_t *lowaddr, uint64_t *highaddr) { | |
struct load_command* cmd = (struct load_command*)((uint8_t*)mh + sizeof(struct macho_header)); | |
// iterate through all the segments once to find highest and lowest addresses | |
uint64_t low_addr_temp = ~0; | |
uint64_t high_addr_temp = 0; | |
for (uint32_t i = 0; i < mh->command_count; i++) { | |
switch (cmd->cmd) { | |
case 0x19: { | |
struct segment_command_64* seg_cmd = (struct segment_command_64*)cmd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <stddef.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <time.h> | |
/* | |
uint8_t sudoku_input_board[81] = { | |
0, 0, 8, 0, 6, 1, 0, 0, 0, | |
6, 0, 4, 0, 0, 7, 5, 0, 0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <SDL2/SDL.h> | |
#include <stdint.h> | |
#include <stddef.h> | |
#define STB_IMAGE_IMPLEMENTATION | |
#include "stb_image.h" | |
#define STB_IMAGE_RESIZE_IMPLEMENTATION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
RECT gUsableAreaCoords = {0}; | |
RECT gCurrentPos = {0}; | |
INT gVelocityX = 5; | |
INT gVelocityY = 5; | |
DWORD gLast = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <stddef.h> | |
#include <string.h> | |
#include <stdbool.h> | |
#include <time.h> | |
#define random_between(min, max) (rand() % (max - min) + min) |
OlderNewer