Skip to main content

Posts

OTF fonts (e.g. Fira Code) look nasty on gVim in Windows

I really like the "Fira Code" font but it always looked nasty in gVim on Windows (my main text editor besides VS), and I really don't want to use a different font for each editor. After spending literally hours fiddling with stuff like the guifont setting, different font/size combos, custom font renderers (e.g. MacType), I finally realised the fonts themselves aren't the problem, nor the rendering settings.  The problem was that the chocolatey installer I had used installed OTF versions of the files, which gVim always used by default even if the TTF versions of them were installed. Uninstalling OTFs and installing TTFs fixed the problem immediately, and now once again I have consistent font rendering across all my text editors. Hooray.

Bonus font opinions:
Best: Fira Code, Cascadia Code, Source Code Pro (in that order)
Nope: Envy Code R, Inconsolata, Hack, Oxygen Mono, Anonymous Pro
Recent posts

Powershell error: "Retrieving COM class factory failed: class not registered (REGDB_E_CLASSNOTREG)"

The problematic command and full error message was:

>get-webbinding
"get-webconfigurationproperty : Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."

I was pretty stuck on the above error while trying to run a script for setting up sites in IIS which involved some calls to get-webbinding (in the WebAdministration module). After much digging around I finally ran into this post. Turns out, genius that I am, I had created a shortcut to the x86 version of Powershell when I first created the VM, so I'd been using the wrong bitness the entire time. I'm surprised I didn't have more issues!  Anyway, running the 64-bit (i.e. regular) version of Powershell fixed the problem immediately. Thanks jasonint32 ;)


Set default program for opening files without extensions in Windows

For some reason, downloading the request / result CSV files for a Salesforce "Bulk Data Load" job returns CSV files with the file extension missing, so you can't just click to open them. This became super annoying during a troublesome data load so I decided to fix it once and for all.  Open cmd as admin and enter the following:

assoc .="No Extension" ftype "No Extension"="C:\ProgramData\chocolatey\lib\csvfileview\tools\CSVFileView.exe" "%1"

Obviously substitute in your favourite CSV editor (unless by some bizarre coincidence, you also like CSVFileView and install everything with chocolatey).  Credit for the solution goes to this post on superuser.

Powershell - normalizing line endings for all files in a directory

If you're working with a git repository, a much better way to solve this is by changing the core.autocrlf setting.  In this case I didn't have that option, and needed a quick way to update thousands of files so the EOL chars would match in a binary diff tool.  Here's my slightly modified version of this SO answer:

$items = get-childitem -Path "C:\path\to\dir\" -Recurse -File foreach($original_file in $items) { $text = [IO.File]::ReadAllText($original_file.FullName) -replace "`r`n", "`n" [IO.File]::WriteAllText($original_file.FullName, $text) }

Connecting to Sharepoint with Powershell when MFA is enabled

If you're using multifactor auth, the usual login method mentioned in the SPOService documentation isn't going to work (using Get-Credential) and you'll get an error saying "Connect-SPOService : The sign-in name or password does not match one in the Microsoft account system".

The correct process is rather bizarre:

$orgName = "organizationname"
connect-sposervice -url "https://$orgName-admin.sharepoint.com"

Then you'll get the same Azure AD auth popup that you'd get with Connect-AzureRmAccount and Microsoft's other Powershell modules.  The only place I could find this was in Microsoft's docs here, but it would have saved me some time if it was at least mentioned in the help text for Connect-SPOService...

Azure Devops CLI - removing old branches after squash merges

We had a git repo with hundreds of already-merged branches which I wanted to clean up.  They'd all been merged via "squash merges", meaning there was no merge commit to easily link back to the source branches. I wanted to delete these unnecessary branches, but only the ones that had definitely already been merged into the master branch via a pull request (PR). Below is how I used the Azure Devops CLI to get a list of them. It hinges on the fact that each PR contains the name of the source branch that was being merged at the time.

# first, get a list of branches (aka references) $refs = (az repos ref list | convertfrom-json); $refNames = ($refs | select -ExpandProperty name) # next, get a list of all completed pull requests that merged into the master branch $prs = (az repos pr list --status=completed --target=master | convertfrom-json) # finally, find the PRs where the source branch matches one of the current branches, and select some relevant fields. These should be s…

Set "Windows spotlight" lockscreen images as desktop wallpapers without installing anything

I ended up moving the code for this post into my github since I'm using it myself ;) Get it from here:
https://github.com/mwanchap/configs/blob/master/Scripts/Windows%20Spotlight%20Wallpapers.ps1

Once you've cloned it, the only things you need to do are:

Decide where you want the wallpaper images to goUpdate the $location variable in the script with that location (I'm using ~\Pictures\Spotlight Wallpapers)Run the scriptOpen windows background settings and set the background type to "slideshow", pointed at that locationRun the script at startup if you want to get new images all the time (optional but recommended)