Skip to content

Instantly share code, notes, and snippets.

View danielrbradley's full-sized avatar

Daniel Bradley danielrbradley

View GitHub Profile
@danielrbradley
danielrbradley / EnumDropdownExtenstions.cs
Created June 21, 2012 10:56
ASP.NET MVC Enumeration Dropdown Extensions
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace System.Web.Mvc.Html
{
@danielrbradley
danielrbradley / AsyncAsserts.cs
Last active January 4, 2016 02:27
Custom Throws assert for the NUnit framework for handling async code.
namespace NUnit.Framework
{
using System;
using System.Threading.Tasks;
using NUnit.Framework;
public static class AsyncAsserts
{
/// <summary>
@danielrbradley
danielrbradley / uk-number-plate-validation.md
Last active April 4, 2024 09:36
Regular Expression to Validate UK Number Plates

Regular Expression to Validate UK Number Plates

Regular Expression

(?<Current>^[A-Z]{2}[0-9]{2}[A-Z]{3}$)|(?<Prefix>^[A-Z][0-9]{1,3}[A-Z]{3}$)|(?<Suffix>^[A-Z]{3}[0-9]{1,3}[A-Z]$)|(?<DatelessLongNumberPrefix>^[0-9]{1,4}[A-Z]{1,2}$)|(?<DatelessShortNumberPrefix>^[0-9]{1,3}[A-Z]{1,3}$)|(?<DatelessLongNumberSuffix>^[A-Z]{1,2}[0-9]{1,4}$)|(?<DatelessShortNumberSufix>^[A-Z]{1,3}[0-9]{1,3}$)|(?<DatelessNorthernIreland>^[A-Z]{1,3}[0-9]{1,4}$)|(?<DiplomaticPlate>^[0-9]{3}[DX]{1}[0-9]{3}$)

For use in JavaScript (with named groups removed):

(^[A-Z]{2}[0-9]{2}\s?[A-Z]{3}$)|(^[A-Z][0-9]{1,3}[A-Z]{3}$)|(^[A-Z]{3}[0-9]{1,3}[A-Z]$)|(^[0-9]{1,4}[A-Z]{1,2}$)|(^[0-9]{1,3}[A-Z]{1,3}$)|(^[A-Z]{1,2}[0-9]{1,4}$)|(^[A-Z]{1,3}[0-9]{1,3}$)|(^[A-Z]{1,3}[0-9]{1,4}$)|(^[0-9]{3}[DX]{1}[0-9]{3}$)
@danielrbradley
danielrbradley / windows-software-installation.md
Last active December 8, 2016 12:21
Windows software installation

Windows Software Installation

Standard

  • Chrome
  • Opera
  • Firefox
  • Notepad++
    • View -> Show Symbol -> Show White Space and Tab
    • Settings -> Preferences -> Tab Settings -> Tick "Replace by space"
  • Settings -> Preferences -> Editing -> Untick "Display bookmark"

CarolR

The aim of CarolR is to play synchronised, real-time, polyphonic music from an orchestra of devices in the same area, to create an immersive, collaborative, Christmas music experience.

Challenges

In the design of such a system, we had several challenges to overcome:

  • Live performance music output
  • Encoding and programming of synchronised, muti-track music
@danielrbradley
danielrbradley / JasmineTemplates.DotSettings
Created May 21, 2014 13:11
Jasmine templates for ReSharper
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=9FFD516F2767AE4AAFBB8FA1580513C8/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=9FFD516F2767AE4AAFBB8FA1580513C8/Shortcut/@EntryValue">it</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=9FFD516F2767AE4AAFBB8FA1580513C8/Description/@EntryValue">Jasmine Spec</s:String>
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=9FFD516F2767AE4AAFBB8FA1580513C8/Text/@EntryValue">it('$description$', function() { $END$ });</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=9FFD516F2767AE4AAFBB8FA1580513C8/Reformat/@EntryValue">True<
@danielrbradley
danielrbradley / TestController.fs
Last active August 29, 2015 14:06
Optional query parameters in WebAPI with F#
module Web
open System.Web.Http
[<AllowNullLiteral>]
type QueryModel() =
member val Top = 50 with get, set
member val Skip = 0 with get, set
[<RoutePrefix("api/test")>]
@danielrbradley
danielrbradley / IsinValidation.fs
Created December 6, 2016 16:33
Validate an ISIN (International Securities Identification Number) in F#
module Isin
open System.Text.RegularExpressions
// See: http://en.wikipedia.org/wiki/International_Securities_Identification_Number
[<Literal>]
let private AsciiZero = 48
[<Literal>]
let private AsciiNine = 57
@danielrbradley
danielrbradley / 1-plain-function.fs
Created December 9, 2016 15:53
3 ways of organising F# functions related to a type
module VendingMachine
type Coin = Quarter | Dime | Nickel
let valueOf coin =
match coin with
| Quarter -> 0.25m
| Dime -> 0.10m
| Nickel -> 0.05m
@danielrbradley
danielrbradley / unsafe.fsx
Last active January 1, 2017 09:12
Types instead of Hungarian notation
// Response to https://www.joelonsoftware.com/2005/05/11/making-wrong-code-look-wrong/
// How to use types in place of naming conventions
module Unsafe
// What different variations do we want to handle?
type Encodable =
| Safe of string
| Unsafe of string
// Wrap our Request method to always mark the output as unsafe