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
@skejeton
skejeton / _result.md
Last active December 25, 2022 09:03
fizzbuzz in 126 bytes mf

image

#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;
@skejeton
skejeton / main.c
Created January 5, 2020 20:12
HTTP server in C
#include "server.c"
char *body = "<a>href='#'>Test</a>";
char *res = strcat(strcat("HTTP/1.1 200 OK\nDate: Mon, 27 Jul 2019 12:28:53 GMT\nServer: Apache/2.2.14 (Win32)\nLast-Modified: Wed, 22 Jul 2009 19:15:56 GMT\nContent-Length: ", str(strlen(body))), "\nContent-Type: text/html\nConnection: Closed\nContent-Type: text/html; charset=utf-8\n\n");
int handle_conn(int sock)
{
write(sock, res, strlen(res));
}
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
#include <math.h>
#include "../lib.h"
typedef enum {
SHUT,