Skip to content

Instantly share code, notes, and snippets.

@jstedfast
jstedfast / HtmlToText.cs
Created January 25, 2016 21:25
HTML to plain text converter
//
// HtmlToText.cs
//
// Author: Jeffrey Stedfast <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@jstedfast
jstedfast / reply.cs
Last active February 26, 2016 18:19
A sample program illustrating how to generate a reply to a message
//
// ReplyVisitor.cs
//
// Author: Jeffrey Stedfast <[email protected]>
//
// Copyright (c) 2016 Xamarin Inc. (www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@jstedfast
jstedfast / dkim-pubkey.cs
Created June 3, 2016 18:47
How to load a DKIM public key from a string
using System;
using System.IO;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.OpenSsl;
namespace DkimKeyLocatorExample
{
public class Program
{
// first we need to base64 decode the content of the existing pkcs7-mime part
var content = new MemoryStream ();
pkcs7.Content.DecodeTo (content);
content.Position = 0;
// now we create a new pkcs7-mime part with the proper smime-type parameter
pkcs7 = new ApplicationPkcs7Mime (SecureMimeType.EnvelopedData, content);
// now decrypt it:
var decrypted = pkcs7.Decrypt (ctx);
@jstedfast
jstedfast / uninstall-xamarin.sh
Last active October 3, 2019 17:20
uninstall-xamarin.sh
#!/bin/bash
echo "Uninstalling the Xamarin Installer..."
rm -rf ~/Library/Caches/XamarinInstaller/
rm -rf ~/Library/Caches/VisualStudioInstaller/
rm -rf ~/Library/Logs/XamarinInstaller/
rm -rf ~/Library/Logs/VisualStudioInstaller/
rm -rf ~/Library/Preferences/Xamarin/
echo "Uninstalling Xamarin.Android..."
@jstedfast
jstedfast / ArcValidationTests.cs
Created May 31, 2019 15:31
MimeKit ARC validation unit tests
//
// ArcValidationTests.cs
//
// Author: Jeffrey Stedfast <[email protected]>
//
// Copyright (c) 2013-2019 Xamarin Inc. (www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
using System;
using System.IO;
using System.Linq;
using System.Text;
using YamlDotNet.Core;
using YamlDotNet.RepresentationModel;
namespace ArcSigningTestGenerator
{
using System;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.X509;
#!/bin/sh
# Create the private key for the root (CA) certificate
if [ ! -e "certificate-authority.key" ]; then
openssl genrsa -out certificate-authority.key 4096 > /dev/null
fi
# Create the private key for the primary intermediate certificate
if [ ! -e "intermediate1.key" ]; then
openssl genrsa -out intermediate1.key 4096 > /dev/null
//
// MessageCache.cs
//
// Author: Jeffrey Stedfast <[email protected]>
//
// Copyright (c) 2020 Jeffrey Stedfast
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights