Skip to content

Instantly share code, notes, and snippets.

@rbirkby
rbirkby / oneliners.cs
Created June 2, 2011 17:12
10 C# One Liners to Impress Your Friends
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
class TenCSharpOneLiners
{
static void Main()
{
@rbirkby
rbirkby / ReactiveExtensionsNotes.md
Last active December 2, 2021 14:03
Reactive Extensions notes
@rbirkby
rbirkby / clone-all.ps1
Created February 25, 2015 14:21
Clone all GitHub private organisation repos with PowerShell
Param ($accessToken, $organisation)
(invoke-webrequest -Uri https://api.github.com/orgs/$organisation/repos?per_page=200"&"access_token=$accessToken"&"type=private).Content | ConvertFrom-Json | % {$_.clone_url} | % {git clone $_}
@rbirkby
rbirkby / OOVatCalculator.cs
Created November 16, 2011 12:34
A UK Vat Calculator written in an OO style
using System;
class Program {
static void Main() {
WriteAmount(new DateTime(2008, 11, 01), 1.00M);
WriteAmount(new DateTime(2009, 01, 01), 1.00M);
WriteAmount(new DateTime(2010, 12, 01), 1.00M);
WriteAmount(new DateTime(2011, 12, 01), 1.00M);
}
# Also see https://cyber-defense.sans.org/blog/2015/08/23/powershell-protect-cmsmessage-example-code
$cert = New-SelfSignedCertificate -subject 'CN=TestCert' -Type DocumentEncryptionCert -NotAfter 2100-07-01 -TextExtension @("2.5.29.37={text}1.3.6.1.4.1.311.80.1") -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider"
Export-Certificate -cert $cert -FilePath cert.cer
$ciphertext = Protect-CmsMessage -Content 'password' -To $cert.Thumbprint
$ciphertext
$plaintext = Unprotect-CmsMessage -Content $ciphertext
@rbirkby
rbirkby / README.md
Last active December 17, 2015 10:58 — forked from mbostock/.block
van Wijk Smooth Zooming
@rbirkby
rbirkby / InstrumentedAuthorisationService.cs
Created May 17, 2013 08:44
Adding a Logger to an authorization system using a Decorator and abiding by SOLID. Please note that this solution isn't thread safe.
using System;
using System.Diagnostics;
using System.Threading;
using Xunit;
namespace CodingChallenge
{
class Program
{
static void Main()
@rbirkby
rbirkby / SolidQuotes.md
Last active December 17, 2015 02:59
SOLID quotes

I quite agree that a dogmatic or religious application of the SOLID principles is neither realistic nor beneficial. If you had read through any of the articles and/or books I’ve written on these principles over the last 15 years, you’d have found that I don’t recommend the religious or dogmatic approach you blamed me for. In short, you jumped to a erroneous conclusion about me, and about the principles, because you weren’t familiar with the material.

Robert C. Martin
https://sites.google.com/site/unclebobconsultingllc/an-open-letter-to-joel-spolsky-and-jeff-atwood

@rbirkby
rbirkby / ArduinoLedMatrix.c
Last active December 9, 2015 21:48
Hacky code for controlling a Max7219 using an Arduino with the LedControl library.
#include "LedControl.h"
#define DIN 2
#define CLK 3
#define LOAD 4
LedControl lc=LedControl(DIN, CLK, LOAD, 1);
unsigned long delaytime=20;
void setup() {
@rbirkby
rbirkby / VS-PackageManager-AttachW3.ps1
Last active October 22, 2015 06:51
Visual Studio Attach to IIS macro
# Paste this into the Nuget Package Manager window in Visual Studio to attach to all w3wp processes
$DTE.Debugger.LocalProcesses | ? Name -m "w3wp.exe" | % Attach