Skip to content

Instantly share code, notes, and snippets.

View LiamKarlMitchell's full-sized avatar

Liam Mitchell LiamKarlMitchell

View GitHub Profile
@LiamKarlMitchell
LiamKarlMitchell / circledNumberHTMLCode.js
Created September 8, 2016 01:51
Circled Number 0 to 20 & html escape unicode code.
// ⓪ ⓪ Circled Digit Zero
// ① ① Circled Digit One
// ② ② Circled Digit Two
// ③ ③ Circled Digit Three
// ④ ④ Circled Digit Four
// ⑤ ⑤ Circled Digit Five
// ⑥ ⑥ Circled Digit Six
// ⑦ ⑦ Circled Digit Seven
// ⑧ ⑧ Circled Digit Eight
// ⑨ ⑨ Circled Digit Nine
@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;
#!/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 / 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',
@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 / 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 / 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 / sftpgetall.sh
Created June 14, 2017 00:36
Automated connect to sftp and download all files.
#!/bin/sh
USER=$1
PASSWD=$2
HOST=$3
# Connect to FTP and download all files.
SSHPASS=$PASSWD sshpass -e sftp -oBatchMode=no -b - $USER@$HOST <<EOF
get -r *
quit
EOF
@LiamKarlMitchell
LiamKarlMitchell / plpgsql_random_number_csprng.sql
Last active October 13, 2017 12:22
A random number generator for PostgreSQL was based on the node-random-number-csprng.
-- A port of node-random-number-csprng to PostgreSQL.
-- https://github.com/joepie91/node-random-number-csprng/blob/master/src/index.js
-- Requires pgcrypto for gen_random_bytes() method.
CREATE EXTENSION IF NOT EXISTS pgcrypto;
-- Note: Maybe I should use bigint which is 8 bytes in size?
DROP FUNCTION IF EXISTS csprng_calculate_parameters(integer);
DROP TYPE IF EXISTS csprng_parameters;
CREATE TYPE csprng_parameters AS (
@LiamKarlMitchell
LiamKarlMitchell / Interval.js
Created October 18, 2017 00:55
JavaScript Interval timer
/*
* A timer that attempts to be more accurate than native setInterval.
* It calculates an appropriate delay to timeout after the callback is called.
* It is intended that the Callback function return ASAP this will not handle async operations that may be delayed.
*/
class Interval {
constructor(cb, ms) {
this.cb = cb;
this.ms = ms;
this.timeout = null;