Skip to content

Instantly share code, notes, and snippets.

View Qix-'s full-sized avatar
💻
Making an OS @oro-os

Josh Junon Qix-

💻
Making an OS @oro-os
View GitHub Profile
@Qix-
Qix- / shemulator.js
Created April 7, 2021 17:31
A thing I spent a few hours writing and ended up not needing.
/*
sh`emulator` (shell emulator)
by Josh Junon
Dual license: MIT License OR public domain
const [code, out, err] = await sh
`cat ${process.argv[2]}`
`wc -w`
`rev`
`tee /tmp/rev-word-count.txt`
I mostly move fast and break things, thinking differently while also not being evil. I am like an android - some call me Mr Robot - turning java and hot pockets into pure, event driven, asynchronous, reactive code - all of which is blazing fast and only three bytes gzipped. With my ninja-like skills I bootstrap unicorns like a rock star, synergizing and weaving machine code together like Our Holy Richard Stallman (peace be upon him), optimizing and streamlining integrations into cohesive and rich user experiences. I conjure magical inCANTATIONs on my DUAL ERGONOMIC MECHANICAL KEYBOARDS, WITH CUSTOM LISP CONFIGURATIONS FOR MANIFESTING MY WORD INTO REALITY LIKE PROPHETS TO THEIR SCRIBES. THE ͜OC͞ÉA̛N̶S ҉OF B̛ITS͝ FLO͡W̧I͜N͠G͜ ̨ON ́TH̶E B͜U͜S ́LI͠NES, ͢Q͝UI̛VÉR̡ING A̷S ͡THO͘U̢ǴH̸ D͠E͝NIAL̀ AT͏ TH̕E G͟AT͝E̴S ̛ǪF ̸VALG̵R̢I͜ND͝ I͝S IM̴M̶I͟NENT̛.̢ I pity the recruiter THAT LAYETH EYES ON MY CODE PATHS. LIKE A SERAPHIM ꙮ AND̕ ̛ITS ͡WATC̨HPOI̷N͠T͠Ś (̨̡͙̰̪̱̝̬̯ẖ͚̱͔̘̟e̸͔͔̱̖̰̻͙̺̕ ̸̱̼͉̼̗̖̞͜͝ͅc͉͉̪͙͎̕ò̰̭̻̻̩̗̕m̢̝̟͢͠e͟
@Qix-
Qix- / fake-language.txt
Last active December 11, 2020 16:21
6 years later and I still need to sit down and make this programming language
# Self-contained example for writing to stdout and to a file.
#
# Relies only on the standard assembler module (std.asm), which
# cannot be stubbed out here (as they are intrinsics). std.asm
# allows direct, architecture-specific emission of machine code
# instructions and access to registers.
#
# Also relies on the @platform, @arch, @effect, and @force_inline
# intrinsics, which cannot be (reasonably) stubbed out here.
#
@Qix-
Qix- / order-of-includes.md
Last active December 10, 2021 14:49
Order of includes

C/C++ Order of Includes

The order in which I group my header includes is as follows. Each section is separated by exactly one blank line, even if the section only has one include.

  1. "" Internal headers
  2. "" Internal generated headers (e.g. from version.h.in; okay to use from include path)
  3. "" Internal third-party headers (vendored into project)
  4. "" Private API headers (always relative paths)
  5. "" Public API headers
  6. <> Build-system level third party headers (e.g. from CMake's add_subdirectory(); always from include path)
@Qix-
Qix- / coro.cpp
Created September 29, 2020 04:16
C++20 coroutines + LibUV sample, v2
// Thank you to the folks at the C++ slack channel,
// along with @lewissbaker for the excellent literature
// (even though it took me a few days to be convinced
// it really was so).
#include <uv.h>
#include <iostream>
#include <experimental/coroutine>
@Qix-
Qix- / coroutine.cc
Created August 30, 2020 08:56
Actually working minimal test of coroutines in C++
/*
I couldn't find a good example of a simplistic, *working*
program using coroutines without a bunch of dependencies
or bloat. Further, most of the code examples didn't work
or missed some detail.
As of this writing, this is a working example in Clang 12.
Public domain.
Written with the help of https://blog.panicsoftware.com/your-first-coroutine/.
@Qix-
Qix- / aseprite.ksy
Last active July 25, 2020 14:35
Aseprite Kaitai definition file
meta:
id: aseprite
endian: le
file-extension:
- aseprite
- ase
seq:
- id: header
type: header
- id: frames
@Qix-
Qix- / libuv.zig
Created March 26, 2020 20:56
Simplistic libuv wrapper example in 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 January 21, 2020 06:38
Tests the ability to pipe between multiple processes uving libuv and without a dedicated read/write buffer copy
#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 January 21, 2020 06:07
Test openpty() (pseudo-terminal) integration with libuv
/*
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 {