Skip to content

Instantly share code, notes, and snippets.

View michaelnoonan's full-sized avatar

Michael Noonan michaelnoonan

View GitHub Profile
WITH LatestUsage AS (
SELECT LicenseSerial, MAX(LastUpdated) AS LastUpdated
FROM UsageRecord
GROUP BY LicenseSerial
),
TargetOperatingSystems As (
SELECT usage.LicenseSerial, TargetOs.Os, TargetOs.[Count]
FROM UsageRecord usage
INNER JOIN LatestUsage latestUsage ON usage.LicenseSerial = latestUsage.LicenseSerial AND usage.LastUpdated = latestUsage.LastUpdated
CROSS APPLY OPENJSON(usage.[JSON]) WITH (TargetOperatingSystems NVARCHAR(MAX) AS JSON) AS UsageJson
@michaelnoonan
michaelnoonan / ConfigurationAutofacModule.cs
Created May 9, 2016 01:12
Configuration example: ReleaseBot
using System.Configuration;
using System.Linq;
using Autofac;
using ReleaseBot.Core.Configuration;
using ReleaseBot.Core.Integration.AzureStorage;
using ReleaseBot.Core.Integration.GitHub;
using ReleaseBot.Core.Integration.Octofront;
using ReleaseBot.Core.Integration.Octopus;
namespace ReleaseBot.SlackLink
@michaelnoonan
michaelnoonan / SemanticVersionInfo.cs
Created September 1, 2015 22:54
GitVersion SemanticVersionInfo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace GitVersion
{
/// <summary>
/// http://gitversion.readthedocs.org/en/latest/more-info/variables/
/// </summary>
@michaelnoonan
michaelnoonan / AppServerCommandRouteAttribute.cs
Last active August 29, 2015 14:06
Attribute Routing for Nimbus
[AttributeUsage(AttributeTargets.Class)]
public class AppServerCommandRouteAttribute : Attribute
{
public AppServerCommandRouteAttribute(string route)
{
if (string.IsNullOrWhiteSpace(route)) throw new ArgumentNullException("route");
Route = ("appserver." + route).ToLowerInvariant();
}
@michaelnoonan
michaelnoonan / WindowsServiceLib.psm1
Created July 10, 2013 01:30
Useful Deployment Scripts
Set-StrictMode -Version Latest
$libPath = (Split-Path -Parent $MyInvocation.MyCommand.Definition)
Import-Module $libPath\SecurityLib.psm1
function New-WindowsService {
param
(
[Parameter(Mandatory=$True,Position=0,HelpMessage="The name of the Windows Service")]
[string]$serviceName,
@michaelnoonan
michaelnoonan / gist:5566257
Last active December 6, 2019 01:55
Stop Loss Kata
Stop Loss Kata (original source: https://gist.github.com/gregoryyoung/1500720)
Developing solutions when time is involved is tricky, but testing when time is involved is yet another problem.
A trailing stop loss is a term used in financial trading. For a very in depth explanation you can read here (http://www.investopedia.com/articles/trading/03/080603.asp) and here (http://en.wikipedia.org/wiki/Order_(exchange)#Stop_orders), however we do not need a huge amount of background in order to do the kata as we are going to limit the problem a bit.
Say you buy into a stock at $10. You want it to automatically get sold if the stock goes below $9 to limit your exposure. This threshold is set by subtracting 10% from the original position. The term "trailing" means that if the price goes up to $11 then the sell point becomes $10, if it goes up to $15 then the sell point becomes $14, maintaining the original 10% margin of $1.
The kata is to create something that implements a trailing stop loss and to do it with TDD.
@michaelnoonan
michaelnoonan / OctoDeploy.ps1
Created January 16, 2013 01:43
Deploying releases using Octopus Deploy from TeamCity
param
(
[string] $EnvironmentName,
[string] $Version,
[string] $ProjectName,
[string] $OctopusApiKey,
[string] $OctopusServerUrl,
[string] $ReleaseNotes
)