This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
let sumOfSquares = | |
[|1 .. 100|] | |
|> Array.map (fun x -> x * x) | |
|> Array.sum | |
let squareOfSum = | |
[|1 .. 100|] | |
|> Array.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
let isPrime (n : int64) = | |
let upperBound = n |> float |> sqrt |> int64 | |
seq {2L .. upperBound} | |
|> Seq.forall (fun x -> n % x <> 0L) | |
Seq.unfold (fun x -> Some(x, x + 1L)) 1L | |
|> Seq.filter isPrime | |
|> Seq.nth 10001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum [x | x <- [1..999], mod x 3 == 0 || mod x 5 == 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Instantiates TClass using a compiled lambda expression and caches it. This assumes a parameterless constructor. | |
/// </summary> | |
/// <typeparam name="TClass">The type of the class to be instantiated.</typeparam> | |
internal static class New<TClass> where TClass : class | |
{ | |
public static readonly Func<TClass> Instance = Expression.Lambda<Func<TClass>>(Expression.New(typeof(TClass))).Compile(); | |
/// <summary> | |
/// Allows a class to be instantiated using a parameterised constructor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public static class TypeSwitch | |
{ | |
public class CaseInfo | |
{ | |
public bool IsDefault { get; set; } | |
public Type Target { get; set; } | |
public Func<object, string> Action { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
name | |
, filename | |
, convert(decimal(12,2),round(a.size/128.000,2)) as FileSizeMB | |
, convert(decimal(12,2),round(fileproperty(a.name,'SpaceUsed')/128.000,2)) as SpaceUsedMB | |
, convert(decimal(12,2),round((a.size-fileproperty(a.name,'SpaceUsed'))/128.000,2)) as FreeSpaceMB | |
from dbo.sysfiles a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @TableName sysname | |
SET @TableName = 'table_name' | |
SELECT OBJECT_NAME(object_id) as [Table Name], format(SUM(row_count), '###,###') AS [Row Count] | |
FROM sys.dm_db_partition_stats | |
WHERE object_id = OBJECT_ID(@TableName) | |
AND index_id < 2 | |
GROUP BY OBJECT_NAME(object_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class ValueObject<T> : IEquatable<T> where T : ValueObject<T> | |
{ | |
private List<PropertyInfo> Properties { get; } | |
protected ValueObject() | |
{ | |
Properties = new List<PropertyInfo>(); | |
} | |
public override Boolean Equals(object obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set PowerShell execution policy | |
Set-ExecutionPolicy Unrestricted | |
Set-ExecutionPolicy Bypass -Scope Process -Force | |
# Install Chocolatey | |
ex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
# Install Boxstarter | |
. { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configure Windows | |
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar | |
Update-ExecutionPolicy Unrestricted | |
# cinst -y Microsoft-Hyper-V-All -source windowsFeatures | |
#Visual Studio 2017 Community Edition | |
cinst -y visualstudio2017community |