Skip to content

Instantly share code, notes, and snippets.

View stevenkuhn's full-sized avatar

Steven Kuhn stevenkuhn

View GitHub Profile

Keybase proof

I hereby claim:

  • I am stevenkuhn on github.
  • I am stevenkuhn (https://keybase.io/stevenkuhn) on keybase.
  • I have a public key ASBljJq4I8JmLl_GTa2JNWQcsLo5QVVaXUKU7ZFhhSXFewo

To claim this, I am signing this object:

@stevenkuhn
stevenkuhn / Program.cs
Created November 11, 2015 16:41
Swagger File Generation With Swashbuckle
public class Program
{
public static void Main(string[] args)
{
if (args == null || args.Length == 0) throw new InvalidOperationException("You must specify arguments.");
var path = args[0];
using (var server = TestServer.Create<Startup>())
{
@stevenkuhn
stevenkuhn / IISExpressFixture.cs
Created November 19, 2014 02:35
IISExpressFixture
public class IISExpressFixture : IDisposable
{
public Uri Server { get; private set; }
public string SitePath { get; private set; }
private readonly Process _process;
public IISExpressFixture()
{
// Run site on a random port to prevent port clashes
public class LocalFileStoreProvider : IFileStoreProvider
{
public bool SaveScreenshot(FluentSettings settings, byte[] contents, string fileName)
{
try
{
if (!string.IsNullOrEmpty(settings.ScreenshotPrefix))
{
fileName = Path.Combine(
Path.GetDirectoryName(fileName),
## Octopus Azure deployment script, version 1.1
## --------------------------------------------------------------------------------------
##
## This script is used to control how we deploy packages to Windows Azure.
##
## When the script is run, the correct Azure subscription will ALREADY be selected,
## and we'll have loaded the neccessary management certificates. The Azure PowerShell module
## will also be loaded.
##
## If you want to customize the Azure deployment process, simply copy this script into
@stevenkuhn
stevenkuhn / gist:5062660
Last active March 7, 2023 16:03
This PowerShell script generates release notes for Octopus Deploy that contain the GitHub commits and JIRA issues from the current build to the latest production release. It will also create the Octopus release based on the TeamCity build number.
#
# Assumptions
#
# 1. If you have a Octopus release deployed, say 1.0.0.73, there is a git
# tag set for that commit in GitHub that is "v1.0.0.73".
#
# 2. You have TeamCity label each successful build in GitHub with the format
# "v{build number}. Sidenote: it appears that TeamCity only labels the
# default branch, but not feature branches.
#
$configFile = Get-Item .\nexuspwn.Service.exe.config
$xml = [xml](Get-Content $configFile)
$smtpNode = $xml.SelectSingleNode("/configuration/system.net/mailSettings/smtp")
$smtpNode.network.host = $OctopusParameters["MailSettings.Smtp.Network.Host"]
$smtpNode.network.port = $OctopusParameters["MailSettings.Smtp.Network.Port"]
$smtpNode.network.enableSsl = $OctopusParameters["MailSettings.Smtp.Network.EnableSsl"]
$smtpNode.network.userName = $OctopusParameters["MailSettings.Smtp.Network.UserName"]
$smtpNode.network.password = $OctopusParameters["MailSettings.Smtp.Network.Password"]
@stevenkuhn
stevenkuhn / releaseInfo.cshtml
Created February 13, 2012 20:08
Display release information via JavaScript using Octopus API, Knockout JS, and PageDown.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Octopus Release Information</title>
<style type="text/css">
</style>
</head>
<body>
<div data-bind="visible: version() != ''">
@stevenkuhn
stevenkuhn / EventService.cs
Created February 2, 2012 05:44
Triggering events in a Windows Service from an ASP.NET site using Redis
private void ProcessEvents() {
using (var client = redisManager.GetClient()) {
// incoming events are JSON, so deserialize each one to IDictionary<>.
var events = client.GetTypedClient<IDictionary<string, object>>().Lists["urn:events"];
while (true) {
// wait for next event, then convert it to an ExpandoObject;
dynamic @event = events.BlockingDequeue(null).ToExpando();
using Dapper;
public class EmployeeController : Controller
{
private IDbContext DbContext { get; set; }
public EmployeeController(IDbContext dbContext)
{
DbContext = dbContext;
}