Skip to content

Instantly share code, notes, and snippets.

View MarkRobertJohnson's full-sized avatar

Mark R. Johnson MarkRobertJohnson

  • Corpay, Inc.
  • Portland, OR
View GitHub Profile
@MarkRobertJohnson
MarkRobertJohnson / VCDMount-Iso.ps1
Last active June 1, 2016 10:09
Function (VCDMount-Iso) to mount ISO images using Virtual Clone Drive
#requires -version 2.0
Add-Type @"
public class Shift {
public static int Right(int x, int count) { return x >> count; }
public static uint Right(uint x, int count) { return x >> count; }
public static long Right(long x, int count) { return x >> count; }
public static ulong Right(ulong x, int count) { return x >> count; }
public static int Left(int x, int count) { return x << count; }
public static uint Left(uint x, int count) { return x << count; }
public static long Left(long x, int count) { return x << count; }
@MarkRobertJohnson
MarkRobertJohnson / gist:7012670
Last active December 25, 2015 17:19
Extract certificate from WCF secure envelope
var ms = new MemoryStream(secureEnvelopeBytes);
var xRdr = new XmlTextReader(ms);
var message = Message.CreateMessage(xRdr, int.MaxValue, MessageVersion.Soap12);
var securityHeader = message.Headers.FirstOrDefault(x => x.Name == "Security");
if (securityHeader != null)
{
var securityElement = XElement.Parse(securityHeader.ToString());
var binarySecurityToken = securityElement.Descendants(
XName.Get("BinarySecurityToken", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")).Single();
@MarkRobertJohnson
MarkRobertJohnson / BLU_Paver
Last active December 31, 2015 20:59
BLU Paving
<#
.SYNOPSIS
This is a BoxStarter script for paving BLU machines
#>
Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
#Should we create domain users and groups? or assume their existence?
#Perhaps for now just assume their existence, but add the users to the local groups
@MarkRobertJohnson
MarkRobertJohnson / CredentialManager.cs
Created August 17, 2016 21:33 — forked from meziantou/CredentialManager.cs
Using the Windows Credential API (CredRead, CredWrite, CredDelete, CredEnumerate)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.Win32.SafeHandles;
public static class CredentialManager
{
public static Credential ReadCredential(string applicationName)
@MarkRobertJohnson
MarkRobertJohnson / prop.snippet
Created September 19, 2017 23:25
Visual Studio snippet for TypeScript property setter and getter
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>prop</Title>
<Author>Mark R. Johnson</Author>
<Shortcut>prop</Shortcut>
<Description>Code snippet for a property</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
#!/bin/bash
#Docker commands taken from: https://inedo.com/support/kb/1100/getting-started-with-proget-for-linux#limitations
brew cask install docker
#Now, go and start start docker from finder
mkdir -pv /private/var/proget/db
mkdir -pv /private/var/proget/packages
@MarkRobertJohnson
MarkRobertJohnson / musicKeys.html
Last active April 7, 2018 15:20
A little polyphonic synthesizer that run in the browser. Uses computer keyboard to trigger notes.
<html>
<header>
<script lang="javascript" >
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var sineTerms = new Float32Array([0, 0, 1, 0, 1]);
var cosineTerms = new Float32Array(sineTerms.length);
var customWaveform = audioCtx.createPeriodicWave(cosineTerms, sineTerms);
@MarkRobertJohnson
MarkRobertJohnson / Get-SeqGuid.ps1
Created January 13, 2018 23:01
Generates sortable sequential GUIDs
$c = @"
using System;
using System.Runtime.InteropServices;
public static class SeqGuid {
private class NativeMethods
{
[DllImport("rpcrt4.dll", SetLastError=true)]
public static extern int UuidCreateSequential(out Guid guid);
}
@MarkRobertJohnson
MarkRobertJohnson / Get-SeqGuid2.ps1
Created January 13, 2018 23:18
Get sequential GUIDs without using Windows DLL.
$c = @"
using System;
public class SequentialGuid {
Guid _CurrentGuid;
public Guid CurrentGuid {
get {
return _CurrentGuid;
}
}
if(!(Get-Command choco -erroraction SilentlyContinue)) {
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
choco install webpicmd -y
$webpicmd = 'webpicmd'
if(!(Get-Command $webpicmd -erroraction SilentlyContinue )) {
$webpicmd = 'C:\Program Files\Microsoft\Web Platform Installer\WebpiCmd.exe'