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- / apply-error.js
Last active August 25, 2015 19:49
Error hacking
function applyFilename(err) {
var descriptor = Object.getOwnPropertyDescriptor(err, 'stack');
var getter = descriptor.get;
descriptor.get = function () {
var lines = getter.call(this).split(/[\r\n]+/g);
if (this.fileName) {
lines[0] += ' in ' + this.fileName;
}
return lines.join('\n');
};
@Qix-
Qix- / README.md
Last active September 28, 2015 21:24
Code Docs

Code Docs

Because I'm tired of guessing at consumption, ownership, and lifetimes.

This little collection of snippets can be used in C/C++ projects to help document - in code - the ownership, lifetime, and consumption of arguments (both in signatures and invocation expressions).


The header provided is a set of simple #define statements, allowing the documentation to run.

NOTE: This does impose the limitation that the identifiers uses, owns, and consumes will no longer work in your code!

@Qix-
Qix- / rip.js
Created December 26, 2015 11:55
use strict plz
'there is a sad song';
'about a boy who had strict parents';
'one day they saw the error of their ways';
'they allowed him to go to a concert';
'that concert had drugs';
'he injected 6 marijuanas';
'the boy ded';
'a lesson to all parents';
'use strict';
@Qix-
Qix- / header-check.c
Created January 2, 2016 03:55
NES Header Checker
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ines-header.h"
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
@Qix-
Qix- / topng.sh
Last active January 30, 2016 10:36
Convert anything to PNG
#!/bin/sh
SIZE=$(wc -c "$1" | awk '{print $1}')
SQUARE=$(bc <<< "sqrt( $SIZE / 3 ) + 1")
TOTAL=$(expr $SQUARE "*" $SQUARE "*" 3)
PAD=$(expr $TOTAL - $SIZE)
dd if=/dev/zero ibs=1 count=$PAD 2>/dev/null | cat $1 - | convert -size ${SQUARE}x${SQUARE} -depth 8 rgb:- -scale 200% $2
@Qix-
Qix- / keybase.md
Created February 13, 2016 21:51
keybase.md

Keybase proof

I hereby claim:

  • I am Qix- on github.
  • I am qix (https://keybase.io/qix) on keybase.
  • I have a public key whose fingerprint is D5F8 6047 E9CF DD53 6588 3F5D 03A0 B7D0 432E 1514

To claim this, I am signing this object:

/*
this quick and dirty example shows how a program can
mount a new table as the global table, run some code,
restore the original global table and then refer to the
'child' global table as a regular ol' table in the parent
global's scope.
expected output:
global
type id 0
@Qix-
Qix- / skinnify.cc
Created April 15, 2016 04:07
Skinnify
#include <iostream>
#include <string>
#include <deque>
using namespace std;
int main(int argc, char **argv) {
if (argc < 2) return 1;
int backsize = atoi(argv[1]);
deque<string> backlog(backsize, "");
cout << string(backsize, '\n');
string line;
@Qix-
Qix- / dstat.c
Created April 29, 2016 06:51
dstat - developer stat
#include <sys/stat.h>
#include <stdio.h>
int main(int argc, char **argv) {
if (argc != 2) {
fprintf(stderr, "error: must specify (only) one file\n");
return -1;
}
struct stat attr;
@Qix-
Qix- / setup_release.sh
Last active April 9, 2018 04:37
LLVM Release Switcher
#!/usr/bin/env bash
set -e
function log {
echo -e "\x1b[36;1m""$@""\x1b[m"
}
function log2 {
echo -e "\x1b[36;2m""$@""\x1b[m"