Skip to content

Instantly share code, notes, and snippets.

View skejeton's full-sized avatar
💠
hello

ske skejeton

💠
hello
View GitHub Profile
@skejeton
skejeton / mario.c
Last active February 20, 2023 12:45
Generates Mario Theme Song
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NUM_SAMPLES 44100
#define PI 3.14159265
// ------ NOTE IDS ------
#define C_ 0
#define CS 1
#define D_ 2
#include <stdint.h>
#include <stdlib.h>
#include "../../lib/umka/src/umka_api.h"
#include <string.h>
#ifdef __unix__
#include <dirent.h>
// 0 : DirectoryPath : str
// R : DirPtr : ^void
@skejeton
skejeton / floatadd.c
Created July 28, 2022 22:35
Add floats (non negative)
// DOES NOT WORK ON NEGATIVE VALUES !! :P
#include <stdio.h>
union MyFloat {
float fv;
struct {
unsigned mantissa: 23;
unsigned exponent: 8;
unsigned sign: 1;
@skejeton
skejeton / Main.c
Last active July 25, 2022 16:47
My first attempt at SIMD :P
#include <emmintrin.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <immintrin.h>
#include <time.h>
#define Benchmark(name, times) for (int t = 1; t;) for (double final; t;) for(clock_t start = clock(); t; final = (double)(clock()-start) / CLOCKS_PER_SEC, printf(" <%s> %gs / %dtimes = %gs\n", name, final, times, final/times), t = 0) for (int i = 0; i < times; ++i)
#define Utf8_BYTES_PER_ASCII 32
static inline size_t Utf8_Fetch(uint32_t *out, const char *s_)
{
const unsigned char *s = (const unsigned char*)s_;
if ((*s & 0xC0) != 0xC0) {
*out = *s;
return *s > 0;
}
const static size_t clas[32] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,3,3,4,5};
size_t cl = clas[*s>>3];
@skejeton
skejeton / ske.vim
Created June 8, 2022 12:50
Vim colorscheme uses handmade-hero.vim as a base
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let colors_name = "handmade-hero"
@skejeton
skejeton / main.c
Created May 16, 2022 11:45
UNICODE PARSER
// vim: noet
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
size_t th_utf8_decode_beta(uint32_t *out, const char *s_) {
const unsigned char *s = (const unsigned char*)s_;
if ((*s & 0xC0) != 0xC0) {
*out = *s;
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
#include <math.h>
#include "../lib.h"
typedef enum {
SHUT,
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include "../lib.h"
typedef struct {
char *source;
char *dest;
} conn_t;
@skejeton
skejeton / day6.c
Last active December 7, 2021 14:08
#include <stdio.h>
#include <inttypes.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
char* read_file(const char *path) {
FILE *f = fopen(path, "rb");
if (f == NULL)