Skip to content

Instantly share code, notes, and snippets.

# 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 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
@rbirkby
rbirkby / web-service.md
Last active August 29, 2015 14:19
Quick web server

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

Defaults to port 8080

@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 / RxVideo.cs
Last active August 29, 2015 14:09
C# port of Netflix Rx video example
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 August 29, 2015 14:08
Reactive Equations
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 / ReactiveExtensionsNotes.md
Last active December 2, 2021 14:03
Reactive Extensions notes
@rbirkby
rbirkby / GetIISPhysicalDir.cmd
Created February 3, 2014 15:48
Gets the physical directory of an IIS website into a DOS batchfile variable using PowerShell
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
@rbirkby
rbirkby / README.md
Last active December 17, 2015 10:58 — forked from mbostock/.block
van Wijk Smooth Zooming