Skip to content

Instantly share code, notes, and snippets.

View marler8997's full-sized avatar

Jonathan Marler marler8997

  • Tuple
  • Idaho, United States
View GitHub Profile
@marler8997
marler8997 / build-llvm-for-zig-debug
Last active August 28, 2023 03:02
Build LLVM for Zig
#!/usr/bin/env sh
set -ex
prefix=$HOME/llvm16-debug
# LLVM
mkdir -p llvm/out-debug
if [ ! -e llvm/out-debug/build.ninja ]; then
cmake -S llvm -B llvm/out-debug \
-DCMAKE_INSTALL_PREFIX=$prefix \
@marler8997
marler8997 / main.c
Created August 10, 2023 23:04
Win32 ShellExecute Clears Message Queue?
// Compile from Visual Studio Command Prompt with:
//
// cl main.c
//
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "shell32.lib")
#define UNICODE
#include <windows.h>
#include <stdio.h>
stream_events_ = {
PW_VERSION_STREAM_EVENTS,
.destroy = on_stream_destroy,
.state_changed = on_stream_state_changed,
.control_info = on_stream_control_info,
.io_changed = on_stream_io_changed,
.param_changed = on_stream_param_changed,
.add_buffer = on_stream_add_buffer,
.remove_buffer = on_stream_remove_buffer,
.process = on_stream_process_static,
@marler8997
marler8997 / new_zig_feature.zig
Last active April 5, 2023 15:57
Opaque Type Heirarchies
pub const Animal = *opaque {};
// allow opaque to take a type as a parent
pub const Dog = *opaque(Animal) {};
pub const Cat = *opaque {};
const some_library = struct {
pub extern fn makeDog() Dog;
pub extern fn bark(Dog) void;
pub extern fn pet(Animal) void;
};
* Now talking on #pipewire
* Topic for #pipewire is: PipeWire multimedia daemon. See https://pipewire.org. Latest version: 0.3.66. You must be registered with NickServ to speak (due to bot spam). Bridged to #pipewire:matrix.org
* Topic for #pipewire set by wtay!~wim@106.red-83-60-92.dynamicip.rima-tde.net (Thu Feb 16 03:43:26 2023)
<marler8997> Hello, I'm trying to finish up our pipewire usage for capturing a screencast session via the flatpak portal and am running into a few issues.
<marler8997> The first is how I should be handling the "node id" that the screencast portal gives me. It looks like the "target id" parameter for connecting a stream is deprecated? Is there a way to turn a pipewire node id into an "object serial" or "node name"?
<marler8997> The next is how to setup the stream. I'm getting different results on different distros/implementations. The question is whether I should be specifying a set of supported formats. If I do but the actual format isn't in my list, then the stream just never
unsigned char param_buffer[1024];
spa_pod_builder builder = SPA_POD_BUILDER_INIT(param_buffer, sizeof(param_buffer));
const spa_pod *params[1];
params[0] = (spa_pod*)spa_pod_builder_add_object(&builder,
SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat,
SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video),
SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw),
// TODO: test what happens if we don't support any formats
SPA_FORMAT_VIDEO_format, SPA_POD_CHOICE_ENUM_Id(3,
SPA_VIDEO_FORMAT_YUY2, // default
@marler8997
marler8997 / doom-linux-sound.c
Created January 17, 2023 04:09
DOOM sndserver linux aplay
static void InitAplay(int samplesize)
{
int pipefd[2];
if (0 != pipe2(pipefd, O_DIRECT)) {
fprintf(stderr, "pipe failed, errno=%d\n", errno);
exit(-1);
}
// pipefd[0] read
pid_t pid = fork();
if (pid == -1) {
@marler8997
marler8997 / TypeSafeIoctlsZig.md
Last active September 7, 2022 16:53
Type Safe Ioctls in Zig

Type Safe Ioctls in Zig

Linux ioctl request numbers embed information about the ioctl, namely,

  1. The size of the argument
  2. The argument IO direction (read/write/both)

For example

@marler8997
marler8997 / README.md
Created September 4, 2022 15:53
X11 Character Sets

This GIST contains the contents of the X11 protocol character set tables in a parseable text format. The text file was created by manually copy/pasting the tables from the PDF file found here:

https://www.x.org/docs/XProtocol/proto.pdf

I've also included an example python script that parses the file and prints it in a new format.

@marler8997
marler8997 / unique.h
Created September 2, 2022 04:23
c++ unique template
template<typename T, T null_value, void (*release)(T)>
class unique {
public:
// TODO: should we include an empty ctor?
// unique() : m_val(null_value) { }
unique() = delete;
unique(T val) : m_val(val) { }
unique(unique&& source) : m_val(source.m_val) {
source.m_val = null_value;