Skip to content

Instantly share code, notes, and snippets.

Richard Birkby rbirkby

  • UK
Block or report user

Report or block rbirkby

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View (Un)Protect-CmsMessage.ps1
# 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 / VS-PackageManager-AttachW3.ps1
Last active Oct 22, 2015
Visual Studio Attach to IIS macro
View VS-PackageManager-AttachW3.ps1
# 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
@rbirkby
rbirkby / web-service.md
Last active Aug 29, 2015
Quick web server
View web-service.md

"%ProgramFiles(x86)%\IIS Express\iisexpress.exe" /path:%cd%

Defaults to port 8080

@rbirkby
rbirkby / clone-all.ps1
Created Feb 25, 2015
Clone all GitHub private organisation repos with PowerShell
View clone-all.ps1
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 / RxVideo.cs
Last active Aug 29, 2015
C# port of Netflix Rx video example
View RxVideo.cs
internal class VideoExample {
/**
* Demonstrate how Rx is used to compose Observables together such as
* how a web service would to generate a JSON response.
*
* The simulated methods for the metadata represent different services
* that are often backed by network calls.
*
* This will return a sequence of dictionaries such as this:
@rbirkby
rbirkby / AtomicDiamond.cs
Last active Aug 29, 2015
Reactive Equations
View AtomicDiamond.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
class X : IObservable<int>
{
public IDisposable Subscribe(IObserver<int> observer)
{
return Observable.Interval(TimeSpan.FromSeconds(1))
@rbirkby
rbirkby / GetIISPhysicalDir.cmd
Created Feb 3, 2014
Gets the physical directory of an IIS website into a DOS batchfile variable using PowerShell
View GetIISPhysicalDir.cmd
powershell -command "ipmo WebAdministration; (gi $(gi 'iis:\Sites\Default Web Site\VDIR').physicalpath).parent.fullname | write-host" > destinationtmp.txt
SET /p DESTINATION=<destinationtmp.txt
del destinationtmp.txt
You can’t perform that action at this time.