Skip to content

Instantly share code, notes, and snippets.

craigtp / GetWindowsProductKey.vbs
Created May 30, 2016
Retrieve Windows Product Key
View GetWindowsProductKey.vbs
Option Explicit
Dim objshell,path,DigitalID, Result
Set objshell = CreateObject("WScript.Shell")
'Set registry key path
Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\"
'Registry key value
DigitalID = objshell.RegRead(Path & "DigitalProductId")
Dim ProductName,ProductID,ProductKey,ProductData
'Get ProductName, ProductID, ProductKey
View .gitconfig
autocrlf = true
excludesfile = D:\\Documents\\gitignore_global.txt
;excludesfile = "D:/Documents/gitignore_global.txt"
;editor = 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -nosession
editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -nosession
preloadindex = true
craigtp / mercurial.ini
Last active Oct 24, 2018
Standard Mercurial Config / ini file
View mercurial.ini
username = Your Name <>
ignore = D:\Documents\hgignore_global.txt
ssh = "C:\Utils\putty\plink.exe" -ssh -2 -batch -C
editor="C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst -nosession
beyondcompare4.args=$local $other $base $output /ro /lefttitle=local /centertitle=base /righttitle=other /automerge /reviewconflicts /solo
beyondcompare4.regkey=Software\Scooter Software\Beyond Compare 4
craigtp / BetterRandom.cs
Last active Jun 13, 2018
BetterRandom - A C# class to produce random numbers which inherits from the .NET framework's System.Random class and so can be a drop-in replacement for usages of the standard Random class, but which uses the RNGCryptoServiceProvider to generate better (and cryptographically secure) random numbers.
View BetterRandom.cs
using System;
using System.Security.Cryptography;
namespace BetterRandomNumbers
// BetterRandom.cs
// This class implements a random number generator that is based off the Windows "Next Generation" cryptographically secure
// random number generator. It inherits from the base Random class, so can be used as a "drop-in" replacement for the
// built-in .NET System.Security.Random class, but providing a superior quality of random numbers.
public class BetterRandom : Random, IDisposable

Keybase proof

I hereby claim:

  • I am craigtp on github.
  • I am craigtp ( on keybase.
  • I have a public key whose fingerprint is 8FBD 50F4 7D2C E90F 95D6 1B27 3965 4610 07EB B49F

To claim this, I am signing this object:

craigtp / .hgignore
Last active Dec 5, 2017
Standard Visual Studio .hgignore file for Mercurial
View .hgignore
syntax: glob
craigtp / .gitignore
Last active Nov 29, 2017
Standard Git gitignore file
View .gitignore
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
craigtp / touch.ps1
Created Sep 23, 2017
Windows Touch - Update Last Write / Modified Date of files recursively.
View touch.ps1
gci -recu -inc "*.*" | % { $_.LastWriteTime = Get-Date }
craigtp / NumericHelpers.cs
Last active Apr 21, 2017
Provides a function that will allow two imprecise floating point numbers to be compared for "near" equality and also an "IsNumeric" function.
View NumericHelpers.cs
public static class NumericHelpers
// Float point maths is whack. We can't check for absolute equality as floating point numbers are imprecise
// and are subject to rounding issues (See:
// Therefore, we can't check for absolute equality, but instead we have to need to check for values being
// "nearly" equal, which allows a small margin of error (i.e. something known as the "Epsilon" value for
// the given data type for this CPU that this code is running on).
public static bool NearlyEqual(double a, double b, double epsilon)
var absA = Math.Abs(a);
craigtp / ShortCodes.cs
Last active Mar 21, 2017
Short code generator.Converts a long integer to a "short code" (a seemingly random string of characters - as seen on many popular URL Shortener utilities.) and vice-versa.See:
View ShortCodes.cs
using System;
namespace ShortCodes
public static class ShortCodes
// You may change the "shortcode_Keyspace" variable to contain as many or as few characters as you
// please. The more characters that are included in the "shortcode_Keyspace" constant, the shorter
// the codes you can produce for a given long.
private static string shortcodeKeyspace = "abcdefghijklmnopqrstuvwxyz0123456789";
You can’t perform that action at this time.