Hacking Hack

6
Filed under Fonts, Text Editors, Visual Studio

First, the TLDR

Download my custom Hackd font here. Unzip, and install the two TTF files. That’s it.

On Programming Fonts

I’ve long been a fan of dedicated, monospaced programming fonts. I’ve even got a page here dedicated to a breakdown of most of the fonts I’ve had the opportunity to work with and review over the years.

I’ve used a number of these for a good period of time, including Consolas, Cascadia Code, and FiraCode among others.

But, for some time now, Hack has been my goto choice. It’s clear, simple, with good spacing, and excellent readability.

Alas…

As usual, though, there’s a few things that have always not sat well with me.

First, Hack has a peculiar dotted zero.

That’s just always seemed off to me.

Plus, it’s percent sign just didn’t jive with the rest of the font.

msedge_3oPHWPX4FB

And then there’s ligatures.

The Ligatures

If you aren’t familiar with ligatures, they’re basically substitutions of a single, conhesive glyph for 2 or more glyphs places next to each other.

For instance, a ligature for “greater or equal”, “>=” might look like this:

It’s important to note however, that ligatures are just a rendering nicety. They don’t actually change the characters you type at all. So, although it might look like one character on screen, your file’s content will still be “>=” just like it always has been.

I realize that there’s a lot of gnashing of teeth online about whether ligatures are worth it or not. In the end, I think it’s completely a matter of preference, and I happen to find them quite nice to look at and helpful during my day to day coding.

And Hack doesn’t have ligatures

When Monospaced isn’t Monospaced

Virtually all dedicated programming fonts are monospaced; every glyph has the same width. But, while a font might say that it’s monospaced, and might have all the right metadata to indicate that it’s monospaced, it turns out that all that doesn’t necessarily mean that it is monospaced.

In fact, there are some apps out there that detect a monospaced font not via metadata, but rather via a Windows call that actually tests if all the glyphs are the same width.

I happen to use a couple of those apps and, as it happens, Hack doesn’t pass that test, so it’s not listed as a choice for font in those apps. And that has been a (rather admittedly trivial) thorn in my side for some time now.

Introducing Hackd

So without further ado, I’d like to present my own take on a programming font; Hackd!

Hackd is based on Hack v3.003, used for most base symbols and upper/lowercase latin glyphs.

I then merged in glyphs from FiraCode v6.002 for all ligatures and pretty much all other characters.

Further, I pulled the % glyph from Firacode and tweaked it slightly to look more “Hack”ish.

 

And finally, I merged in the Powerline glyphs from “Hack Regular Nerd Font Complete Windows Compatible” from the NerdFonts collection.

NOTE: I left out virtually all of the excess glyphs from NerdFonts, including company logos, weather symbols, etc. I just don’t see much utility in having them in the font, unless, maybe, there might be some use for them in some kind of command line terminal customization? I did include the PowerLine symbols for that reason.

Would love to hear any comments on that…

How I Did It

I used FontForge for all manipulations.

I started with FiraCode-Regular and FiraCode-Bold.

Replaced all the glyphs from ! through ascii 255 with the Hack glyphs.

Then pulled all the powerline glyphs from the Hack NerdFont ttf file.

Replaced the % sign using the FiraCode version, then tweaked it by scaling it and repositioning it slightly to look better.

Tweaked all glyph widths to be the same. This automatically causes FontForge to generate a proper “monospaced” font that truly is considered monospaced. Originally, Hack had several glyphs that had a 0 advance, which caused the font to not be considered monospace, even though it really should be.

Updated various metadata in fonts to reflect the history, source, new name and version number.

Repeated all this for both the Regular and Bold versions of the font.

What About Italics?

Once that was done and the new fonts installed, the regular, italics, bold and bold italics alternatives were all available, so I did not create the BoldItalic, Italic, BoldOblique or RegularOblique alternatives as they didn’t seem necessary.

Disclaimer

I’m no fontographer, and I definitely couldn’t have done this without the fantastic work done by the Hack and FiraCode authors, much less the author of FontForge, so my hat’s off to all of them!

Font choice is a highly personal thing, and this work reflects my own personal preferences and taste. My main reason for documenting this is to show that there are tools available that make this kind of customization completely possible, if not easy.

 

Upgrading to WordPress 6.1

0
Filed under Blogging, WordPress

This site’s been chugging along for years now. I’ve been super happy with my hosting company, NameCheap, and everything has just worked.

Until, of course, it didn’t.

I used to use Microsoft’s LiveWriter way back when, but then, they quit updating it and it quit connecting to my blog so… I just used the WordPress editor and continued on.

I finally had minute to take a look and realized that I hadn’t updated WordPress is quite some time.

So, back up the site, then update… oops, no, I’m using an ancient version of PHP.

So, update PHP to 8.1

Update WP to 6.1

Bam!

Critical error loading WordPress

Oh Joy

So I start all the typical stuff. I’m no WordPress expert, by any stretch.

Update all the plugins.

Nope

Disable all the plugins.

Nope

Clear caches. Reset Themes.

Nope, and Nope.

This might turn into a long night.

So I punt.

The guys (and gals) in NameCheap support have pulled me out of a wringer before, so I figured I might give em a shout. The worst they could do is tell me “that’s your programming problem”. Smile

Joy

So I search the Knowledge Base right quick, come up empty, and finally decide to file a support ticket.

Within an hour, I get a message back that they’d had a look at my WordPress log and the issue appeared to be with my theme at line x.

No freakin’ way!

Open the theme INDEX.PHP up and, sure enough, turns out the old WordPress was more forgiving with PHP files that used <? … ?> instead of the newer style <?PHP … ?>

Literally 2 lines of code changed and presto. Entire site back and running!

And not only that, the latest OpenLiveWriter (the open sourced version of my old friend), recognized it and loaded up perfectly. I’m even writing up this entry using it!

Starting VSCode from the command line

0
Filed under Uncategorized

I do a lot from the command line, so starting VSCode to quickly edit a file I’m looking at can be a big help.

VSCode isn’t automatically added to the path, so it won’t normally be available. Besides, if you’re using the Insiders build, the exe name will be Code – Insiders.exe, which is, um, unwieldy, to the say the least.

I know there are other solutions out that that might make more sense depending on your situation, for me, setting up a simple BAT file to start the editor made the most sense.

I already have a folder full of utilities and BAT files that I always add to my path anyway. Plus, I like having a bit of flexibility that wrapping VSCode in a BAT file gives me.

Anyway, here’s what I’ve ended up with.

ECHO off

REM Starts VSCODE and returns immediately to the console where it was started from
REM Running it a second time just opens the new file in a new tab in the existing VSCode window
start /MIN /B "" "C:\Users\darin\AppData\Local\Programs\Microsoft VS Code Insiders\Code - Insiders.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 >nul

Using this, I don’t get “leftover” phantom command line windows, I don’t get random debug logging in the terminal window I started it from, and it all “just works”.

Of course, you’ll have to adjust the path if your name’s not “darin” 🙂 , if you’ve installed VSCode in a non-standard place or if you’re using the normal, not Insiders, version.

Tiny Icons on High DPI Systems

0
Filed under Uncategorized

I’ve been using a triple monitor setup with all three running at high DPI (4k) resolution for some time now, and I love it. I use 200% scaling, so text is reasonably sized, but at 4k resolution, it’s so much clearer and easier on the eyes.

For the most parts, apps “just work” at that scalemode. But every once in a while, I’ll run into one that doesn’t.

Take for example, ClipCache:

Notice how the toolbar icons are tiny! The app’s excellent and I use it all the time, but the developer, while still supporting it, isn’t all that responsive towards updates, unfortunately.

But, it turns out there are things to try that might just resolve these sorts of issues without resorting to code updates by the developers.

Find the EXE file for the app in question. In this case, it’s Clipc.exe.

Right click and choose Properties, then Compatibility:

Now click Change high DPI settings.

You may have to experiment with the settings here. In the case of ClipCache, I set the Program DPI to checked.

Then checked Override high DPI scaling behavior.

And finally, selected System (Enhanced).

I suspect other apps may require slightly different options.

In any case, restart ClipC and presto!

No more tiny toolbar!

Application Access – Part I

0
Filed under Uncategorized
Plastic Black Container With Many Tools Elevated View Of Plastic Black Container With Many Tools On Wooden Table toolbox stock pictures, royalty-free photos & images

I’ve been doing a lot of reflecting lately on how my typical workday progresses and one of my primary realizations is that I spend a lot of time switching between applications.

There’s all the typical development applications, Visual Studio, VSCode, Command line, GIT, Insomnia, Web browsers, file search, clipboard stuff, etc. There’s usually an instance or two of these running, and I often find myself ALT-TABing between them.

Then there’s various utilities that I use regularly but not necessarily constantly: putty, SSH, Fusion, Dbgview, etc. Find it, Open it, Use it, Close it, repeat.

And finally there’s all the other apps that hang out in the periphery: Word, Excel, Outlook, Zoom, Remote Desktop, VMs and so on.

Now, I’ve pinned a few of those to the taskbar, so they’re just a mouse click away. However, there’s only so much space down there. Sure, I could stack some in a folder, which would present as a menu, but then often used items would inevitably end up hidden behind one or more layers of menus.

Of course, there’s the Start menu. But after awhile, that becomes large enough to prevent any kind of speedy access. And then there’s the Start Panel, but again, it can begin to get unwieldy fairly quickly for me.

Plus, when customizing the Start menu, etc, there’s the issue of synchronizing changes between machines. Google Drive helps, but not really for the Start Menu or TaskBar.

As I hinted at above, part of my realization was that there’s three levels of application usage for me.

Utility Belt Apps

These are apps that I almost always have running. I need to switch between them quickly and seamlessly. Adam Savage, of Mythbusters and Tested fame, even has a term for it, which I completely forget and can’t seem to locate right now. Irony?

In any case, the idea is that you shouldn’t have to move any tool to get to any other tool. And I can’t think of a better way to describe Toolbelt level applications.

And for that kind of accessibility, you’re really talking about one thing; hotkeys.

Windows does have the ability to assign hotkeys to shortcuts, icons, etc. but the selection is pretty limited, and when you regularly work with applications like VSCode or Visual Studio, most of the typical hotkeys are already in use by those apps.

Further, if I have two or more instances of any particular Toolbelt app open, I need to quickly switch between those instances, not go Alt-Tabbing through every opened desktop window.

Toolbox Apps

These are those apps I use often but that don’t really deserve being added to my Path. For these, finding them is usually the most time-consuming part. They aren’t constantly in use, but none-the-less, I’d like them to be ready at hand. For instance, when you need to hunt down a library binding issue with a .Net application, I’m gonna reach for FusLogVw, but that app isn’t normally on the path, or easily locatable.

Junk Drawer Apps

Everything else, which I’m perfectly comfortable leaving in the Start Menu where they’re installed and digging them on when I need them. They’re not used enough to justify going on the Toolbelt or in the ToolBox.

How you break things down? Have I missed anything?

I’ll be posting more as I start to solve this problem.

Making CapsLock Relevant Again

0
Filed under Uncategorized

I’ve seen a few articles here and there about Capslock, but now I’d like to throw my own spin on the topic.

Capslock is probably the most useless key on modern keyboards. It’s an antiquated holdover from the days when typing was actually a quite physical activity.

But now, about the only time Capslock gets hit is by accident. It’s BAD FORM TO SHOUT THESE DAYS, after all.

So… what can we do about that?

Ctrl, Alt, Shift Oh My!

If you’re anything like me, you spend your days in a host of applications, all of which have various functions assigned to just about every conceivable combination of hotkey. There’s all the standards: Ctrl-V, Ctrl-C, Ctrl-X. There’s the Ctrl-Shift variants and the Ctrl-Alt variants. Then there’s the less common Alt-Shift variants.

And then there’s those sadistic Ctrl-Alt-Shift hotkeys that exist just to make sure if you didn’t already have carpal tunnel, you will soon enough.

But what if you could use that CapsLock key as another modifier key; a Ctrl2 if you will?

Suddenly, you have a whole smorgasbord of easy to type hotkeys available. Not to mention Shift-Ctrl2 and Alt-Ctrl2 options as well.

And sure, Ctrl2-Shift-Alt, Ctrl-Ctrl2, and, well you get the picture.

Macro Apps

Sure there are macro applications and hotkey applications out there. Plus, your favorite applications may already have customizable hotkeys built in.

But, they likely only support some combination of Ctrl, Shift and Alt for hotkeys, which doesn’t much help with repurposing that CapsLock key.

Remapping

The first step toward solving this problem is changing the CapsLock key to something , almost anything, else.

It turns out, that’s far easier than you might think. On Windows, you can actually remap virtually any key to any other key with nothing more than a registry entry and a reboot.

“Ugh!” you say. “Editing the registry!”. I get it.

Head on over to https://github.com/randyrants/sharpkeys, and install it right quick.

It’s a tiny little app that takes the guesswork and tedium out of editing the registry for this purpose.

Here’s the entry I used. This will make the CapsLock key act like an F19 key (yes, there’s actually far more function keys than just the F1-10, but most keyboards don’t have them).

Why F19? Meh. Seemed like a far enough out-of-the-way F key to not likely get mixed up with any application’s intentional use of a function key. Plus, it works easily with the technique I’ll go into below. But choose whatever you like. There’s F1-24, plus quite a few Unknown key codes as well that would probably work too.

Click the Write to Registry button and close, then reboot. And done.

When your PC comes back up, give it a try, press Capslock.

Nothing. Beautifully, blissfully, nothing! No capslock light coming on. No SHOUTING. Nothing.

But What IF I WANT TO SHOUT!

At this point, you’re probably asking yourself, “But what about Capslock?”

Grab a copy of AutoHotKey and create this script:

*F19::
    If (A_ThisHotkey == A_PriorHotkey && A_TimeSincePriorHotkey < 300)
    {
        If GetKeyState("CapsLock", "T") 
            SetCapsLockState, off
        else
            SetCapsLockState, on
    }
    return

Save it to a file called CapsLock.ahk. And then run it with AutoHotKey.

Now then, just double tap the CapsLock key, and, presto, that CapsLock light will beam its soothing green rays right into your eyes once more.

Double tap again to turn it off.

Hot Keys! Hot Keys! Hot Keys!

Ok, so getting the ability to shout again is nice and all, but there’s gotta be more than that.

And, Oh, there is!

That AutoHotKey app you’ve already installed? You’ve only just scratched the surface of what it can do.

How about making CapsLock work like the Ctrl key? Create another AHK script like this:

F19::LCtrl

Or how about CapsLock-N starting Notepad instantly?

F19 & n::Run Notepad

Or how about CapsLock-Insert appending selected text to what’s already on the clipboard

F19 & Insert::
   clip := Clipboard
   SendInput, ^C
   ClipWait
   clip := clip . Clipboard
   clipboard := clip 
   return

The sky’s the limit. Get familiar with AutoHotkey and you’re likely to find a ton of uses for it.

And with CapsLock now available as a completely new (and completely open) modifier key, you won’t have to worry about conflicting with the hotkey definitions of any other application.

Remote Desktop

I spend almost all day connected to remote machines via remote desktop. A wonderful follow-on benefit of this technique is that, since you’ve remapped Capslock on the host machine, even when you’re connected to a remote machine, Capslock will still map to F19, so the remote machine won’t see any CapsLock keypresses either.

It will, however see F19 keypresses. So, you have the option of deploying and running your AutoHotkey scripts on the remote machine, and they will see the F19 keypress exactly like scripts on the host machine, to be used in any way you see fit.

Lastly

If you’re still following along and all this sounds great, keep in mind that the ScrollLock and those number pad keys can all be remapped in the same fashion. Depending on your typically workflow, that may or may not make sense for you, but the process is exactly the same.

Macros in VS 2022?

0
Filed under Uncategorized

I’ve lamented Visual Studio’s lack of built-in macro support for ages. I tried a few extensions a while back but they never quite measured up.
But I just stumbled across Text Macros for VS 2019-2022.

It’s perfect for a quick, one-off Record/playback macro, you can save macros, edit them (although that’s not ideal as the macros are saved in a rather obtuse XML format), and even assign them permanently to hotkeys.

It’s only good for text editing macros, so you can’t use it to “automate” Visual Studio itself, but I’ve yet to have a need to do that.

Fixing VSCode’s broken Ctrl-Right

0
Filed under Uncategorized

I’ve been using VSCode for quite some time now. Generally speaking, I’ve been super happy with it. It’s ultra configurable, fairly light weight, very fast, and just generally a pleasure to work with.

Except….

They completely got handling of Ctrl-Right wrong. Try it in Word, try it in Notepad++, in Visual Studio, you name it, they all work a certain way.

But VSCode, not so much.

Now, it’d be easy enough to get used to it, if all my editors decided to change the default way they handle Ctrl-Right. But, yeah, no.

I’ve dealt with it for a while now but this weekend, I finally decided to have a look.

It took some Google-foo, but eventually I came across this post by Spongman that very accurately describes the problem.

I won’t repeat that here, but here’s the keybindings for VSCode that fix the problem.

    {
        "key": "ctrl+shift+right",
        "command": "-cursorWordEndRightSelect",
        "when": "textInputFocus"
    },
    {
        "key": "ctrl+right",
        "command": "-cursorWordEndRight",
        "when": "textInputFocus"
    },
    {
        "key": "ctrl+right",
        "command": "-cursorWordAccessibilityRight",
        "when": "accessibilityModeEnabled && textInputFocus"
    },
    {
        "key": "ctrl+shift+right",
        "command": "-cursorWordAccessibilityRightSelect",
        "when": "accessibilityModeEnabled && textInputFocus"
    },
    {
        "key": "ctrl+right",
        "command": "cursorWordStartRight"
    },
    {
        "key": "ctrl+shift+right",
        "command": "cursorWordStartRightSelect"
    }

It’s a bit tricky to get them installed in VSCode, what with the new Settings UI, but, once they’re there, Mwah! Perfection!

0
Filed under .NET, SQL, Visual Studio

Command Line MSSQL

SQL on the command line!

There’s a number of tools out there for connecting to an MSSQL Database and running queries from the command line, but a colleague recently pointed out a new one I hadn’t seen before that actually works really really well, especially with Windows Terminal and Cmder.

First, make sure you’ve got Windows Terminal and Cmder installed. They are truly the bees knees when it comes to working in the command line under Windows!

Next, install mssql-cli. This app is actually a python script, so you’ll also need Python if you don’t already have it installed. Don’t fret, though. The link contains instructions on getting Python going, and once that’s done, installing mssql-cli is a single pip command:

python -m pip install mssql-cli

To test it, just open a command prompt and type:

mssql-cli

Now, that alone is nice, but if you’re like me, you have several test databases you connect to on a regular basis and entering credentials is troublesome at best.

Not to worry. There’s a batch file for that!

Now, it’s not the simplest in the world even though it is a single liner. So here goes:

wt -d c:\users\dhiggins\desktop cmd /k "c:\apps\cmdr\vendor\init.bat cd %CD% && mssql-cli -U {dbloginusername} -P {password} -d {dbname} -S {dbservername}"

Let’s break that down:

  • wt – starts Windows Terminal
  • -d – followed by the folder you’d like to start terminal in. Not strictly required, but it’s a nice add. I just set it to my desktop
  • cmd – This is used to get Cmder started in a tab in Windows Terminal
  • /k – tells cmd to execute the following quoted command and stay loaded
  • “c:/apps/cmdr/vendor/init.bat – this get Cmder started and the shell all initialized. Note that the path to your installed copy of Cmdr may be different from the “apps/cmdr” that I have here.
  • cd %CD% – Gets Cmder switched to the folder that this bat file is located in
  • && mssql-cli – Actually starts mssql-cli! The whole point of this exercise.
  • -U {dbloginusername} – Provider the UserName you use to log into your db server here
  • -P {password} – provide the database user password here
  • -d {dbname} – provide the database name here
  • -S {dbservername}” – And finally provide the database server name here. I’m just connecting up to the locally installed instance of SQL Server.

Save that as a BAT file and dblclick it to launch directly into a Cmder tab inside Windows Terminal connected to the DB of your choice. Perfection!

One big benefit from using Cmder, at least from what I can tell, is that it automatically supports horizontal scrolling of query result sets.

Notice that those right pointing arrows!

Just use <left><right> arrow keys to scroll the grid left and right as you page through results.

If you don’t use Cmder as your shell, scrolling won’t work like that unless you install something else called PyPager. Which I didn’t do.

Visual Studio Bonus!

Now, all this is well and good, but as they say on late, late night TV: Wait! There’s more!

I spend a lot of time in Visual Studio, so any way to stay there tends to be a positive for me, and one of the most recent additions to VS is built-in Terminal support.

Works a treat and even works with Cmder, so you get all that great Cmder goodness right inside Visual Studio.

But, you can create as many “Terminal Configurations” as you want, so here’s a shot of a few that I have, including one running Cmder directly and another starting the MSSQL-CLI directly to a specific database.

Easy and quick direct access to a specific db, Right inside VS!

Rainmeter WebParser Problems

0
Filed under Uncategorized

A colleague recently pointed me to a fantastic little desktop customization app for windows, RainMeter.

He was using the lottaweather skin, so I pulled that as well, and I’ve found it quite nice to have a really clear forecast stuck right there on the desktop.

Beautiful Weather Skin

It’s tiny, quite capable, and is really easy to knock up a quick notification panel or whatnot based on a webservice, or so I thought.

At work, we’d recently been throwing ideas around about how to be reasonably notified of build failures and Pull Requests/Statuses.

Another colleague came across AnyStatus, which is quite nice in it’s own right, but I thought it’d be nice to have something in the same style as lottaweathers skin.

I’ll dig into the details of scraping azuredevops and jenkins later, but while putting things together, I ran into a vexing problem.

I had one measure that resolved the users azure guid “id” given their name and a different measure that requested all the Pull Requests where that userid was listed as a “reviewer”.

Pretty standard stuff for RainMeter, and the urls I was using worked just fine in PostMan, but not Rainmeter.

Actually, the UserID request worked, but not the Pull Request query.

Here’s the measure definitiion:

[MeasureMyReviews]
Measure=WebParser
Disabled=1
URL=https://azuredevops.blahblah.com/#organization#/#project#/_apis/git/repositories/#repository#/pullrequests?api-version=5.1&searchCriteria.reviewerId=[MeasureUserID]
Header=Authorization:Basic #AzureDevOpsPATBase64#

After WAY too much head scratching, I discovered the problem was two-fold.

  1. My measure referenced the UserID measure like so: [MeasureUserID] but that syntax doesn’t work in this context. In a URL definition, it needs to be [&MeasureUserID] (note the &)
  2. WebParser measures happen asynchronously, but in this case, the “MeasureMyReviews” has to happen AFTER the MeasureUserID. Otherwise, the userid hasn’t been resolved and will just be blank.

The fix was to set Disabled=1 for the MeasureMyReviews measure, then enable it in the FinishAction of MeasureUserID, like so:

[MeasureUserID]
Measure=WebParser
URL=https://azuredevops.blahblah.com/#organization#/_apis/identities?api-version=5.1&searchFilter=General&filterValue=#username#
Header=Authorization:Basic #AzureDevOpsPATBase64#
RegExp=(?siU)"id":"(.*)"
StringIndex=1
DynamicVariables=1
FinishAction=[!SetOption MeasureMyReviews Disabled 0][!UpdateMeasure MeasureMyReviews]

Note the two bang commands in the “FinishAction”