Skip to content

Instantly share code, notes, and snippets.

View chrisoldwood's full-sized avatar

Chris Oldwood chrisoldwood

View GitHub Profile
@chrisoldwood
chrisoldwood / Test-Driven-SQL-Procedure.sql
Last active January 14, 2016 22:13
The final versions of the example SQL code written during my live-coding Test-Driven SQL talk
if (object_id('pub.ReportBugsPerDeveloper') is not null)
drop procedure pub.ReportBugsPerDeveloper;
go
create procedure pub.ReportBugsPerDeveloper
as
select
su.FirstName + ' ' + su.LastName as FullName,
count(b.BugId) as BugCount
from
@chrisoldwood
chrisoldwood / SimpleDependencyResolver.cs
Created January 14, 2016 21:28
A minimalist IoC container for use with ASP.Net/OWIN.
using System;
using System.Collections.Generic;
using System.Web.Http.Dependencies;
namespace WebApi
{
using TypeFactories = Dictionary<Type, Func<object>>;
public sealed class SimpleDependencyResolver : IDependencyResolver
{
@chrisoldwood
chrisoldwood / CreateAssemblyVersionInfo.txt
Last active May 18, 2016 10:42
Visual C# pre-build step to generate a common AssemblyVersionInfo.cs from a version number defined by a couple of environment variables.
<PreBuildEvent>
if not defined PRODUCT_VERSION set PRODUCT_VERSION=0.0.0
if not defined BUILD_NUMBER set BUILD_NUMBER=1
echo using System.Reflection;&gt;"$(SolutionDir)Source\AssemblyVersionInfo.cs"
echo [assembly: AssemblyVersion("%25PRODUCT_VERSION%25.%25BUILD_NUMBER%25")]&gt;&gt;"$(SolutionDir)Source\AssemblyVersionInfo.cs"
</PreBuildEvent>
@chrisoldwood
chrisoldwood / fixr.py
Created June 2, 2018 23:19
Python script to query the Fixr REST API
import requests
import argparse
import sys
def listVenues():
response = requests.get(f'{baseUrl}/venue?limit=1000&offset=0')
json = response.json()
for venue in json['data']:
id = venue['id']
@chrisoldwood
chrisoldwood / Log-SQL-IO-Stats.ps1
Last active August 6, 2018 12:11
Example of how to capture SQL Server query IO statistics from a .Net based client.
Set-StrictMode -Version Latest
$ErrorActionPreference = 'stop'
$configuration = 'Server=.\SQLEXPRESS;Database=master;Trusted_Connection=True;'
$connection = New-Object System.Data.SqlClient.SqlConnection $configuration
$connection.Open()
$handler = [System.Data.SqlClient.SqlInfoMessageEventHandler] {
param($sender, $event)
@chrisoldwood
chrisoldwood / CheckPackageCache.ps1
Last active November 24, 2018 23:29
Checks the solution's packages folder looking for multiple versions of the same package.
<#
.synopsis
Looks for multiple versions of the same NuGet package in the NuGet
packages folder for a .Net based soluton.
.description
If you check your NuGet dependencies into your source control repository
it's easy for old versions to be left hanging around. This script, a
companion to CheckPackageVersions, highlights where you might have stale
packages left behind.
@chrisoldwood
chrisoldwood / CheckPackageVersions.ps1
Last active November 24, 2018 23:31
Checks all packages.config files looking for version mismatches between different projects.
<#
.synopsis
Scans the packages.config files in a .Net solution looking for multiple
versions of the same package.
.description
Ideally your .Net based solutions should always be using a consistent
set of NuGet packages to avoid subtle bugs. This script, a companion to
CheckPackageCache, analyses all the NuGet packages used by your solution
and tells you if multiple package versions are being referenced.
@chrisoldwood
chrisoldwood / ShowProjectBuildTypes.ps1
Last active November 24, 2018 23:35
List Visual Studio solution file project build configurations.
<#
.synopsis
Shows which build configurations are supported for which projects in a
Visual Studio solution file (.sln).
.description
With a large Visual Studio solution that has more than just the default
build configurations it's easy for them to get out of step. This script
analyses a .sln file and shows you which build configurations are
available for which projects so that you can find inconsistencies.
@chrisoldwood
chrisoldwood / Log-SQL-Plan.ps1
Last active March 29, 2019 10:53
Example for how to get the query plan from SQL Server via .Net code,
Set-StrictMode -Version Latest
$ErrorActionPreference = 'stop'
$instance = '.\SQLEXPRESS'
$database = 'database'
$configuration = "Server=$instance;Database=$database;Trusted_Connection=True;"
$connection = New-Object System.Data.SqlClient.SqlConnection $configuration
$connection.Open()
$command = $connection.CreateCommand()
@chrisoldwood
chrisoldwood / windows10.auto.xml
Last active November 25, 2019 15:10
Example Oz configuration files for creating a Windows 10 VM on QEMU/KVM/libvirt with oz-install.
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DiskConfiguration>
<Disk>
<CreatePartitions>
<CreatePartition>