Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Ben Collins aggieben

🏠
Working from home
Block or report user

Report or block aggieben

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pe.rs
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 Jun 1, 2018
Tool to find catch blocks for a specific exception type
View ExceptionHandler.fs
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 Apr 13, 2018
Postman Pre-Request Script Variable Substitution
View variable_substitution_prerequest.js
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
View DotNetSdk.FscTooling.props
<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>
View WebSocketClient.fs
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 Feb 18, 2017
A consent controller with business logic
View ConsentController.cs
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;
@aggieben
aggieben / dotnet-versions
Last active Jul 20, 2017
List installed .NET Core SDK versions
View dotnet-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"
@aggieben
aggieben / sh_env_var_opts.sh
Created Oct 1, 2015 — forked from KylePDavis/sh_env_var_opts.sh
Simple bash shell script templates. There are two versions: 1) simple env var based options, and 2) with added command line argument parsing and error handling.
View sh_env_var_opts.sh
#!/bin/bash -e
# A SHORT DESCRIPTION OF YOUR SCRIPT GOES HERE
# USAGE:
# DESCRIPTION OF ENV VARS HERE
###############################################################################
set -e # exit on command errors (so you MUST handle exit codes properly!)
set -o pipefail # capture fail exit codes in piped commands
#set -x # execution tracing debug messages
# Get command info
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.country {
fill: #b8b8b8;
stroke: #fff;
stroke-width: .5px;
stroke-linejoin: round;
}
View With-Env.ps1
# this is required
Import-Module pscx
# just drop this into your $profile, somewhere after the above import-module line
function With-Env (
[string[]]$vars,
[Parameter(Position=1)]
[scriptblock]$f
) {
Push-EnvironmentBlock
You can’t perform that action at this time.