Skip to content

Instantly share code, notes, and snippets.

View aggieben's full-sized avatar
🏠
Working from home

Ben Collins aggieben

🏠
Working from home
View GitHub Profile
@aggieben
aggieben / 00_powershell_profile_readme.md
Last active July 14, 2020 13:56
PowerShell Profile Scripts

Overview

These files are part of how I build a powershell profile.

This is what it looks like at startup:

Terminal Startup

Setup Instructions

@aggieben
aggieben / StructureMapTesting.linq
Last active June 5, 2020 15:21
Testing StructureMap child containers and Injection
<Query Kind="Program">
<NuGetReference>FluentAssertions</NuGetReference>
<NuGetReference>NSubstitute</NuGetReference>
<NuGetReference>NUnit</NuGetReference>
<NuGetReference>structuremap</NuGetReference>
<Namespace>FluentAssertions</Namespace>
<Namespace>NSubstitute</Namespace>
<Namespace>NUnit</Namespace>
<Namespace>NUnit.Framework</Namespace>
<Namespace>StructureMap</Namespace>
@aggieben
aggieben / pr-comment-emojis.md
Created March 2, 2020 21:46 — forked from raorao/pr-comment-emojis.md
PR Comment Emojis

Any top-level comment on pull request ought be tagged with one of four emojis:

  • for a non-blocking comment that asks for clarification. The pull request author must answer the question before the pull request is merged, but does not have to wait for the comment author to re-review before merging.

  • 🎨 for a non-blocking comment that proposes a refactor or cleanup. The pull request author does not have to address the comment for the pull request to merge.

  • ⚠️ for a blocking comment that must be addressed before the pull request can merge. The comment's author should leave a Request Changes review, and is responsible for re-reviewing once the pull request author has addressed the issue.

  • 😻 for a comment that compliments the author for their work.

@aggieben
aggieben / pe.rs
Created September 13, 2019 20:14
use nom::{IResult, dbg_dmp};
use nom::bytes::complete::{tag};
use nom::number::complete::le_u32;
fn has_msdos_header(input:&[u8]) -> IResult<&[u8], u32> {
const DOS_BEGIN : [u8; 60] =
[0x4d, 0x5a, 0x90, 0x00, 0x03, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@aggieben
aggieben / ExceptionHandler.fs
Last active June 1, 2018 22:42
Tool to find catch blocks for a specific exception type
module ExceptionHandlers
open System
open System.Collections.Generic
open System.Diagnostics
open Microsoft.Build.Locator
open Microsoft.CodeAnalysis
open Microsoft.CodeAnalysis.MSBuild
open Microsoft.CodeAnalysis.CSharp
open Microsoft.CodeAnalysis.Text
@aggieben
aggieben / variable_substitution_prerequest.js
Created April 13, 2018 16:45
Postman Pre-Request Script Variable Substitution
function replaceVariables(templateString) {
let tokens = _.uniq(templateString.match(/{{\w*}}/g))
_.forEach(tokens, t => {
let variable = t.replace(/[{}]/g, '')
let value = environment[variable] || globals[variable]
templateString = templateString.replace(new RegExp(t,'g'), value)
});
return templateString
<Project>
<PropertyGroup>
<IsWindows Condition="'$(OS)' == 'Windows_NT'">true</IsWindows>
<IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPLatform]::OSX)))' == 'true'">true</IsOSX>
<IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPLatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
<PropertyGroup Condition="'$(IsWindows)' == 'true'">
<FscToolPath>C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0</FscToolPath>
<FscToolExe>fsc.exe</FscToolExe>
</PropertyGroup>
@aggieben
aggieben / dotnet-versions
Last active July 20, 2017 21:52
List installed .NET Core SDK versions
#!/bin/sh
# Benjamin Collins <aggieben@gmail.com>
# Requires GNU readlink (get on macOS with `brew install coreutils`)
READLINK=${READLINK:-readlink}
cliPath=$(which dotnet)
netDir=$(dirname $($READLINK -f $cliPath))
ls -1 "$netDir/sdk"
module WebSocketClient
open System
open System.Net.WebSockets
open System.Text
open System.Threading
open Newtonsoft.Json
[<EntryPoint>]
let main argv =
@aggieben
aggieben / ConsentController.cs
Created February 18, 2017 21:35
A consent controller with business logic
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using IdentityServer4.Services;
using IdentityServer4.Stores;
using IdentityServer4.Models;