Skip to content

Instantly share code, notes, and snippets.

Avatar

Bevan Arps theunrepentantgeek

View GitHub Profile
@theunrepentantgeek
theunrepentantgeek / clean-inbox.ps1
Created May 29, 2020
PowerShell scripts to archive old messages from Inbox
View clean-inbox.ps1
. ./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
Dump a Go source file as an Abstract Syntax Tree (AST)
View main.go
package main
import (
"fmt"
"os"
"go/ast"
"go/format"
"go/parser"
"go/token"
@theunrepentantgeek
theunrepentantgeek / Program.cs
Last active Jun 23, 2018
Benchmark the relative costs of structs vs primitive types
View Program.cs
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run<Driver>();
@theunrepentantgeek
theunrepentantgeek / burst-source.ps1
Created Apr 5, 2018
PowerShell script to burst a C# source file containing many classes/interfaces/etc into separate files, each containing one thing
View burst-source.ps1
#
# 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
View NullabilityDemo.cs
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 Apr 26, 2016
Example wrap-string function
View lib-wrap-string.ps1
# 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 = ""
View immutable-polymorphism.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Immutable
{
public struct PartyName
{
View immutable.cs
using System;
namespace Immutable
{
enum Qux { Qux1, Qux2 }
class Baz
{
private Qux _qux;