Skip to content

Instantly share code, notes, and snippets.

View MyNameIsTrez's full-sized avatar
:shipit:

Sander Bos MyNameIsTrez

:shipit:
View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
// -----------------------------------------------------------------------------
// Cross platform high resolution timer
// From https://gist.github.com/ForeverZer0/0a4f80fc02b96e19380ebb7a3debbee5
#include <stdint.h>
#include <stdbool.h>
#if defined(__linux)
@mieki256
mieki256 / yliluoma_ordered_dither.py
Last active January 8, 2025 04:32
Yliluoma's ordered dithering algorithm 1, 2, 3. Python version.
#!python
# -*- mode: python; Encoding: utf-8; coding: utf-8 -*-
# Last updated: <2022/07/13 01:32:08 +0900>
"""
Yliluoma's ordered dithering algorithm 1, 2, 3 and adobe like
Arbitrary-palette positional dithering algorithm
https://bisqwit.iki.fi/story/howto/dither/jy/
Usage:
@lundman
lundman / time.h
Last active March 23, 2025 21:02
time.h style timers for macOS
#include <sys/stdtypes.h>
#include <stdbool.h>
#include <mach/boolean.h>
#include <sys/errno.h>
#include <stdlib.h>
#include <dispatch/dispatch.h>
#if !defined(MAC_OS_X_VERSION_10_12) || \
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12)
@x0nu11byt3
x0nu11byt3 / elf_format_cheatsheet.md
Created February 27, 2021 05:26
ELF Format Cheatsheet

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@ityonemo
ityonemo / test.md
Last active April 19, 2025 05:23
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@mvanga
mvanga / ecs-annotated.py
Last active March 30, 2025 02:02
A Python3 implementation of an entity-component-system in under 50 lines code.
import uuid
import json
# Returns a python dictionary given a file containing a JSON-based
# component definition. Every definition *must* contain a 'type'
# and 'schema' field inside a top-level dictionary. Here is an
# example of a simple schema file that defines a 'meta' component
# containing a 'name' field.
#
@pointhi
pointhi / pil_with_pyopencl.py
Created July 16, 2016 15:22
A minimal example to show how PIL.Image can be used in combination with pyopencl to do hardware accelerated image modification
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This script is a simple test to do image operations on pyopencl in combination with PIL
#
# based on the code of: https://gist.github.com/likr/3735779
import pyopencl as cl
import numpy
anonymous
anonymous / list27.txt
Created May 8, 2016 17:40
000(023Rb|001Rb)
001(017La|002Rb)
002(021La|003Rb)
003(021La|004La)
004(009Rb|005Lb)
005(004Ra|005La)
006(008La|007La)
007(009Rb|007La)
008(009Ra|008La)
009(010Ra|026Ra)
@hewittc
hewittc / python-dlopen
Last active November 22, 2024 22:22
Python ctypes automatically uses RTLD_NOW despite supplied flags. Here's something for fun.
#!/usr/bin/env python3
'''
test.c - clang -o test.so -fPIC -shared test.c
----------------------------------------------
extern int baz();
int foo() {
return 42;
}
@loderunner
loderunner / osx-ld.md
Last active March 2, 2025 18:22
potential blog posts

ld – Wading through Mac OS X linker hell

Intro

Friend: I tried looking at static linking in Mac OS X and it seems nearly impossible. Take a look at this http://stackoverflow.com/a/3801032

Me: I have no idea what that -static flag does, but I'm pretty sure that's not how you link to a library. Let me RTFM a bit.

Minutes later...