Skip to content

Instantly share code, notes, and snippets.

View tillig's full-sized avatar

Travis Illig tillig

View GitHub Profile
@tillig
tillig / CallLogger.cs
Last active September 14, 2015 09:51
Intercepting SignalR Hubs with Autofac
using System;
using System.Diagnostics;
using System.Linq;
using Castle.DynamicProxy;
namespace SignalInterceptor
{
public class CallLogger : IInterceptor
{
public void Intercept(IInvocation invocation)
@tillig
tillig / gist:a6cb81f8986d2fe5011a
Last active April 13, 2016 19:01
Boxstarter - Windows Server 2012 Dev Machine Base Setup
# Base explorer features
$Boxstarter.RebootOk = $true
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
Enable-MicrosoftUpdate
Update-ExecutionPolicy -Policy RemoteSigned
# Base updates
Install-WindowsUpdate -GetUpdatesFromMS -AcceptEula
# Installation platforms
@tillig
tillig / gist:6f92842f10e062b714e1
Last active April 6, 2017 20:34
Boxstarter - Windows Dev Machine Base Tools
# Base explorer features
$Boxstarter.RebootOk = $true
Enable-MicrosoftUpdate
Update-ExecutionPolicy -Policy RemoteSigned
# Powershell 5 / WMF
cinst powershell
# Installation platforms
cinst lessmsi
@tillig
tillig / gist:ebe7ca1af84aa5f28c38
Last active September 28, 2015 17:19
Boxstarter Package Detection Test
# Detects whether a specific package is already installed
function Test-PackageInstalled
{
param([Parameter(Mandatory=$true)][string] $packageName)
$found = Get-ChildItem -Path "$env:ChocolateyInstall\lib" -Directory -Filter "$packageName.*" | Measure-Object | Select-Object -ExpandProperty Count
return $found -ne 0
}
Test-PackageInstalled nuget.commandline
@tillig
tillig / create-certificates.cmd
Created July 19, 2016 15:48
Examples of how to create certificates with makecert/pvk2pfx
# Certificate for simple encryption/decryption. Doesn't have to be signed, but does need key exchange allowed.
makecert -sv mycertificate.pvk -n "CN=My Simple Certificate" mycertifcate.cer -sky Exchange
# Certificate that can sign other certificates (share this as the CA).
makecert -sv mysigningcert.pvk -n "CN=My Signing Certificate" -r mysigningcert.cer
# Certificate for SSL that's signed by a certificate authority.
makecert -sk mysignedcert -iv mysigningcert.pvk -n "CN=My Signed Certificate" -ic mysigningcert.cer mysignedcert.cer -sr YourUsername -ss My
# If you need to export/save a certificate as a PFX file.
@tillig
tillig / Sync-AzureAD.ps1
Created July 26, 2016 17:30
Force an Azure AD Connect delta synchronization
# Run this as administrator
Import-Module ADSync
Start-ADSyncSyncCycle -PolicyType Delta
@tillig
tillig / DropAll.ps1
Last active January 20, 2017 16:28
Kill an Entire LocalDB Instance
$LocalDB = "YourInstanceName"
& "$($env:ProgramFiles)\Microsoft SQL Server\110\Tools\Binn\sqlcmd.exe" -S "(localdb)\$LocalDB" -d "master" -Q "EXECUTE master.sys.sp_MSforeachdb 'USE [?];declare @name nvarchar(max) = DB_NAME();IF(@name NOT IN (''master'',''model'',''msdb'',''tempdb''))BEGIN USE [master];EXEC (''alter database ['' + @name + ''] set single_user with rollback immediate; DROP DATABASE '' + @name) END'"
& sqllocaldb p $LocalDB
& sqllocaldb i $LocalDB
@tillig
tillig / RetroactiveTag.sh
Created January 3, 2017 20:12
Retroactively tag a git commit
# From http://stackoverflow.com/questions/21738647/change-date-of-git-tag-or-github-release-based-on-it
git checkout SHA1_OF_PAST_COMMIT
GIT_COMMITTER_DATE="$(git show --format=%aD | head -1)" git tag -a v0.9.33 -m"Retroactively tagging version 0.9.33"
@tillig
tillig / InstallApp.cs
Last active January 4, 2017 21:15
Example console app showing how to add items to the Visual Studio toolbox
using System;
using System.Reflection;
using System.Runtime.InteropServices;
namespace ToolboxIntegration
{
class InstallApp
{
protected const string DTE_PROG_ID = "VisualStudio.DTE.7.1";
@tillig
tillig / KeyedCollection.cst
Created January 4, 2017 21:54
CodeSmith template for generating a KeyedCollection
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a strongly typed collection based on a generic KeyedCollection." %>
<%@ Property Name="Accessibility" Type="System.String" Optional="True" Default="public" Category="Options" Description="The accessibility of the collection class." %>
<%@ Property Name="ClassName" Type="System.String" Optional="True" Category="Context" Description="The name of the collection class." %>
<%@ Property Name="TargetNamespace" Type="System.String" Optional="True" Category="Namespaces" Description="The namespace of the collection class." %>
<%@ Property Name="KeyPropertyName" Type="System.String" Category="Context" Description="The name of the property on each collection member that returns the key value." %>
<%@ Property Name="KeyType" Type="System.String" Category="Context" Description="The key type of the collection." %>
<%@ Property Name="KeyNamespace" Type="System.String" Optional="True" Category="Namespaces" Description="The namespace of the key type." %