Skip to content

Instantly share code, notes, and snippets.

View MarkRobertJohnson's full-sized avatar

Mark R. Johnson MarkRobertJohnson

  • Axian, Inc.
  • Portland, OR
View GitHub Profile
@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 / 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; }