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.Diagnostics; | |
using System.Text.RegularExpressions; | |
namespace Diuturnal { | |
/// <summary> | |
/// Represents a UK National Insurance number. | |
/// </summary> | |
/// <remarks> | |
/// Based on the specification found at http://www.hmrc.gov.uk/manuals/nimmanual/NIM39110.htm. |
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; | |
namespace Diuturnal { | |
[Serializable] | |
public class Range<T> where T : IComparable<T> { | |
private T _start; | |
private T _end; | |
public Range(T first, T second) { | |
if (first.CompareTo(second) > 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
<html> | |
<head> | |
<title>LocalStorage fundamentally broken in IE11</title> | |
</head> | |
<body> | |
String length: <input id="length" type="text" value="2000" /><br /> | |
<button onclick="set(null);">Clear</button> | |
<button onclick="store('A');">Store w/ A</button> | |
<button onclick="store('B');">Store w/ B</button> | |
<button onclick="show();">Show value</button> |
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
let emptyIfZero f x = | |
match x with | |
| 0 -> [] | |
| _ -> f x | |
let elementsBetween0And20 = emptyIfZero (fun x -> [ string x ]) | |
let elementsBetween21And99 x = string (x - (x % 10)) :: elementsBetween0And20 (x % 10) | |
let ifGreaterThan y f g x = if x > y then f x else g x | |
let elementsFor2DigitNumber = ifGreaterThan 20 elementsBetween21And99 elementsBetween0And20 | |
let elementsBetween100And999 x = string (x / 100) :: "hundred" :: emptyIfZero (fun x -> "and" :: elementsFor2DigitNumber x) (x % 100) |
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
<asp:FormView ID="fvApplication" runat="server"> | |
<ItemTemplate> | |
<h1>Application Form</h1> | |
<!-- Lots of detail about application in here --> | |
<asp:LoginView ID="lvOptions" runat="server"> | |
<RoleGroups> | |
<asp:RoleGroup Roles="Provider"> | |
<ContentTemplate> | |
<asp:LinkButton runat="server" OnClick="Offer_Click" | |
Visible='<%# ApplicationStatus.Sent == (ApplicationStatus) Eval("Status") %>'>Make Offer</asp:LinkButton> |
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 Diuturnal.Utility { | |
public class DirectoryHelper { | |
public static FileInfo[] GetFiles(DirectoryInfo directory, | |
params string[] searchPatterns) { | |
List<FileInfo> allFiles = new List<FileInfo>(); | |
foreach (string pattern in searchPatterns) { | |
allFiles.AddRange(directory.GetFiles(pattern)); | |
} |
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 Diuturnal.Utility { | |
[Serializable] | |
public abstract class DoubleKeyedCollection<TKey, TSecondKey, TItem> | |
: KeyedCollection<TKey, TItem> { | |
private Dictionary<TSecondKey, TKey> _secondKeyIndex = | |
new Dictionary<TSecondKey, TKey>(); | |
public TItem GetItem(TSecondKey secondKey) { |
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 Diuturnal.Utility { | |
[Serializable] | |
public struct Postcode { | |
private const string ValidationString = | |
@"^\s*(?<out>[A-Z]{1,2}[0-9R][0-9A-Z]?) *(?<in>[0-9][A-Z-[CIKMOV]]{2})\s*$"; | |
private static readonly Regex _validator = | |
new Regex(ValidationString); | |
public static readonly Postcode Empty = | |
new Postcode(string.Empty, string.Empty); | |
private string _outCode; |
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
// Whip up a fake HttpRequest | |
HttpRequest httpRequest = new HttpRequest("default.aspx", "http://www.diuturnal.com/default.aspx", string.Empty); | |
// Have to access the Headers collection first as this creates the internal collection we're about to hack | |
NameValueCollection headers = httpRequest.Headers; | |
// Accessing Headers property above will have created the private _headers member, so now we can grab it | |
headers = (NameValueCollection) httpRequest.GetType().GetField("_headers", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(httpRequest); | |
PropertyInfo readOnlyInfo = headers.GetType().GetProperty("IsReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); |
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 CompilerFail { | |
public int[] Numbers { set { ; } } | |
public int FirstNumber { get { return Numbers[0]; } } | |
} |