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- / bson-encode.js
Created September 20, 2014 00:14
Pure Javascript BSON Encoding
/**
* BSON Pure Javascript Implementation
* by Qix
*
* Known shortcomings:
* - ObjectID is excluded (for now)
* - DBPointer is excluded
* - Javascript code is excluded (for now; scoped encoding
* will always be excluded)
* - Timestamp (Mongo's specific type, not UTC) is excluded (for now)
@Qix-
Qix- / cwords.php
Last active August 29, 2015 14:07
PHP cwords()
<?php
/**
* A more robust ucwords()
*/
define( 'UCW_DEFAULTS', 0x1 );
define( 'UCW_MATCHSTART', 0x2 );
define( 'UCW_REVERSE', 0x4 );
@Qix-
Qix- / breakout.sh
Last active August 29, 2015 14:14
Tup Breakout Script
#!/bin/bash
# Takes a **RELATIVE** path and makes it relative to the *actual* source tree.
# Only use if you know what you're doing; this circumvents what Tup is supposed
# to do: manage read/write access.
# Check that we're in a tup directory
test "$(pwd | grep "\/\.tup")" || (echo "Not in a .tup directory!" 1>&2 && exit 1)
# First, find the actual root.
troot=
@Qix-
Qix- / install-watchrun.sh
Last active August 29, 2015 14:22
WatchRun
#!/bin/bash
(cat > /usr/local/bin/watchrun) <<EOF
#!/bin/bash
# Watches the CWD recursively and runs a command
# whenever a file changes.
trap ctrl_c INT
function ctrl_c() {
echo "Terminating watchrun"
@Qix-
Qix- / console.cpp
Created June 24, 2015 18:20
Allocate Console on Windows
#include <windows.h>
#include <tchar.h>
#include <sstream>
#include <iostream>
#include <fstream>
#include <io.h>
#include <stdio.h>
#include <fcntl.h>
BOOL ncEnableConsole()
@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- / no-inherit.cpp
Last active December 31, 2015 12:29
No-Inherit is a little windows utility I whipped up for use with Cygwin to fix a few issues while executing windows-based programs to run a child program natively, without inheriting the parent process' environment. Use it how you want!
/*
* Windows utility that creates a child process without inheriting any
* sort of environment. Used in the setup scripts to fake a vanilla
* windows environment for CMake.
*
* Developed by Qix
*/
#pragma comment(lib, "Userenv.lib")
#pragma comment(lib, "Advapi32.lib")
@Qix-
Qix- / wansi.cpp
Last active January 1, 2016 15:58
A simple Lua module that converts certain (supported) codes to equivalent Win32 console outputs. UTF/wide inputs are not supported. It is installed to `io.write` as an override.
/*
* WANSI - The Windows ANSI Lua Module
*/
#ifndef _WIN32
static_assert(false, "This Lua module is only intended to be built by MSVC tools on Windows.");
#endif
#include <windows.h>
#include <lua.hpp>