I hereby claim:
- I am craigtp on github.
- I am craigtp (https://keybase.io/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:
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: http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html) | |
// 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); |
gci -recu -inc "*.*" | % { $_.LastWriteTime = Get-Date } |
I hereby claim:
To claim this, I am signing this object:
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 |
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) |
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: http://www-users.math.umd.edu/~jkolesar/mait613/floating_point_math.pdf |
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"; |
# 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 |
(dir -include *.cs -recurse | select-string .).Count |
-- Create a temporary table in an in-memory variable simply to allow the | |
-- select statement to output multiple rows. | |
DECLARE @TestTable TABLE (uniqueID int) | |
INSERT INTO @TestTable | |
SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL | |
SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 | |
-- The main Select statement that shows different correct (and incorrect) ways to generate | |
-- "random" things in a set-based select statement. | |
SELECT |