Skip to content

Instantly share code, notes, and snippets.

View flysand7's full-sized avatar
๐Ÿž
been breadin'

Sunagatov Denis flysand7

๐Ÿž
been breadin'
View GitHub Profile
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.
// This code is Public Domain
// General information:
// Thread safety: none, wrap in a mutex or something
// Allocator type: combination of freelist and bitmap allocator
// Usage:
// include bballoc.h in every file that uses functionality from the library.
// define bballoc_implementation in EXACTLY one of the files.
#include<stdio.h>
#pragma message "Enable SSE? (Enter 0 or 1)"
enum {
sse =
#include</dev/stdin>
};
#pragma message "Enable Logging? (Enter 0 or 1)"
package main;
import (
"fmt"
"net/http"
"io"
"os"
"path"
"path/filepath"
"github.com/fsnotify/fsnotify"
#define LO32(x) (x&((UINT64_C(1)<<32)-1))
#define HI32(x) (x >> 32)
// Returns the high 64-bits of the 128-bit result.
// the `result` variable specifies the address of the low 64-bits
static uint64_t add_u64(uint64_t *result, uint64_t a, uint64_t b)
{
uint64_t al = LO32(a);
uint64_t ah = HI32(a);
@flysand7
flysand7 / webserver.c
Created September 24, 2021 18:26
Ultra minimal HTTP web server with winsock 2.
#include<stdbool.h>
#include<stdio.h>
#define WIN32_LEAN_AND_MEAN
#include<Winsock2.h>
#include<Ws2tcpip.h>
#define nil ((void *)0)
#define kb 1024
# This script correctly sorts strings that contain mix of characters
# and numbers.
# For example it is common for files in filesystems to
# have the following names:
# "file1"
# "file2"
# ...
# "file10"
# Though most operating systems sort blindly by comparing
@flysand7
flysand7 / stack_swap.py
Last active March 13, 2021 12:51
This is a program that swaps two stack contents using third stack.
n = 10
# stack data
class t_stack:
arr = 0;
top = 0;
def __init__(self):
self.arr = [];