Skip to content

Instantly share code, notes, and snippets.

View LiamKarlMitchell's full-sized avatar

Liam Mitchell LiamKarlMitchell

View GitHub Profile
@LiamKarlMitchell
LiamKarlMitchell / REZ.bt
Last active May 26, 2017 10:37
Lithtech REZ file template for 010 Hex Editor.
//--------------------------------------
//--- 010 Editor v8.0 Binary Template
//
// File: Lithtech REZ File Version 1
// Author: MegaByte
// Revision: 1
// Purpose: To understand REZ Files.
//--------------------------------------
// TODO: Detect empty areas.
// TODO: Identify more parts of the Archive.
@LiamKarlMitchell
LiamKarlMitchell / array_natural_distribution_table_grid.js
Last active February 1, 2017 21:13
To output an ordered array of records distributed into a table/grid with natural numbering top left to bottom then continue counting from next column's top.
/*
Goal: To output an ordered array of records distributed into a table/grid with natural numbering top left to bottom then continue counting from next column's top.
Author: Liam Mitchell
Example:
2 columns with 8 records would look like this.
Row 0: 0 4
Row 1: 1 5
Row 2: 2 6
@LiamKarlMitchell
LiamKarlMitchell / ajaxReload.js
Last active January 30, 2017 03:45
Got sick of website timing out my session whilst waiting for reply from ticket help desk.
var crc32Previous = crc32(document.body.innerHTML);
var notificationPromptedAlready = false;
var useAlertInstead = true;
var ajaxRefreshTimeout = null;
function goReloadAJAX(done, notifyOnChange) {
var xhr = new XMLHttpRequest();
xhr.open('GET', window.location);
xhr.send(null);
xhr.onreadystatechange = function () {
@LiamKarlMitchell
LiamKarlMitchell / mysql helper.js
Last active January 25, 2017 03:42
A node.js script to help find missing indexes, FK, PK and mismatched ENGINE types (prefers INNODB).
// This script will connect to the DB and look for potential missing indexes.
// Author: Liam Mitchell
var db = 'database here';
var async = require('async');
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'host here',
user : 'username here',
#!/bin/bash
# Note, apt-get on Ubuntu seems to be providing an out of date optipng.
# Try doing this to install version 0.7.6
# Run optipng -v to see the version you have installed.
# wget http://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.6/optipng-0.7.6.tar.gz
# tar xvf optipng-0.7.6.tar.gz
# cd optipng-0.7.6
# ./configure
@LiamKarlMitchell
LiamKarlMitchell / InhibitWindowsEvents.cpp
Created November 30, 2016 19:48
Suppresses the Back and Forward mouse button actions and the Left Windows Key action on Windows 7+?
//// InhibitWindowsEvents.cpp : Defines the entry point for the console application.
////
#define WIN32_LEAN_AND_MEAN // Note: This could use WIN_NT 403
#include <windows.h>
#include <stdio.h>
HHOOK llMouseHook = NULL;
HHOOK llKeyboardHook = NULL;
@LiamKarlMitchell
LiamKarlMitchell / circledNumberHTMLCode.js
Created September 8, 2016 01:51
Circled Number 0 to 20 & html escape unicode code.
// ⓪ &#9450; Circled Digit Zero
// ① &#9312; Circled Digit One
// ② &#9313; Circled Digit Two
// ③ &#9314; Circled Digit Three
// ④ &#9315; Circled Digit Four
// ⑤ &#9316; Circled Digit Five
// ⑥ &#9317; Circled Digit Six
// ⑦ &#9318; Circled Digit Seven
// ⑧ &#9319; Circled Digit Eight
// ⑨ &#9320; Circled Digit Nine
@LiamKarlMitchell
LiamKarlMitchell / downloadFile.js
Last active September 3, 2019 10:34
node.js download file outputs progress and does not re-download already downloaded file.
var fs = require('fs');
var http = require('http');
var forceredownload = false;
function downloadFile(url, file, callback, redirect_count, known_size) {
console.log('Attempting to download ' + url + ' to ' + file);
if (redirect_count) {
if (redirect_count > 5) {
callback('Max redirects reached', url);
return;
@LiamKarlMitchell
LiamKarlMitchell / unicode_card.js
Last active February 18, 2016 03:14
A way to output unicode information for a card number.
// https://en.wikipedia.org/wiki/Standard_52-card_deck
function unicodeCard(cardNumber) {
// As of Unicode 7.0 playing cards are now represented. Note that the following chart ("Playing Cards", Range: 1F0A0–1F0FF) includes cards from the Tarot Nouveau deck as well as the standard 52-card deck.
if (cardNumber < 0 || cardNumber > 56) { throw 'Invalid cardNumber '+cardNumber }
cardNumber += 2*Math.max(Math.ceil(cardNumber/14),1);
return String.fromCodePoint(127136-2+cardNumber);
}
function unicodeCardHTMLEncoded(cardNumber) {
// As of Unicode 7.0 playing cards are now represented. Note that the following chart ("Playing Cards", Range: 1F0A0–1F0FF) includes cards from the Tarot Nouveau deck as well as the standard 52-card deck.
// A way to compare two floating point numbers for "equality".
const EPSILON = 0.00000001;
function fEqual(a, b) {
return ((a - b) < EPSILON && (b - a) < EPSILON);
}
// An infamous mistake by rookies is to notice the following.
// 0.1 + 0.2 == 0.3
// And think it is a mistake when the language says false. Us humans would just say 0.3.
// But because of how float points work in computer you end up with something like 0.30000000000000004.