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
static class EventStoreConnectionExtensions | |
{ | |
public static Task<EventStoreRxSubscription> SubscribeToAll(this EventStoreConnection connection, bool resolveLinkTos) | |
{ | |
return Task<EventStoreRxSubscription>.Factory.StartNew(() => { | |
var subject = new Subject<ResolvedEvent>(); | |
var subscriptionTask = connection.SubscribeToAll(resolveLinkTos, subject.OnNext, () => subject.OnError(new SubscriptionDroppedException())); | |
subscriptionTask.Wait(); |
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
open System | |
let isDivisibleBy seq n = | |
seq | |
|> Seq.forall (fun x -> n % x = 0) | |
Seq.unfold (fun x -> Some(x, x + 20)) 20 | |
|> Seq.find (isDivisibleBy [|1 .. 20|]) |
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
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
yellow() { tput setaf 3; cat; tput sgr0; } | |
green() { tput setaf 2; cat; tput sgr0; } | |
cyan() { tput setaf 6; cat; tput sgr0; } | |
alias ll='ls -lhA' | |
alias g='git' | |
alias c='clear' | |
alias d='docker' | |
alias reload='source ~/.bash_profile' | |
alias v='vim' | |
source ~/git-completion.bash |
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); |