Skip to content

Instantly share code, notes, and snippets.

craigtp /
Created May 1, 2020
Notes on Udi Dahan's Advanced Distributed System Design Course

Advanced Distributed System Design Course - Udi Dahan

Notes by Craig Phillips

Fallacies of Distributed Computing

  • There are 11 fallacies of Distributed Computing:
    1. The network is reliable
    2. Latency isn’t a problem
    3. Bandwidth isn’t a problem
    4. The network is secure
    5. The topology won’t change
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
craigtp / LargestDBs
Last active Apr 27, 2021
List the largest databases on a SQL Server instance
View LargestDBs
SELECT DB_NAME(database_id) AS DatabaseName,
Name AS Logical_Name,
Physical_Name, (size*8)/1024 SizeMB
FROM sys.master_files
craigtp / CleanUpTemporaryASPNETFiles.ps1
Last active Apr 7, 2021
Clean Up Temporary ASP.NET Files with Powershell
View CleanUpTemporaryASPNETFiles.ps1
# Run this as Administrator
net stop w3svc
Get-ChildItem "C:\Windows\Microsoft.NET\Framework*\v*\Temporary ASP.NET Files" -Recurse | Remove-Item -Recurse -Force
net start w3svc
craigtp / ShortCodes.cs
Last active Mar 30, 2020
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";
craigtp / ProbabilityKata2
Last active May 28, 2019 — forked from gregoryyoung/ProbabilityKata2
Probability Kata part 2
View ProbabilityKata2
OK so now you have implemented the kata. Your tests should look something like this:
We can say that the tests define the object "in a calculus of itself".
They are not state based tests, they define how the behaviours of the object interact with each other.
To see the real value of this let's introduce some change ... I hear real system's do this occasionally.
Because this is a high performance system decimal math is too slow. You now need to use floats instead.
Need help on floating point math? Check out:
craigtp / ProbabilityKata
Created May 27, 2019 — forked from gregoryyoung/ProbabilityKata
Greg Young's Probability Kata
View ProbabilityKata
Value objects are an important concept in DDD. This kata is made both to learn value objects and to learn better ways of testing.
Write a probability value object. It should contain the following methods:
Probability CombinedWith(Probability)
Probability InverseOf()
Probability Either(Probability)
if you forget your probability math:
Either:P(A) + P(B) - P(A)P(B)
CombinedWith: P(A)P(B)
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 / 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 }