Skip to content

Instantly share code, notes, and snippets.

mcastelino /
Last active February 16, 2023 23:25
Testing a all virtio QEMU platform with all possible virtio devices

Test Target

Devices needed

name "vhost-scsi", bus virtio-bus
name "vhost-user-blk", bus virtio-bus
name "vhost-user-scsi", bus virtio-bus
name "virtio-blk-device", bus virtio-bus
michaeljclark / macos-syscall.c
Created April 30, 2017 08:55
simple macos process with no dependency on libsystem.dylib
View macos-syscall.c
* cc -Wall -O3 -c macos-syscall.c -o macos-syscall.o
* ld -static -macosx_version_min 10.12 -pagezero_size 0x1000 macos-syscall.o -o macos-syscall
__attribute__ ((visibility("default"))) extern void start(void) asm("start");
#define NR_exit 0x2000001
#define NR_write 0x2000004
View gist:44b7063110fc423edb4d

Things that programmers don't know but should

(A book that I might eventually write!)

Gary Bernhardt

I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel. For comparison, articles in large papers like the New York Times average about 1,200 words. Each topic gets whatever level of detail I can fit into that space. For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.

alghanmi /
Last active October 18, 2023 21:49
Podcast Feed Generator -- Generate an podcast RSS feed for a set of media in a directory.
"""Podcast Feed Generator
Generate an podcast RSS feed for a set of media in a directory.
Use the list-extensions argument to see the list of supported extensions. You can add custom extensions using
Usage: gen <directory> --title=<podcast-title> --link=<podcast-link> --desc=<description> [--output=<rss-feed-file>] [--feed-link=<feed-url>] [--id=<podcast-id>] [--logo=<image_file>] [--category=<itunes-category> [--subcategory=<itunes-category>]] [--language=<language>] [--use-extension=<ext>] list-categories list-extensions -h | --help
panzi / portable_endian.h
Last active November 14, 2023 07:04
This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, Mac OS X, and QNX. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh. License: I hereby put …
View portable_endian.h
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
mlafeldt / elf.h
Last active March 2, 2024 14:01
elf.h for OSX
View elf.h
/* This is the original elf.h file from the GNU C Library; I only removed
the inclusion of feature.h and added definitions of __BEGIN_DECLS and
__END_DECLS as documented in
On macOS, simply copy the file to /usr/local/include/.
Mathias Lafeldt <> */
/* This file defines standard ELF types, structures, and macros.
zliuva / gist:1084476
Last active July 31, 2023 21:32
A minimal Mach-o x64 executable for OS X
View gist:1084476
; A minimal Mach-o x64 executable for OS X (also see below Mountain Lion version)
; $ nasm -f bin -o tiny_hello tiny_hello.s
; $ chmod +x tiny_hello
; $ ./tiny_hello
; Hello World!
; $
; c.f.
; ( the original tiny mach-o executable )