Skip to content

Instantly share code, notes, and snippets.

View AlastairTaft's full-sized avatar

Alastair Taft AlastairTaft

  • Tasmania, Australia
View GitHub Profile
@AlastairTaft
AlastairTaft / generate-random-colour.js
Created September 7, 2020 06:40
Generate random colour
'#' + '000000'.split('').map(c => Number(Math.floor(Math.random() * 16)).toString(16)).join('')
@AlastairTaft
AlastairTaft / generate-key.js
Last active September 23, 2020 23:45
Generates a URL safe key with sufficient bit complexity
/**
* Generate a URL safe key with sufficient bits of complexity.
*/
const generateKey = function(bits){
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "012345678910"
+ "-_"
var expectedEntroy = Math.pow(2, bits)
var key = ''
@AlastairTaft
AlastairTaft / test-util.js
Last active April 19, 2019 07:30
Browser Test Utility
/**
* Usage
* Include this file in the <head />
*
* Then you can use HTML like so.
*
* ```html
* <browser-test pass="false">
* <span slot="description">This is a failed test</span>
* <pre slot="info">
@AlastairTaft
AlastairTaft / list branches.bash
Created March 13, 2018 01:54
List branches with info
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'
@AlastairTaft
AlastairTaft / ThreadCorruptionTest
Created June 16, 2015 09:12
A console application to break safe threads with bad threads using SqlConnection objects
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading;
namespace ThreadCorruptionTest
{
class Program