Skip to content

Instantly share code, notes, and snippets.

View shimamura-sakura's full-sized avatar
🖥️
Coding…

lipsum shimamura-sakura

🖥️
Coding…
View GitHub Profile
@MartelliEnrico
MartelliEnrico / defer.h
Last active December 17, 2023 05:44
C defer for GCC
#pragma once
#define defer_(x) \
void _dtor_##x(); \
int __attribute__((cleanup(_dtor_##x))) _dtorV_##x; \
void _dtor_##x()
#define defer__(x) defer_(x)
#define defer defer__(__COUNTER__)
@shicky
shicky / ld_preload_hook.c
Last active June 27, 2024 12:25
LD_PRELOAD linux function hook example
# helloworld.c
# gcc helloworld.c -o helloworld
#include <stdio.h>
#include <unistd.h>
int main() {
puts("Hello world!\n");
return 0;
}
@vurtun
vurtun / _GJK.md
Last active July 17, 2024 17:42
3D Gilbert–Johnson–Keerthi (GJK) distance algorithm

Gilbert–Johnson–Keerthi (GJK) 3D distance algorithm

The Gilbert–Johnson–Keerthi (GJK) distance algorithm is a method of determining the minimum distance between two convex sets. The algorithm's stability, speed which operates in near-constant time, and small storage footprint make it popular for realtime collision detection.

Unlike many other distance algorithms, it has no requirments on geometry data to be stored in any specific format, but instead relies solely on a support function to iteratively generate closer simplices to the correct answer using the Minkowski sum (CSO) of two convex shapes.

@birme
birme / mse-tutorial.html
Created May 25, 2018 11:30
The basic principles for video streaming using MSE API
<!DOCTYPE html>
<html>
<body>
<video style="width: 640px; height: 360px; border: solid 1px;"></video>
<script>
var queue = [];
// Check that browser has support for media codec
var mimeCodec = 'video/mp4; codecs="avc1.4D401F"';
console.log(MediaSource.isTypeSupported(mimeCodec));
@tcoppex
tcoppex / c_nostd.txt
Last active July 14, 2024 12:30
Writing C software without the standard library [Linux Edition] - Franc[e]sco's Gopherspace
###################################################################
Writing C software without the standard library
Linux Edition
###################################################################
There are many tutorials on the web that explain how to build a
simple hello world in C without the libc on AMD64, but most of them
stop there.
I will provide a more complete explanation that will allow you to
build yourself a little framework to write more complex programs.
@andrewrk
andrewrk / build.zig
Created February 20, 2023 16:20
sprinkling a little zig into a C project to help with debugging
const std = @import("std");
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard optimization options allow the person running `zig build` to select