Skip to content

Instantly share code, notes, and snippets.

View tjrobinson's full-sized avatar

Tom Robinson tjrobinson

View GitHub Profile
@tjrobinson
tjrobinson / AutoMocker.cs
Created March 20, 2021 17:50
AutoMocker experiments
// @nuget: Moq.AutoMock -Version 2.3.0
using System;
using Moq;
using Moq.AutoMock;
public interface IMyService
{
string GetValue();
}
@tjrobinson
tjrobinson / keybase.md
Created September 11, 2019 10:37
Keybase proof

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@tjrobinson
tjrobinson / InstallHubFlow.ps1
Created October 9, 2017 09:07 — forked from mastilver/InstallHubFlow.ps1
Hubflow windows installer
Add-Type -AssemblyName System.IO.Compression.FileSystem
$TEMP = $([environment]::GetEnvironmentVariable("TEMP", "User"))
$CWD = $(Split-Path $MyInvocation.MyCommand.Path)
$PATH = $([environment]::GetEnvironmentVariable("PATH", "User"))
$git_folder = "C:\Program Files\Git"
$git_bin_folder = "$($git_folder)\bin"
$tmp_folder = "$($TEMP)\$([guid]::NewGuid())";
# Set environment variables for Visual Studio Command Prompt
# Based on: http://stackoverflow.com/questions/2124753/how-i-can-use-powershell-with-the-visual-studio-2010-command-prompt
$version=14
pushd "c:\Program Files (x86)\Microsoft Visual Studio ${version}.0\Common7\Tools"
cmd /c "vsvars32.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("=")
set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
@tjrobinson
tjrobinson / install-psget.ps1
Created June 22, 2015 14:19
install-psget.ps1 - suitable for use as part of a Group Policy Object
function Install-PsGet {
$Destination = "C:\Windows\System32\WindowsPowerShell\v1.0\Modules"
New-Item -Path ($Destination + "\PsGet\") -ItemType Directory -Force | Out-Null
Write-Host 'Downloading PsGet from https://github.com/psget/psget/raw/master/PsGet/PsGet.psm1'
$client = (New-Object Net.WebClient)
$client.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$client.DownloadFile("https://github.com/psget/psget/raw/master/PsGet/PsGet.psm1", $Destination + "\PsGet\PsGet.psm1")
Write-Host "PsGet is installed and ready to use" -Foreground Green
}
@tjrobinson
tjrobinson / es-curator.ps1
Created May 14, 2015 08:05
es-curator.ps1
# get indexes in "logstash" alias
$indexes = Invoke-RestMethod "http://localhost:9200/logstash/_settings"
# get the names of the indexes
$indexNames = Get-Member -InputObject $indexes -MemberType NoteProperty|%{$_.Name}
# foreach index check its age. If over 10 days, delete it
$indexNames|sort |%{
$datePart = $_.Substring(9)
$indexAge = [datetime]::UtcNow.Date.Subtract([DateTime]::Parse($datePart)).Days
Split-Path -parent $dte.Solution.FileName | cd
New-Item -ItemType Directory -Force -Path ".\licenses"
@( Get-Project -All |
? { $_.ProjectName } |
% { Get-Package -ProjectName $_.ProjectName } ) |
Sort -Unique |
% { $pkg = $_ ; Try { (New-Object System.Net.WebClient).DownloadFile($pkg.LicenseUrl, (Join-Path (pwd) 'licenses\') + $pkg.Id + ".html") } Catch [system.exception] { Write-Host "Could not download license for $pkg" } }
@tjrobinson
tjrobinson / gist:0ad6c790e90d7a385eb1
Last active July 12, 2018 02:55
ActiveDirectoryUserService.cs
using System;
using System.Collections.Generic;
using System.DirectoryServices.AccountManagement;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Thinktecture.IdentityServer.Core;
using Thinktecture.IdentityServer.Core.Models;
using Thinktecture.IdentityServer.Core.Services;
@tjrobinson
tjrobinson / AcmeUserAccountService.cs
Created August 11, 2014 08:45
MembershipReboot UserAccountService implementation with custom username validation
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using BrockAllen.MembershipReboot;
namespace Acme.Users.MembershipReboot
{
public class AcmeUserAccountService<TAccount> : UserAccountService<TAccount>