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- / ohai.gif
Last active October 16, 2023 16:04
ohaider
ohai.gif
@Qix-
Qix- / Makefile
Last active February 15, 2019 05:19
Example of how syscall support could be added to Terra without any dependencies
.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 January 26, 2019 01:05
Build an ICNS based off a single PNG (ImageMagick) or SVG image (Inkscape)
# 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 January 23, 2019 16:50
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.
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 January 21, 2019 23:34
Accepting any callable as a parameter to a variadic template for any pack of argument types
#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 January 21, 2019 22:25
Abusing pointer casts to store any function and call it with a parameter pack at runtime
#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);
@Qix-
Qix- / asar.js
Created October 10, 2018 11:36
Tried (and failed) attempt to write an efficient ASAR transformer
/*
This was a tried (and failed) attempt at making an ASAR file
transformer. The ASAR file format is so bizarre and thoughtless
that they used Pickling (lol) and a flat, offset-based data
format with absolutely no formal specification.
For whatever reason, the below code that *should* work does not.
Completely inexplicably, too.
I eventually gave up and resorted to extracting all of the data
@Qix-
Qix- / Alignment.md
Last active July 26, 2018 10:44
Tests Markdown alignment

Lorem

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut in mi tellus. Nulla bibendum eros id ante feugiat molestie. Praesent consequat consectetur risus, non congue risus tempor a. Vestibulum vitae neque at lorem volutpat tempor at a ante. Praesent aliquet nisi vitae lectus placerat, a sodales purus ultrices. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam erat volutpat. Suspendisse nec ultricies ex, vel congue sem. Proin tincidunt turpis in libero gravida lacinia. Duis sit amet dolor urna.

Curabitur et lorem ut tortor volutpat convallis sollicitudin eget eros. Duis nunc mi, pulvinar a euismod vitae, vulputate vitae nulla. Aliquam consectetur semper molestie. Donec orci felis, bibendum a commodo sodales, eleifend quis lectus. Nullam a sapien quis leo facilisis fringilla. Quisque pharetra libero eu odio rhoncus, nec volutpat sapien tincidunt. P

@Qix-
Qix- / scurl.sh
Last active March 7, 2024 10:43
Safe cURL - pipe your cURL-obtained scripts into this and pass it a sha256 to verify against. Comes with a pure-bash sha256 implementation.
#!/usr/bin/env bash
# Usage: curl https://some-site-with-potential-mitm.com/script.sh | scurl $verified_sha256_digest_of_script
# Released into the Public Domain.
# Written by Josh Junon (josh@junon.me) <github.com/qix->
# Original SHA256 implementation in C by Brad Conte (brad@bradconte.com) <https://github.com/B-Con/crypto-algorithms>
# Ported to (almost) pure Bash by Josh Junon
@Qix-
Qix- / sha256.sh
Last active July 10, 2023 10:00
SHA256 in (mostly) pure Bash script
#!/usr/bin/env bash
# Released into the Public Domain.
#
# Original implementation in C by Brad Conte (brad@bradconte.com) <https://github.com/B-Con/crypto-algorithms>
# Ported to Bash (lol) by Josh Junon (josh@junon.me) <https://github.com/qix->
#
# Yes, it's absolutely as slow as it looks.
#
# The only external dependency it has is on a utility called `od`,