Skip to content

Instantly share code, notes, and snippets.

🥐

Qix Qix-

🥐
View GitHub Profile
@Qix-
Qix- / aseprite.ksy
Last active Jul 25, 2020
Aseprite Kaitai definition file
View aseprite.ksy
meta:
id: aseprite
endian: le
file-extension:
- aseprite
- ase
seq:
- id: header
type: header
- id: frames
@Qix-
Qix- / libuv.zig
Created Mar 26, 2020
Simplistic libuv wrapper example in Zig
View libuv.zig
const std = @import("std");
const warn = @import("std").debug.warn; // XXX DEBUG
const assert = std.debug.assert;
const c = @cImport({
@cInclude("uv.h");
});
pub const UVError = error{ E2BIG, EACCES, EADDRINUSE, EADDRNOTAVAIL, EAFNOSUPPORT, EAGAIN, EAI_ADDRFAMILY, EAI_AGAIN, EAI_BADFLAGS, EAI_BADHINTS, EAI_CANCELED, EAI_FAIL, EAI_FAMILY, EAI_MEMORY, EAI_NODATA, EAI_NONAME, EAI_OVERFLOW, EAI_PROTOCOL, EAI_SERVICE, EAI_SOCKTYPE, EALREADY, EBADF, EBUSY, ECANCELED, ECHARSET, ECONNABORTED, ECONNREFUSED, ECONNRESET, EDESTADDRREQ, EEXIST, EFAULT, EFBIG, EHOSTUNREACH, EINTR, EINVAL, EIO, EISCONN, EISDIR, ELOOP, EMFILE, EMSGSIZE, ENAMETOOLONG, ENETDOWN, ENETUNREACH, ENFILE, ENOBUFS, ENODEV, ENOENT, ENOMEM, ENONET, ENOPROTOOPT, ENOSPC, ENOSYS, ENOTCONN, ENOTDIR, ENOTEMPTY, ENOTSOCK, ENOTSUP, EPERM, EPIPE, EPROTO, EPROTONOSUPPORT, EPROTOTYPE, ERANGE, EROFS, ESHUTDOWN, ESPIPE, ESRCH, ETIMEDOUT, ETXTBSY, EXDEV, UNKNOWN, EOF, ENXIO, EMLINK };
@Qix-
Qix- / uv_pipe.c
Created Jan 21, 2020
Tests the ability to pipe between multiple processes uving libuv and without a dedicated read/write buffer copy
View uv_pipe.c
#include <uv.h>
#include <unistd.h>
extern char *environ[];
static int uv_perror(int r, const char *msg) {
printf("%s: %s (%s)\n", msg, uv_strerror(r), uv_err_name(r));
return 1;
}
@Qix-
Qix- / isatty.c
Last active Jan 21, 2020
Test openpty() (pseudo-terminal) integration with libuv
View isatty.c
/*
Simple testbed for checking TTY status. Use with the other program if you'd like.
*/
#include <unistd.h>
#include <stdio.h>
static void check(const char *name, int fd) {
if (isatty(fd)) {
printf("%s IS a tty: %s\n", name, ttyname(fd));
} else {
@Qix-
Qix- / Makefile
Last active Feb 15, 2019
Example of how syscall support could be added to Terra without any dependencies
View Makefile
.PHONY: all
all: bin/test-syscall
bin/test-syscall: test-syscall.t syscall-macos-x64.t
@mkdir -p bin
terra $<
.PHONY: clean
clean:
rm -rf bin
@Qix-
Qix- / icns.cmake
Created Jan 26, 2019
Build an ICNS based off a single PNG (ImageMagick) or SVG image (Inkscape)
View icns.cmake
# LICENSE: CC0 - go nuts.
# Hi :) This is what I used to generate the ICNS for my game, Tide.
# Both input formats (SVG vs PNG) work just fine, but in my experience
# the SVG came out with noticeably better results (although PNG wasn't
# a catastrophe either). The logo for the game was simple enough that
# SVG was indeed an option.
# To use:
#
@Qix-
Qix- / example-http-backend.tf
Created Jan 23, 2019
Example Terraform HTTP backend implementation for Node.js. Stores the state in a local object. Not meant for production, but more to show how one would go about implementing the HTTP api for it since it's not well documented.
View example-http-backend.tf
terraform {
backend "http" {
address = "http://localhost:8080/tfstate"
lock_address = "http://localhost:8080/tfstate"
unlock_address = "http://localhost:8080/tfstate"
}
}
@Qix-
Qix- / voodoo.cc
Created Jan 21, 2019
Accepting any callable as a parameter to a variadic template for any pack of argument types
View voodoo.cc
#include <iostream>
#include <string>
#include <functional>
#include <tuple>
#include <type_traits>
using namespace std;
// This voodoo brought to you by the legendary JLBorges
// http://www.cplusplus.com/forum/general/223816/#msg1025150
@Qix-
Qix- / fn-recasting.cc
Created Jan 21, 2019
Abusing pointer casts to store any function and call it with a parameter pack at runtime
View fn-recasting.cc
#include <iostream>
#include <string>
#include <functional>
#include <tuple>
using namespace std;
template <typename... TArgs>
void cast_apply(function<void()> fn, tuple<TArgs...> tup) {
function<void(TArgs...)> realFn = *reinterpret_cast<function<void(TArgs...)>*>(&fn);
You can’t perform that action at this time.