Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
What a mess I've made

Stephen Jennings jennings

🦄
What a mess I've made
View GitHub Profile
View Systemantics.md

Fundamental Principle

Systems in general work poorly or not at all.

First Principles

  1. New Systems mean new problems.
  2. The total amount of anergy in the universe is fixed.
  3. Systems tend to expand to fill the known universe.
@jennings
jennings / windbg-notes.md
Last active Jun 30, 2020
Debugging .NET with WinDbg feels like wizardry, so naturally I want to get better at it.
View windbg-notes.md

Load PSSCOR4:

.loadby sos clr
.load C:\Debug\Psscor4\amd64\psscor4.dll

or:

@jennings
jennings / BatchfileTricks.cmd
Last active Jun 15, 2020
Stupid batch file tricks
View BatchfileTricks.cmd
:: Sleep for N seconds:
ping localhost -n N -w 1
:: Get the date and time (US LOCALE ONLY)
set YEAR=%DATE:~-4,4%
set TWOYEAR=%DATE:~-2,2%
View PUTTY_WITH_GIT.md

Download PuTTY

Download and install the latest 64-bit PuTTY. Using the MSI is fine.

Generate an SSH key

Each computer should a unique SSH key. The same key can be reused for GitHub, Bitbucket, and any other Git server you connect to.

  1. Launch PuTTYgen:
  2. Select "Ed25519"
View Caffeinate.ps1
function Caffeinate {
param([scriptblock]$ScriptBlock)
$active_scheme_id = (powercfg /GetActiveScheme).Split(" ")[3]
$high_perf_id = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c"
powercfg /s $high_perf_id
if ($LASTEXITCODE -ne 0) { return }
try {
& $ScriptBlock
} finally {
@jennings
jennings / rx-net-vs-rxjs.md
Last active Dec 19, 2019
A cheatsheet of Rx.NET to rxjs operators
View rx-net-vs-rxjs.md

Creation

System.Reactive rxjs 6
Observable.Return import { of } from "rxjs"
Observable.Empty import { EMPTY } from "rxjs"
Observable.Never import { NEVER } from "rxjs"
Observable.Throw import { throwError } from "rxjs"
Observable.Create new Observable(observer => {})
Observable.Range import { range } from "rxjs"
@jennings
jennings / WcfExtensibilityPoints.md
Last active Oct 23, 2019
I can never remember how to extend WCF in the ways that I want.
View WcfExtensibilityPoints.md

A good summary of all the extensibility points: https://blogs.msdn.microsoft.com/carlosfigueira/2011/03/14/wcf-extensibility/

Doing stuff before/after calls

Use IOperationInvoker if you need to do "runtime-y" things, such as replacing the current SynchronizationContext (perhaps with one that restores OperationContext after an await...).

But! You can only apply an IOperationInvoker from an IOperationBehavior, not from a IServiceBehavior. If you try to assign an operation invoker from a service behavior, WCF will eventually just overwrite it. If you want to apply an IOperationInvoker to every operation in a contract, you can write an IServiceBehavior which applies the IOperationBehavior to every operation.

You can have an attribute which can apply to a whole service, or to a single operation:

View export-git-changed-files.ps1
$ErrorActionPreference = "Stop"
function Main {
"This script creates a zip file that contains all files changed between two commits."
"Commits can be specified as commit IDs (SHA) or as branch names."
"For example: 'master' or 'ff39683ed6'"
""
$git_dir = Read-Host -Prompt "Git directory"
$to_commit = Read-Host -Prompt "Commit to deploy"
@jennings
jennings / README.md
Last active May 2, 2019
Templates for empty new-style csproj files
View README.md

These are copied from this article by Nate McMaster. I've been Googling for it every time I needed it, so I decided it would be a good idea to save these templates somewhere, in case the article ever goes away.

View fake_webpack.js
const MODULE_BODIES = {
// This is the body of the file foo/index.ts, wrapped in a function
["./foo/index.ts"]: function (module) {
const file = __webpack_resolve__("./foo/file.ts")
module.exports.Service = file.Service
},
// This is the body of the file foo/file.ts, wrapped in a function
["./foo/file.ts"]: function (module) {
You can’t perform that action at this time.