Skip to content

Instantly share code, notes, and snippets.

View MrBretticus's full-sized avatar

Brett Errington MrBretticus

View GitHub Profile
@MrBretticus
MrBretticus / Archive-BitwardenFolder.ps1
Created July 11, 2026 02:12
PowerShell script to archive all items in a BitWarden folder, using the CLI
<#
.SYNOPSIS
Archives all Bitwarden vault items in a given folder using the bw CLI.
.DESCRIPTION
Unlocks the Bitwarden vault (or reuses an existing session), syncs, finds the
specified folder, and archives every item in it that isn't already archived.
Requires bw CLI 2026.6.0+ (bw archive item <id>) and a Premium account
(Archive is a Premium feature).
@MrBretticus
MrBretticus / mdi_glyph_substitutions.yaml
Created June 14, 2026 10:20 — forked from Slalamander/mdi_glyph_substitutions.yaml
mdi icon substitutions for ESPHome
##Allows using mdi icons in esphome configs without having to look up the unicode value
##Uses the substitution engine to substitute the icon with the unicode. This means it is limited to a valid substitution format
##So instead of the home assistant mdi: way, icons are prefixed with mdi_. Slashes are also not allowed, so those are replaced with underscores as well.
mdi_ab_testing: "\U000F01C9"
mdi_abacus: "\U000F16E0"
mdi_abjad_arabic: "\U000F1328"
mdi_abjad_hebrew: "\U000F1329"
mdi_abugida_devanagari: "\U000F132A"
mdi_abugida_thai: "\U000F132B"
@MrBretticus
MrBretticus / LambdaExtensions.cs
Created June 21, 2012 09:11
Extension method to convert lambda property getter expression to a property setter delegate
public static class ExpressionExtensions
{
/// <summary>
/// Converts a lambda property getter expression to a property setter delegate.
/// For example: "o => o.MyProperty" to "o => o.MyProperty = newValue"
/// </summary>
public static Action<TProperty> ConvertGetterToSetter<TObject, TProperty>(this Expression<Func<TObject, TProperty>> expression, TObject o) {
var property = ((MemberExpression)expression.Body).Member as PropertyInfo;
Guard.Against(property == null, "Expression is not a property getter");
@MrBretticus
MrBretticus / gist:1923936
Created February 27, 2012 13:56
What I learnt, or my notes, from "In The Brain of Greg Young: CQRS and Event Sourcing - the Business Perspective"
Notes based on Greg Young's business perspective presentation
http://skillsmatter.com/podcast/agile-testing/greg-young-cqrs-event-sourcing-the-business-perspective
With a standard structural model we make assumptions of what the business may or may not want in the future. How can we presume to know what to track and what to discard.
CQRS/ES benefits:
* Captures behaviour explicitly, events carry the intent of users.
* We can derive any possible model about data that may be required.
* Allows domain experts and users to look at today in any way they may want to.
@MrBretticus
MrBretticus / SimpleRestfulieCall.cs
Created January 25, 2012 08:29
C# example of using the Restfulie .NET client
// NOTE: ripped from https://github.com/caelum/restfulie/wiki/csharp_short_samples
//retrieves the resource through GET: the entry point
dynamic order = Restfulie.At(resourceURI).Get();
Console.WriteLine("the order price is " + order.Price);
Console.WriteLine("The order product is" + order.Product);
// Executing a state transition:
order.Pay();