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- / 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>
@Qix-
Qix- / portal-console.js
Created September 18, 2014 22:47
Portal Fish Recipe Console
'use strict';
var injectables = [
"ingredients",
"for the cake",
"1 2/3 cups all-purpose flour",
"1 1/2 cups granulated sugar",
"2/3 cup unsweetened cocoa powder",
"1 1/2 teaspoons baking soda",
"1 teaspoon salt",
@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- / palette.php
Last active April 9, 2017 15:19
PHP Palette (Color manipulation)
<?php
/**
* Palette Library
*
* A simple class that wraps color modification operations
* into a simple and elegant chainable clas
*/
class Palette
{
@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- / justify.js
Last active May 9, 2019 21:02
Justifies text to a certain width (usually for console text or source code text)
// Get width
const width = parseInt(process.argv[2] || '80');
// Read STDIN
let buffer = Buffer.alloc(0);
process.stdin.resume();
process.stdin.on('data', function(data) {
buffer = Buffer.concat([buffer, data]);
});
@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()