Skip to main content


Showing posts from December, 2018

Docker + ASP.NET MVC Hello world - abridged edition

Here's the exact steps to get the ASP.NET MVC sample application running in a Docker container in Windows 10, abridged from the Microsoft tutorial here.  I used a fresh Azure VM to avoid the many weird issues I kept running into with my bizarrely-screwy desktop, because of course it is.
$ip = (New-AzureRmVm -Name dockertest -Credential (Get-Credential) | Get-AzureRmPublicIpAddress); "Remote desktop to: " + $ip.IpAddress; mstsc -v $ip.IpAddress
Next, install chocolatey, then install everything else: choco install visualstudio2017professional visualstudio2017-workload-netweb docker docker-desktop -y Sign out and back in again, run docker desktop as admin, right-click the tray icon and switch to windows containers, let it enable hyper-v and reboot.  Run docker desktop as admin again.
Open Visual Studio, create a new project using the ASP.NET template and let it add all the MVC stuff. Create a publish profile, publishing files to the default location of /bin/Release/Publish …

Get the date each branch in a git repo diverged from master

I'm trying to clean up some long-lived branches in our repo and came across this handy stackoverflow post to get branches by the date of the commit they branched from.

I've modified it slightly to be easier to use for my purposes:
git show-ref | { while read branch; do merge_base=$(git merge-base --all $branch master); date_branched=$(git show -s --format=format:"%cd %an" --date=short $merge_base); echo "$date_branched, $branch"; done } | sort

Powershell jobs

Mostly for my own benefit but maybe someone will find this a helpful and concise reference

Create a job like this
$job = start-job {sleep 60; get-service;}

If you're creating jobs in a loop, add them to an array
$jobs = @()
foreach ($asdf in $qwer) { $jobs += start-job {...} }

Check job status while a job is running with
$job | get-job

Receive the result of that job with
$jobResult = ($job | wait-job | receive-job)

To execute some command over a large number of servers: $creds = get-credential

$scriptBlock = {
    write "running on $server";
    Invoke-Command -ComputerName $server -Credential $creds -Command {
        & {get-childitem -Path 'C:\' -Filter 'whatever' -Recurse } 2>$null 3>$null

$servers = @("server1", "server2", "server3", "etc")
$servers | % {
    start-job -ScriptBlock $scriptBlock -ArgumentList $_,$creds