Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
ChrisMcKee / Repository.cs
Created January 4, 2013 11:41
Generic Repository Interface and implementation. NHIBERNATE
namespace Core.Repository
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
public interface IRepository<T> where T : class
{
bool Add(T entity);
@ChrisMcKee
ChrisMcKee / restoreDB.sql
Created March 29, 2021 16:42 — forked from RobsonAutomator/restoreDB.sql
restore RDS database from S3
-- Change [bucket] with your bucket name
exec msdb.dbo.rds_restore_database
@restore_db_name='Sitecore_Analytics',
@s3_arn_to_restore_from='arn:aws:s3:::[bucket]/Sitecore_Analytics.bak';
exec msdb.dbo.rds_restore_database
@restore_db_name='Sitecore_Core',
@s3_arn_to_restore_from='arn:aws:s3:::[bucket]/Sitecore_Core.bak';
@ChrisMcKee
ChrisMcKee / ShortIds.cs
Created August 24, 2020 16:38
Sizeable seed based ID
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
namespace HashTime
{
class Program
{
@ChrisMcKee
ChrisMcKee / pack-man.ps1
Last active July 31, 2020 14:04 — forked from rjmurillo/pack-man.ps1
Useful Package Manager console commands
Get-Project –All | Add-BindingRedirect
# On large projects commands like `Update-Package -Reinstall` can take HOURS
# If the updates are broken up, then don't lock up the IDE and complete much faster (minutes vs hours)
# Reinstall all packages that match a specific targetFramework
# Useful when retargeting
gci -recurse packages.config | % { [xml]$XmlDocument = Get-Content -Path $_.FullName; $XmlDocument.packages.package | ? { $_.targetFramework -eq 'net462' } | select id | sort-object -unique | % { update-package -reinstall $_.id } }
# Reinstall all packages that have been marked with requireReinstallation
@ChrisMcKee
ChrisMcKee / upgrade-docker.sh
Created June 23, 2020 10:55
Upgrade docker to a specific version
#!/bin/bash
docker_version=19.03.11
pkg_version=$(apt-cache madison docker-ce | grep ${docker_version} | head -n 1 | cut -d ' ' -f 4)
apt-get install -y -q docker-ce=${pkg_version} docker-ce-cli=${pkg_version}
@ChrisMcKee
ChrisMcKee / uk-number-plate-validation.md
Created April 9, 2020 10:32 — forked from danielrbradley/uk-number-plate-validation.md
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}$)
@ChrisMcKee
ChrisMcKee / php-md5-hash-in-c#
Created January 4, 2013 13:49
PHP MD5 Hash in C# Most implementations of the PHP md5() function in C# produce a different result; this produces the correct one.
public static string PHPMd5Hash(string pass)
{
using (MD5 md5 = MD5.Create())
{
byte[] input = Encoding.UTF8.GetBytes(pass);
byte[] hash = md5.ComputeHash(input);
return BitConverter.ToString(hash).Replace("-", "");
}
}
@ChrisMcKee
ChrisMcKee / CSharp Common Extensions.cs
Created January 4, 2013 11:24
Common Extensions for CSharp (.net)
namespace Helper
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
@ChrisMcKee
ChrisMcKee / pointless_1321343.cs
Last active November 11, 2019 00:15
Pointless string replace benchmark. Just for fun (D commented out because, urgh)
namespace ConsoleApplication1
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
public class Program
{
@ChrisMcKee
ChrisMcKee / BuildWarningReportGenerator.ps1
Last active August 2, 2019 10:41 — forked from tarwn/BuildWarningReportGenerator.ps1
Powershell script for TeamCity build warnings (fixed for 2018 / removed guest from end of urls used to fetch last builds log file)
Param
(
[parameter(Mandatory=$true)][string]
$BuildLogPath,
[parameter(Mandatory=$true)][string]
$BuildCheckoutDirectoryPath,
[parameter()][string]
$BuildArtifactRepositoryUrl