Skip to content

Instantly share code, notes, and snippets.

Avatar
🦀
Ascending from a Rust hater to a Rust advocate

Qix Qix-

🦀
Ascending from a Rust hater to a Rust advocate
View GitHub Profile
@Qix-
Qix- / no-inherit.cpp
Last active Dec 31, 2015
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!
View no-inherit.cpp
/*
* 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 Jan 1, 2016
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.
View wansi.cpp
/*
* 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 Sep 18, 2014
Portal Fish Recipe Console
View portal-console.js
'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 Sep 20, 2014
Pure Javascript BSON Encoding
View bson-encode.js
/**
* 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 Apr 9, 2017
PHP Palette (Color manipulation)
View palette.php
<?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 Aug 29, 2015
PHP cwords()
View cwords.php
<?php
/**
* A more robust ucwords()
*/
define( 'UCW_DEFAULTS', 0x1 );
define( 'UCW_MATCHSTART', 0x2 );
define( 'UCW_REVERSE', 0x4 );
@Qix-
Qix- / breakout.sh
Last active Aug 29, 2015
Tup Breakout Script
View breakout.sh
#!/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
Justifies text to a certain width (usually for console text or source code text)
View justify.js
// 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]);
});
View install-watchrun.sh
#!/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 Jun 24, 2015
Allocate Console on Windows
View console.cpp
#include <windows.h>
#include <tchar.h>
#include <sstream>
#include <iostream>
#include <fstream>
#include <io.h>
#include <stdio.h>
#include <fcntl.h>
BOOL ncEnableConsole()