Chrome forcing all localhost queries to https, breaking various CLIs
Jan 13, 2019
I use the Azure CLI and the Force.com CLI pretty regularly, and both of them make use of a little webserver running on localhost, presumably to catch the auth tokens once the SSO process redirects back. I also like to use localhost as a new tab page, to better invoke Chrome’s Vimium extension on all new tabs. On several installs of several dev machines, http://localhost has been regularly redirected to https where it shouldn’t be, causing breakage of all the CLIs, since they’re not providing TLS certs, and my new tab page as I haven’t got a TLS binding set up for the IIS default website.
...
➦
Docker + ASP.NET MVC Hello world - abridged edition
Dec 26, 2018
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 -ySign 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.
...
➦
Get the date each branch in a git repo diverged from master
Dec 12, 2018
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
Dec 12, 2018
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
...
➦
Azure Devops, unit tests and Azure AD Service Authentication
Nov 26, 2018
I couldn’t think of a title for this one that wasn’t ridiculously long so to help future Googlers, here’s what we were trying to do:
Authenticate against Azure Key Vaultusing a Service Principalusing Azure AD Service AuthenticationRrom our build serverRunning an Azure Devops build agent
Whew. Basically we had some integration tests that retrieve a database connection string from an Azure Key Vault, and needed Azure Devops to be able to run those tests on our build server.
...
➦
Making EntityFramework play nice with Azure Key Vault
Nov 14, 2018
Make a separate class containing a constructor to pass in the connection string from KV. Don’t modify the constructor in the Whatever.Context.cs file because it’ll get regenerated when you update the model and overwrite any changes you make in there.
Get the connection string from the “update model from database” command, but replace " with actual quotes. The connection string in KV should look like this:
metadata=res:///EntityFramework.DataWarehouse.csdl|res:///EntityFramework.DataWarehouse.ssdl|res://*/EntityFramework.DataWarehouse.msl;provider=System.Data.SqlClient;provider connection string="data source=databasename.database.windows.net;initial catalog=thedatabase;user id=dbusername;password=passwordgoeshere;MultipleActiveResultSets=True;App=EntityFramework”
Salesforce - bypass running unnecessary unit tests during a deployment
Nov 09, 2018
We had to urgently fix a bug in an Apex class written by a previous colleague, which was causing major issues with a customer-facing application on a Friday afternoon (because these things always happen then). We’d found the bug and updated the code easily enough, but Salesforce’s default deployment option of running all local unit tests was failing because of some completely unrelated tests that were failing.
Salesforce’s documentation (or at least the parts that I read) doesn’t clarify that you aren’t actually required to get 75% code coverage across all Apex code in your production org - you only need to get 75% coverage over the code you’re deploying.
...
➦
A non-useful Powershell snippet
Oct 02, 2018
What can I say, I was distracted
$t = “Taste the rainbow “; $c = ([ConsoleColor].GetEnumNames()); (1..7) | % {$c += $c; $t += $t}; foreach($x in $c) { write-host $t -ForegroundColor $x -NoNewline; sleep -Milliseconds 50 }
Strongly-typed action links in ASP.NET Core MVC views
Sep 30, 2018
While experimenting with ASP.NET Core and Razor views it occurred to me that the magic-string-based links really weren’t ideal, so I did a little googling and came across the excellent AspNet.Mvc.TypedRouting nuget package, which lets you use strongly-typed references to controllers and action methods.
I won’t repeat the install instructions, but for some reason they didn’t provide any examples of using their extension methods with the one thing I wanted to do - action links.
...
➦
Adding Application Insights to a .NET Core application
Sep 20, 2018
$appInsights = New-AzureRmApplicationInsights -Location USEast -ResourceGroupName rgname -Name ainame
$appInsights.InstrumentationKey #copy this
dotnet new mvc
dotnet add package Microsoft.ApplicationInsights.AspNetCore
In appsettings.json, add this
{
“ApplicationInsights”: {
“InstrumentationKey”: “11111111-2222-3333-4444-555555555555"
}
}
In program.cs add UseApplicationInsights() to the method chain for CreateDefaultBuilder
dotnet run
Ref: https://github.com/Microsoft/ApplicationInsights-aspnetcore/wiki/Getting-Started-with-Application-Insights-for-ASP.NET-Core