Skip to content

Instantly share code, notes, and snippets.

View theunrepentantgeek's full-sized avatar

Bevan Arps theunrepentantgeek

View GitHub Profile
@theunrepentantgeek
theunrepentantgeek / clean-inbox.ps1
Created May 29, 2020 20:57
PowerShell scripts to archive old messages from Inbox
. ./script-library.ps1
[console]::OutputEncoding = New-Object System.Text.UTF8Encoding
$mailboxName = "<mailboxname>"
$outlook = new-object -com outlook.application;
Write-ColorText -Green "[✓] Connected to Outlook"
$ns = $outlook.GetNameSpace("MAPI");
@theunrepentantgeek
theunrepentantgeek / main.go
Created May 25, 2020 21:58
Dump a Go source file as an Abstract Syntax Tree (AST)
package main
import (
"fmt"
"os"
"go/ast"
"go/format"
"go/parser"
"go/token"
@theunrepentantgeek
theunrepentantgeek / Program.cs
Last active June 23, 2018 02:18
Benchmark the relative costs of structs vs primitive types
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run<Driver>();
@theunrepentantgeek
theunrepentantgeek / burst-source.ps1
Created April 5, 2018 19:49
PowerShell script to burst a C# source file containing many classes/interfaces/etc into separate files, each containing one thing
#
# Split a C# source file containing many classes, interfaces, etc, into one file per item
#
param(
# Specify the source C# file that should be burst into separate components
[Parameter(Mandatory=$true)]
[string]
$sourceFile,
# Specify the output folder for all the separated pieces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo
{
enum OriginShow
{
@theunrepentantgeek
theunrepentantgeek / lib-wrap-string.ps1
Created April 26, 2016 09:10
Example wrap-string function
# Word wrap function, return word wrapped version of passed string
function wrap-string($str, $length)
{
if ($str.length -lt $length)
{
return $str
}
# Holds the final version of $str with newlines
$strWithNewLines = ""
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Immutable
{
public struct PartyName
{
using System;
namespace Immutable
{
enum Qux { Qux1, Qux2 }
class Baz
{
private Qux _qux;