Skip to content

Instantly share code, notes, and snippets.

@bert2
bert2 / Option.cs
Last active September 20, 2022 01:28
copy & paste: lightweight implementation of the famous `Maybe` monad/functor with async support
/**
* Lightweight implementation of the famous `Maybe` type that safely wraps
* optional values without using `null` references.
*
* Add this file to your project and get three new namespaces:
* - `Option`: the base type, factories, operators (map, bind, filter, tap,
* flatten), and means to get the contained value.
* - `Option.Extras`: some utility functions like `IEnumerable.FirstOrNone()`,
* combinators (and, or, ...), and maybe-ready `TryParse` functions.
* - `Option.Async`: async variants of the operators so you can bind against
@bert2
bert2 / scan-vs-dlls.linq
Last active October 4, 2020 12:12
Developing a VS extension and want to style it with the VS theme? This is a list of all `*style.xaml` files found in the VS dlls. Open any of the DLLs with ILSpy to inspect the XAML files (they're named `*.baml` after compilation).
// This needs to be executed multiple times, because it will crash with an out of memory exception.
// Once an assembly has been loaded with `Assembly.LoadFile()`, it cannot be unloaded again. The
// +10K DLLs to load will eat up all your memory, but the script will resume at the DLL that
// crashed the process, when it is restarted.
void Main() {
// Adjust those paths.
var resultStore = @"C:\Users\bert\Desktop\vs-style-baml-files.txt";
var lastFileStore = @"C:\Users\bert\Desktop\vs-baml-files.last.txt";
// Make sure this file exists (empty).
@bert2
bert2 / README.md
Last active December 26, 2022 09:03
Giving Sisyphus a Hand: How to Improve OOP with Functional Principles

Giving Sisyphus a Hand: How to Improve OOP with Functional Principles

Yet another rant about object-oriented programming, but mainly a collection of ideas stolen from functional programming to improve it.

@bert2
bert2 / github-to-nuget.md
Last active May 15, 2019 15:14
Outline for a short talk demonstrating continuous deployment of a GitHub repo to NuGet

Continuous Deployment from GitHub to NuGet with Cake and AppVeyor

The Example Project

The Goals

  • new release for every commit
  • ability to skip release for certain commits
@bert2
bert2 / rest-intro.md
Last active May 8, 2019 09:06
A very brief intro to REST

RESTful Web API Design

What is REST?

  • Buzzword
  • Short for REpresentational State Transfer
  • Architectural style invented by Roy Fielding
  • Set of constraints, rules, and conventions
  • Very hard to do 100% right
  • Replacement for RPC style applications