View gist:1335363
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
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
var x = new Number<int>(3); | |
var y = new Number<int>(-4); | |
Number<int> result = x + y; // result is 7 | |
Console.WriteLine(result); |
View jquery-validation-engine_with_select2
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
<script type="text/javascript"> | |
// This is a workaround for using jquery-validation-engine with select2 for 'required' validation | |
// Since the _required validator for jquery-validation-engine uses .val() to see | |
// if there's anything in the input, we can hijack .val() for the container created by select2\ | |
// and redirect it to the value of the hidden element | |
// jquery-validation-engine throws an error if the thing we're validating doesn't have an id | |
// so we'll put one on the container created by select2 (that way, the positioning of the prompts | |
// will be correct) | |
$('#mySelector').select2('container').attr('id', 'mySelectorValidate'); |
View gist:3880921
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
var graph = new ConversionGraph(); | |
var meter = new Unit("meter"); | |
var feet = new Unit("foot"); | |
graph.AddConversion(Conversions.One(meter).In(feet).Is(3.28084M)); |
View convertinator_interfaces.cs
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 interface IConversion | |
{ | |
IEnumerable<IConversionStep> Steps { get; } | |
void AddStep(IConversionStep step); | |
Conversion Reverse(); | |
} | |
public interface IConversionStep | |
{ | |
decimal Apply(decimal input); |
View gist:3881027
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
var graph = new ConversionGraph(); | |
var meter = new Unit("meter"); | |
var feet = new Unit("foot"); | |
var kilometer = new Unit("kilometer"); | |
var inches = new Unit("inch"); | |
graph.AddConversion( | |
Conversions.From(kilometer).To(meter).MultiplyBy(1000M), | |
Conversions.From(meter).To(feet).MultiplyBy(3.28084M), |
View gist:3881051
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
var celcius = new Unit("Celcius") | |
.IsAlsoCalled("celcius", "Centigrade", "centigrade", "degrees Celcius", "degrees Centigrade") | |
.IsAlsoCalled("celcuis") // typo from legacy system | |
.CanBeAbbreviated("°C") | |
.PluralizeAs("°C"); |
View gist:3881054
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
var temperature = new ConversionGraph(); | |
var fahrenheit = new Unit("degrees Fahrenheit") | |
.IsAlsoCalled("Fahrenheit") | |
.CanBeAbbreviated("°F") | |
.PluralizeAs("°F"); | |
temperature.AddConversion( | |
Conversions.From(fahrenheit).To(celcius).Subtract(32).MultiplyBy(5M / 9M)); |
View AddressController.cs
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 AddressController : ApiController | |
{ | |
public IEnumerable<AddressViewModel> Get() | |
{ | |
return Addresses.Get(); | |
} | |
[Route(Name = "GetAddress")] | |
public AddressViewModel Get(int id) | |
{ |
View AddressController.cs
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> | |
/// Endpoints for managing Addresses | |
/// </summary> | |
public class AddressController : ApiController | |
{ | |
/// <summary> | |
/// Gets a list of addresses in the system | |
/// </summary> | |
/// <returns>IEnumerable<AddressViewModel>.</returns> | |
public IEnumerable<AddressViewModel> Get() |
View RefactorableSettingsTemplate.tt
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
<#@ template language="C#" hostspecific="True" #> | |
<#@ assembly name="System.Xml" #> | |
<#@ import namespace="System.IO" #> | |
<#@ import namespace="System.Xml" #> | |
<# | |
XmlDocument doc = new XmlDocument(); | |
doc.Load(Path.Combine(Path.GetDirectoryName(Host.TemplateFile), "Settings.settings")); | |
string xmlns = doc.DocumentElement.Attributes["xmlns"].Value; | |
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable); |
OlderNewer