Skip to content

Instantly share code, notes, and snippets.

@tjrobinson
tjrobinson / AutoMocker.cs
Created Mar 20, 2021
AutoMocker experiments
View AutoMocker.cs
// @nuget: Moq.AutoMock -Version 2.3.0
using System;
using Moq;
using Moq.AutoMock;
public interface IMyService
{
string GetValue();
}
View keybase.md

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 Oct 9, 2017 — forked from mastilver/InstallHubFlow.ps1
Hubflow windows installer
View InstallHubFlow.ps1
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())";
View Microsoft.PowerShell_profile.ps1
# 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 Jun 22, 2015
install-psget.ps1 - suitable for use as part of a Group Policy Object
View install-psget.ps1
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
}
View 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
View download-nuget-licenses.ps1
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 Jul 12, 2018
ActiveDirectoryUserService.cs
View gist:0ad6c790e90d7a385eb1
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 Aug 11, 2014
MembershipReboot UserAccountService implementation with custom username validation
View AcmeUserAccountService.cs
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>