Category Archives: Visual Studio

Hacking Hack

17
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.

 

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!

Handy VS2010 Extensions

0
Filed under Subversion, Utilities, Version Control, Visual Studio

I’ve recently had to set up several machines for use with Visual Studio 2010 and found that I just about had to install several extensions, as they’re so useful in normal day-to-day programming.

They are:

  • The NuGet Package Manage (easily pull programming libraries into your project)
  • AnhkSVN for Visual Studio (great Subversion integration)
  • Productivity PowerTools (the “Locate in Solution Explorer” function alone makes this worth downloading)
  • VSCommands (the File Structure Viewer and enhanced syntax highlighting makes this one very nice)
  • DevColor (provided additional functions for setting colors in CSS/HTML files, right from the VS edit window)
  • IndentGuides (visualizes indents. Yeah, so you’re not REALLY supposed to have a for loop that spans pages of code, but hey, sometimes you have to read other people’s code, right? <g>)

There’s tons more extensions accessible from Tools/Extension Manage right inside Visual Studio, so if you haven’t browsed through it in a while, it might be worth a few minutes!

 

Oh, and, two more tools to throw out there. Grab a copy of the freeware Snarl from the guys at Fullphat and then download CommitMonitor, which connects to Snarl and provides you with toast notifications of checkins from other developers in Subversion projects that you care about. Handy stuff if your shop uses SVN.