This file contains hidden or 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
namespace Mvc.ResourceLoader.Util { | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
public class JoinedStreamReader : Stream { |
This file contains hidden or 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
################################################################################################################################ | |
# | |
# Script Name : SmoDb | |
# Version : 1.0 | |
# Author : Vince Panuccio | |
# Purpose : | |
# This script generates one SQL script per database object including Stored Procedures,Tables,Views, | |
# User Defined Functions and User Defined Table Types. Useful for versionining a databsae in a CVS. | |
# | |
# Usage : |
This file contains hidden or 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
// Usage | |
var intResult = Parse("1", 0, int.TryParse); // Returns 1 | |
var dateResult = Parse("asdf", DateTime.Now, DateTime.TryParse); // Returns 18/07/2012 1:39:06 PM | |
delegate TParsedValue ParseFunc<T, U, TParsedValue>(T input, out U output); | |
static V Parse<T, V>(T valueToBeParsed, V defaultVal, ParseFunc<T, V, bool> dele) { | |
V result; |
This file contains hidden or 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
$uri = 'http://www.tsqltidy.com/SQLTidy.asmx' | |
$proxy = New-WebServiceProxy -Uri $uri -class FormatSQL -Namespace FormatSQL | |
#Warning - Will format file contents and overwrite the original file. Use with caution. | |
gci *.sql | % { $content = $proxy.ParseSQL((get-content $_.FullName)); Set-Content $_.FullName $content; } |
This file contains hidden or 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 static class TestHelpers | |
{ | |
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue) | |
{ | |
ShouldEqualWithDiff(actualValue, expectedValue, DiffStyle.Full, Console.Out); | |
} | |
public static void ShouldEqualWithDiff(this string actualValue, string expectedValue, DiffStyle diffStyle) | |
{ | |
ShouldEqualWithDiff(actualValue, expectedValue, diffStyle, Console.Out); |
This file contains hidden or 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
[Test] | |
public void TestEmpty() | |
{ | |
CollectionAssert.AreEqual( | |
new int[0].MinsBy(i => i), | |
new int[0]); | |
} | |
[Test] | |
public void TestPreserveOrderAndValue() |
This file contains hidden or 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
// Only let input Observable fire every 'n' seconds at most | |
// but unlike Throttle, items fire immediately when they aren't | |
// rate-limited. | |
public IObservable<T> RateLimit<T>(this IObservable<T> This, TimeSpan interval, IScheduler scheduler) | |
{ | |
var slot = default(IObservable<Unit>); | |
var input = This.Publish().RefCount(); | |
return input.Window(input, _ => { | |
if (slot != null) return slot; |
This file contains hidden or 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
// Full credit goes to Wes Dyer http://blogs.msdn.com/b/wesdyer/archive/2008/01/11/the-marvels-of-monads.aspx | |
// Explanation of how query expressions are translated in to extension method syntax. | |
public class Identity<T> | |
{ | |
public T Value { get; private set; } | |
public Identity(T value) { this.Value = value; } | |
public static implicit operator Identity<T>(T value) { | |
return new Identity<T>(value); |
This file contains hidden or 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
void Main() | |
{ | |
// An implementation of the Where method using the SelectMany() method. | |
TestWhere(); | |
// An implementation of Join using the SelectMany() method. | |
TestJoin(); | |
} | |
public static IEnumerable<T> Where<T>(IEnumerable<T> stuffs, Func<T, bool> predicate) |
This file contains hidden or 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; | |
using System.Collections.Generic; | |
using System.Linq.Expressions; | |
using System.Reflection; | |
namespace Bleroy.Helpers { | |
public static class NotNull { | |
public static TProp Get<TSource, TProp>(this TSource source, Expression<Func<TSource, TProp>> property) where TSource : class { | |
if (source == null) return default(TProp); | |
var current = property.Body; |
OlderNewer