I hereby claim:
- I am CallumWatkins on github.
- I am callumwatkins (https://keybase.io/callumwatkins) on keybase.
- I have a public key whose fingerprint is 7A2C 9986 AF66 4A9E 2A8D 869F C71C 342D A44D AB84
To claim this, I am signing this object:
Verifying that +callumwatkins is my blockchain ID. https://onename.com/callumwatkins |
I hereby claim:
To claim this, I am signing this object:
/// <summary> | |
/// Checks whether any given integer is located in the range between two other integers. | |
/// </summary> | |
/// <param name="i">The integer to check.</param> | |
/// <param name="min">The minimum value of the range.</param> | |
/// <param name="max">The maximum value of the range.</param> | |
/// <param name="inclusive">Whether or not the minumum and maximum values are included in the range.</param> | |
/// <returns>Boolean</returns> | |
private static bool IsInIntegerRange(this int i, int min, int max, bool inclusive = true) | |
{ |
public void SearchWindowsExplorer(string query, string location = null) | |
{ | |
if (location != null && !Directory.Exists(location)) | |
{ | |
throw new ArgumentException("Directory does not exist.", "location"); | |
} | |
string uri = "search:query=" + Uri.EscapeDataString(query) + | |
(location == null ? string.Empty : "&crumb=location:" + Uri.EscapeDataString(location)); | |
Process.Start(uri); | |
} |
using System; | |
using System.IO; | |
/// <summary> | |
/// Creates all directories and subdirectories unless they already exist and creates or overwrites a file in the specified path. | |
/// </summary> | |
/// <param name="path">The full path of the file.</param> | |
public static FileStream CreateFileAndDirectory(string path) | |
{ | |
if (path == null) { throw new ArgumentNullException(nameof(path)); } |
public static class Compass | |
{ | |
public enum CompassDirection { N, NbE, NNE, NEbN, NE, NEbE, ENE, EbN, E, EbS, ESE, SEbE, SE, SEbS, SSE, SbE, S, SbW, SSW, SWbS, SW, SWbW, WSW, WbS, W, WbN, WNW, NWbW, NW, NWbN, NNW, NbW } | |
public enum CompassPoints { Four = 4, Eight = 8, Sixteen = 16, ThirtyTwo = 32 } | |
public static Dictionary<CompassDirection, string> CompassDirections | |
{ | |
get | |
{ | |
return new Dictionary<CompassDirection, string>() |
/// <summary> | |
/// Calculates the sum of all the integers in the range between two integers. | |
/// </summary> | |
/// <param name="start">The starting integer.</param> | |
/// <param name="end">The ending integer.</param> | |
/// <param name="exclusive">Whether or not the <paramref name="start"/> and <paramref name="end"/> integers are excluded from the sum.</param> | |
/// <returns>Returns the sum of the integers in the range.</returns> | |
private static long SumBetween(int start, int end, bool exclusive = false) | |
{ | |
if (start > end) { throw new ArgumentException("End value must be more than or equal to start value."); } |
/// <summary> | |
/// Swaps two variables of type T with one another. | |
/// </summary> | |
/// <typeparam name="T">The type of both variables. Must implement IEquatable.</typeparam> | |
/// <param name="a">The first variable.</param> | |
/// <param name="b">The second variable.</param> | |
static void Swap<T>(ref T a, ref T b) where T : IEquatable<T> | |
{ | |
if (a.Equals(b)) return; | |
T tempA = a; |
using Newtonsoft.Json; | |
// Requires Newtonsoft's Json.NET | |
// http://www.newtonsoft.com/json | |
/// <summary> | |
/// Perform a deep clone of the object, using Json as a serialisation method. | |
/// </summary> | |
/// <typeparam name="T">The type of object being cloned.</typeparam> | |
/// <param name="source">The object instance to clone.</param> | |
/// <returns>The cloned object.</returns> |
/// <summary> | |
/// Tests the speed of an action. | |
/// </summary> | |
/// <param name="action">The method to be tested.</param> | |
/// <param name="iterations">The number of times to perform the action in each test.</param> | |
/// <param name="repetitions">The number of times to repeat the test.</param> | |
/// <param name="name">The name of the test.</param> | |
/// <param name="warmupMilliseconds">The number of milliseconds to warm up for.</param> | |
static void TestSpeed(Action action, long iterations, int repetitions, string name, int warmupMilliseconds = 5000) | |
{ |