Skip to content

Instantly share code, notes, and snippets.


Bill Wilder codingoutloud

View GitHub Profile
codingoutloud /
Last active Oct 13, 2015
Decided to make a list of conventions I practice in development... They aren't necessarily *right*, but are what they are.
codingoutloud / DumpExpiredCerts.cs
Created Dec 1, 2012
Dump information about expired certificates from the Windows Certificate Store
View DumpExpiredCerts.cs
using System;
using System.Security.Cryptography.X509Certificates;
namespace DumpExpiredCertificates
internal class Program
private static void Main(string[] args)
// Iterates through all of the X.509 digital certificates installed in the certificate store
codingoutloud / RunningAsAdministrator.cs
Created Dec 5, 2012
Am I running as an Administrator?
View RunningAsAdministrator.cs
using System.Security.Principal;
// Is this thread running with Administrator role?
private static bool RunningAsAdministrator()
var identity = WindowsIdentity.GetCurrent();
if (identity == null) return false; // Administrator should always have access to this
var principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
codingoutloud / temp-tidy.ps1
Created Dec 10, 2012
PowerShell script to tidy up the application TEMP area on Windows by deleting files older than 7 days
View temp-tidy.ps1
# The intent is that the command is to be scheduled to be run by the Windows Scheduler once a day:
# For Windows Azure, a new Windows Scheduler task is best added by a Startup Script and, like any other machine with the default PowerShell security settings, will need the PowerShell ExecutionPolicy configured:
# Bill Wilder @codingoutloud
# See also
get-childitem $TEMP -recurse | where {$_.lastwritetime -lt (get-date).adddays(-7)} |% {remove-item $_.fullname -force -recurse -verbose}
codingoutloud / blob-cache-control-header.cs
Created Feb 13, 2013
Snippet of Azure Client SDK 1.7 code that demonstrates setting ContentType and CacheControl headers.
View blob-cache-control-header.cs
// .NET Storage SDK 1.7
CloudBlob destBlob = TargetContainer.GetBlobReference(destFileName);
destBlob.Properties.ContentType = "image/jpeg";
destBlob.Properties.CacheControl = "x-ms-blob-cache-control: public, max-age=31556926"; // cache for up to one year
codingoutloud / AzureCustomRetryPolicy.cs
Created Feb 13, 2013
Show Custom Retry Policy for Windows Azure Storage SDK.
View AzureCustomRetryPolicy.cs
// Azure Storage SDK 1.7
public static RetryPolicy TrackingRetryExponential(int maxRetryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff, ILog logger)
"Setting TrackingRetryExponential: maxRetryCount = {0}, minBackoff = {1}, maxBackoff = {2}, deltaBackoff = {3}",
maxRetryCount, minBackoff, maxBackoff, deltaBackoff);
return () => (int currentRetryCount, Exception lastException, out TimeSpan retryInterval) =>
codingoutloud / get-gitignore.ps1
Last active Dec 16, 2015
Download my latest .gitignore file - useful when creating a new Windows Azure Project
View get-gitignore.ps1
Invoke-WebRequest -OutFile .\.gitignore
codingoutloud / AzureEmulatorPowerSwitch.cs
Created May 27, 2013
Power Switch for the Azure Emulator processes. Make it easy to programmatically turn Storage or Compute emulation On or Off.
View AzureEmulatorPowerSwitch.cs
using System;
using System.Diagnostics;
using System.IO;
namespace DevPartners
/// <summary>
/// Power Switch for the Azure Emulator processes. Make it easy to programmatically turn Storage or Compute emulation On or Off.
/// </summary>
public static class AzureEmulatorPowerSwitch
codingoutloud / rewrite-to-https.web.config
Created Sep 6, 2013
A rewrite rule for ASP.NET that will redirect HTTP requests to be HTTPS requests. Credit: Maarten Balliauw ( this guy: ) showed me how to do it.
View rewrite-to-https.web.config
<rule name="Force HTTPS" enabled="true">
<match url="(.*)" ignoreCase="false" />
<add input="{HTTPS}" pattern="off" />
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
codingoutloud / relax.ps1
Last active Dec 24, 2015
Use this to "relax" the constraints on a Windows Azure VM - primarily for a Cloud Service VM. It also installs some handy tools. Goal is to make it easy to diagnose issues on a VM. If you use this, plan to reimage the VM afterwards.
View relax.ps1
# original:
# (inspired by
# MANUALLY FIRST DO THIS from ELEVATED PowerShell command prompt
Set-ExecutionPolicy Unrestricted -Force ; New-Item -ItemType Directory -Path c:\tools ; cd c:\tools ; notepad c:\tools\relax.ps1