Skip to content

Instantly share code, notes, and snippets.

View alchemycs's full-sized avatar

alchemycs

View GitHub Profile
@alchemycs
alchemycs / to-be-within-tolerance.spec.ts
Created January 13, 2021 03:20
Custom Jest Test For Clock Drift and Ranges
// Define and declare a custom jest expectation so we can handle clock drift tolerances
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jest {
interface Matchers<R> {
toBeWithinTolerance(center: number, tolerance: number): R;
}
}
}
@alchemycs
alchemycs / Rule 001 - Set the UPN
Last active August 29, 2015 14:10
Microsoft ADFS Claim Rules For Connecting To CompliSpace Fundamentals via SAML
c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer == "AD AUTHORITY"]
=> issue(store = "Active Directory", types = ("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"), query = ";userPrincipalName;{0}", param = c.Value);
@alchemycs
alchemycs / ScreenShot.cs
Created November 7, 2014 23:04
Bind a key to take a screen shot for
using UnityEngine;
using System.Collections;
public class ScreenShot : MonoBehaviour {
//Default is None, you should set this to whatever you want in the inspector
public KeyCode screenshotKey = KeyCode.None;
// Use this for initialization
void Start () {
@alchemycs
alchemycs / OpenWebLink.cs
Last active August 29, 2015 14:08
Unity 3D Touchable/Clickable Hyperlinked Objects with 'guiText' Components
@alchemycs
alchemycs / boxcmd.js
Created August 20, 2014 00:51
Run repository scripts in AWSBOX from cron or shell with environment variables
#!/usr/local/bin/node
//quick and dirty to get my scripts going quickly on awsbox from cron. Will clean this up some other time.
var path = require('path');
var child_process = require('child_process');
var configFile = path.join(process.env['HOME'], 'config.json');
var config = require(configFile);
@alchemycs
alchemycs / apache-config-watcher.conf
Created August 15, 2014 00:33
Apache Config Auto-Watch via Upstart
# apache-config-watch - checks config changes and reloads apache if the configs are ok
description "Reload apache when configs have changed."
author "Michael McHugh <developer@yrucalling.me>"
start on runlevel [2345]
stop on runlevel [016]
respawn
@alchemycs
alchemycs / take-site-snapshot.sh
Last active August 29, 2015 14:05
AWS Nightly Snapshot
#!/bin/bash
#
# We use this code from cron to automate nightly volume snapshots.
# In our case we have two volumes.
#
#
export EC2_KEYPAIR=MY-KEY-PAIR
export EC2_URL=https://ec2.ap-southeast-2.amazonaws.com
export AWS_ACCESS_KEY=accesskey
export AWS_SECRET_KEY=secretkey
@alchemycs
alchemycs / injectiontest.js
Created June 4, 2014 04:03
Web input/output sanitisation test script
/*
This file is used to test any input that is also used as an output to ensure sanitisation has occured:
Usage: on any form input enter something like:
<script src="thisfile.js"></script>
*/
alert('If this alert box worked then you need to sanitise your output!');
@alchemycs
alchemycs / fakemail.sh
Created February 25, 2014 04:58
Don't accidentally send emails when testing email function from PHP (*nix including OS X)
#!/bin/bash
#
# 1. Put this somewhere like /usr/local/bin/fakemail.sh
# 2. Set the permissions with: chmod a+x /usr/local/bin/fakemail.sh
# 3. Edit your php.ini and set: sendmail_path=/usr/local/bin/fakemail.sh
#
# Now your email will not be sent but logged to unique files that are timestamped.
# We use $RANDOM just to try and reduce collissions in case multiple emails are sent at the same time.
#
@alchemycs
alchemycs / gist:8193961
Created December 31, 2013 08:14
Enable Android adb on Mac OS X to work with Telstra T-Hub 2. Probably works for other OS by updating the equivalent file with the correct vendor id.
# This works for my model anyway, use
echo 0x069b >> ~/.android/adb_usb.ini
adb kill-server
adb devices