Skip to content

Instantly share code, notes, and snippets.

Avatar

Alastair Crabtree alastairtree

View GitHub Profile
@alastairtree
alastairtree / RoutingLinkBuilder.cs
Created Feb 22, 2021
MVC Route aware ILinkBuilder for JsonApiDotNet 4 & aspnet core 3.1
View RoutingLinkBuilder.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Controllers;
using JsonApiDotNetCore.Middleware;
using JsonApiDotNetCore.Queries;
using JsonApiDotNetCore.Queries.Expressions;
using JsonApiDotNetCore.Queries.Internal.Parsing;
@alastairtree
alastairtree / HttpCorrelation.cs
Created Dec 30, 2020
Using stevejgordon/CorrelationId inside Azure Functions
View HttpCorrelation.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CorrelationId;
using CorrelationId.Abstractions;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@alastairtree
alastairtree / CreateSite.ps1
Last active Nov 12, 2020
IIS site stop and create website/appPool utility scripts
View CreateSite.ps1
## FYI: These scripts are now maintained in a proper repository:
## https://github.com/alastairtree/deploy-websites-with-powershell
## Intro: Simple powershell script to install (or replace) a local website and app pool
## Usage: CreateSite.ps1 [WebsiteName] [AppPoolName] [Port] [Path] ([domain\user] [password])
## Note : These scripts require local admin priviliges!
# Load IIS tools
Import-Module WebAdministration
sleep 2 #see http://stackoverflow.com/questions/14862854/powershell-command-get-childitem-iis-sites-causes-an-error
@alastairtree
alastairtree / run-tests.ps1
Created Jun 28, 2020
Quick integration tests of terraform modules using powershell
View run-tests.ps1
Function TC-Escape ([string] $text){
return $text.Replace("|","||").Replace("'","|'").Replace("\n","|n").Replace("\r","|r").Replace("[","|[").Replace("]","|}")
}
Function Invoke-Exec
{
[CmdletBinding()] param([Parameter(Position=0,Mandatory=1)][scriptblock]$cmd)
$scriptExpanded = $ExecutionContext.InvokeCommand.ExpandString($cmd).Trim()
View DevBox
choco install sql-server-management-studio –y
choco install git –y
choco install putty -y
choco install gitextensions -y
choco install vscode –y
choco install azure-data-studio –y
choco install 7zip –y
choco install nodejs-lts -y
choco install googlechrome -y
choco install firefox –y
View RetryHelper.cs
public static class RetryHelper
{
private static ILog logger = LogManager.GetLogger(); //use a logger or trace of your choice
public static void RetryOnException(int times, TimeSpan delay, Action operation)
{
var attempts = 0;
do
{
try
@alastairtree
alastairtree / gist:6777218c2c7facc17282
Created Jul 28, 2014
grant read execute permissions to a folder via powershell
View gist:6777218c2c7facc17282
$path = "C:\Sites\Website123"
$user = "domain\user"
$acl = Get-Acl $path
$arguments = $user, "ReadAndExecute", "ContainerInherit, ObjectInherit", "None", "Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $arguments
$acl.SetAccessRule($accessRule)
View RetryHelperAsync.cs
using System;
using System.Configuration;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using log4net;
namespace Utils
{
View Get-AADToken.ps1
# Original code from https://github.com/slavizh/OMSSearch/blob/master/OMSSearch.psm1
# - Updated/fixed authentication method calls
# - Ensure ADAL DLL is loaded
Function Get-AADToken {
<#
.SYNOPSIS
Get token from Azure AD so you can use the other cmdlets.
.DESCRIPTION
Get token from Azure AD so you can use the other cmdlets.
View my_boxstarter
choco install firefox -y
choco install 7zip -y
choco install putty -y
choco install notepadplusplus.install -y
choco install nuget.commandline -y
choco install git -y
choco install kdiff3 -y
choco install gitextensions -y
choco install vim -y
choco install fiddler4 -y