Skip to content

Instantly share code, notes, and snippets.

View LiamKarlMitchell's full-sized avatar

Liam Mitchell LiamKarlMitchell

View GitHub Profile
@LiamKarlMitchell
LiamKarlMitchell / D3DFORMAT.h
Created February 10, 2018 03:53
DirectX 9 D3D Header structs/info
typedef enum _D3DFORMAT
{
D3DFMT_UNKNOWN = 0,
D3DFMT_R8G8B8 = 20,
D3DFMT_A8R8G8B8 = 21,
D3DFMT_X8R8G8B8 = 22,
D3DFMT_R5G6B5 = 23,
D3DFMT_X1R5G5B5 = 24,
D3DFMT_A1R5G5B5 = 25,
@LiamKarlMitchell
LiamKarlMitchell / HideVirtualBox.bat
Created February 3, 2018 12:11
Hide Virtual Machine.
@echo off
@reg copy HKLM\HARDWARE\ACPI\DSDT\VBOX__ HKLM\HARDWARE\ACPI\DSDT\NOBOX__ /s /f
@reg delete HKLM\HARDWARE\ACPI\DSDT\VBOX__ /f
@reg add HKLM\HARDWARE\DESCRIPTION\System /v SystemBiosVersion /t REG_MULTI_SZ /d "NOBOX - 1" /f
@reg add HKLM\HARDWARE\DESCRIPTION\System /v VideoBiosVersion /t REG_MULTI_SZ /d "NOBOX - 1" /f
@taskkill /f /im VBoxTray.exe
@exit
@LiamKarlMitchell
LiamKarlMitchell / BindProperty.cs
Last active December 6, 2017 02:30
C# Datagrid bind nested properties from data source.
// I can't take credit for this but I wanted it as a Gist so I could find it in the future easily if needed.
// Found on a blog post by Antonio Bello
// http://www.developer-corner.com/blog/2007/07/19/datagridview-how-to-bind-nested-objects/
/// <summary>
/// A custom property binder.
/// </summary>
/// <param name="property"></param>
/// <param name="propertyName"></param>
/// <returns></returns>
@LiamKarlMitchell
LiamKarlMitchell / checkbox.js
Last active November 17, 2017 20:58
Helpful Handlebars template helpers.
// Show an HTML encoded checkbox for the result of a boolean like value.
Handlebars.registerHelper('checkbox', function (obj) {
return new Handlebars.SafeString(obj==true ? '&#9745;' : '&#9744;')
})
@LiamKarlMitchell
LiamKarlMitchell / jsreport audit.md
Last active November 16, 2017 16:50
A breif investigation into the security and suitability of jsreport.

JSReport, brief audit.

In order to verify if JSReport is suitable for our needs one thing we must check is the licensing because it uses a remote server.

jsreport can be run on our own servers.

Licensing

We may be able to use a free license during development. If we grow beyond 5 report templates we will need to subscribe for a yearly enterprise license.

@LiamKarlMitchell
LiamKarlMitchell / jsreport licensing audit
Created November 16, 2017 14:59
A breif investigation into the security and suitability of jsreport.
JSReport, brief licensing audit.
In order to verify if JSReport is suitable for our needs one thing we must check is the licensing because it uses a remote server.
A license key is checked by a remote server, as such we must understand the behavior.
We can't have the software leaking any private information from the report templates/data therein.
The implementation does a post to an https URL.
License verification URL: https://jsreportonline.net/license-key
@LiamKarlMitchell
LiamKarlMitchell / style.css
Last active October 29, 2017 22:53
Drunk Stack Overflow - Drunk CSS
@keyframes rotating-function {
0% {
transform: rotate(0deg);
}
25% {
transform: rotate(2deg);
filter: blur(1px);
}
50% {
transform: rotate(0deg);
@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;
@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 / 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