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 class ClientWrapperUsage | |
{ | |
public static void main(string[] args) | |
{ | |
using(var clientWrapper = new ServiceClientWrapper<ServiceType>()) | |
{ | |
var response = clientWrapper.Channel.ServiceCall(); | |
} | |
} | |
} |
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
Greg's Stop Loss Kata | |
Testing is very hard when time is involved ... | |
A trailing stop loss is a term used in financial trading. For a very in depth explanation you can read here http://www.investopedia.com/articles/trading/03/080603.asp and http://en.wikipedia.org/wiki/Order_(exchange)#Stop_orders | |
However we do not need a huge amount of background in order to do the kata as we are going to limit the problem a bit. | |
The general idea is that when you buy into a stock at a price say $10. You want it to automatically get sold if the stock goes below $9 (-$1). If we use the term "trailing" that means that id the price goes up to $11 then the sell point becomes $10. |
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 static class SelectListExtensionMethods | |
{ | |
/// <summary> | |
/// The SelectListItem to use by default as the placeholder for select lists generated by these extension methods when the user needs to pick a value. | |
/// </summary> | |
public static readonly SelectListItem DefaultEmptySelectListItem = new SelectListItem() { Text = "-- Pick One --", Value = string.Empty }; | |
/// <summary> | |
/// The SelectListItem to use by default as the placeholder for select lists generated by these extension methods when not picking a value is the same as using as of the possible choices (meant for filtering typically) | |
/// </summary> | |
public static readonly SelectListItem AnySelectListItem = new SelectListItem() { Text = "-- Any --", Value = string.Empty }; |
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 class SiteScrape : HttpTaskAsyncHandler | |
{ | |
public override async Task ProcessRequestAsync(HttpContext context) | |
{ | |
using (var http = new HttpClient()) | |
{ | |
var downloadTasks = new List<Task<string>> { | |
http.GetStringAsync("http://bing.com"), | |
http.GetStringAsync("http://google.com"), | |
http.GetStringAsync("http://oredev.org"), |
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; | |
using System.Collections.Generic; | |
using System.Dynamic; | |
using System.Globalization; | |
using System.Linq; | |
using System.Reflection; | |
using System.Web; | |
using System.Web.ModelBinding; | |
namespace VS11BetaTAPWebForms |
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reactive.Concurrency; | |
using System.Reactive.Disposables; | |
using System.Reactive.Linq; | |
using System.Reactive.Subjects; | |
using System.Reactive.Threading.Tasks; | |
using System.Text; | |
using System.Threading; |
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
namespace Casero.Web.Mvc | |
{ | |
using System; | |
using System.Collections.Specialized; | |
using System.Web; | |
using System.Web.Helpers; | |
using System.Web.Mvc; | |
// Checks the User's CSRF token | |
// http://haacked.com/archive/2011/10/10/preventing-csrf-with-ajax.aspx |
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 = 'TableName' | |
declare @Namespace varchar(50) | |
set @Namespace = 'Namespace' | |
declare @prop varchar(max) | |
PRINT 'Imports PetaPoco ' | |
PRINT '' | |
PRINT 'Namespace ' + @Namespace | |
PRINT '<TableName("' + @TableName + '")>' |
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 class FuncServiceLocator | |
{ | |
Dictionary<Tuple<Type, string>, List<Func<object>>> _registry; | |
public void Register(Func<object> factory, Type type, string contract = null) | |
{ | |
var pair = Tuple.Create(type, contract ?? ""); | |
if (!_registry.ContainsKey(pair)) _registry[pair] = new List<Func<object>>(); | |
_registry[pair].Add(factory); |
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
# Test for formaction attribute support in Modernizer. | |
Modernizr.addTest 'formaction', 'formaction' of document.createElement('input') | |
# Shim for formaction attributes on buttons and inputs. | |
$.fn.shimFormAction = -> | |
return this if Modernizr.formaction | |
this.each -> | |
$(this).find 'input,button' | |
.filter '[formaction!=""][formaction]' |
OlderNewer