Monday, September 17, 2018

Why is Y the Abiathar hotkey for Grid?

Here's a little tidbit of Abiathar history.

The keyboard shortcut to toggle the visibility of the grid is Y, not G. Before version 1.0, the menu item to start a new project was called Gather because project creation involves gathering up the several files that represent a level set. (The window to do that, which survived the entire 1.x series and was only retired in 2.0, was internally called the Dependency Gatherer. I don't recall whether or for how long that name was displayed.) The first letter of Gather is G, so that was the hotkey. When I added the grid, I figured that Y was a decent choice because it's close to G on the keyboard.

Feedback I received on the pre-release version informed me that the "gather" terminology was confusing, so I changed the menu item's text to New and the hotkey to N. The grid hotkey apparently didn't cross my mind when I was making that change because it didn't get changed to take advantage of the now-free G.

In version 2.0, the two tools that had no hotkey were given shortcuts. G and H went to the Tile Instance Remapper (effectively a find-and-replace tool) and Tile Instance Locator (find), respectively. H was for "highlight" (the TIL added a highlight to the desired tile) and G was next to it (replace is a related operation to find). Later down the line, the Tile Instance Locator tool became the Find Highlight view mode, but the TIR is still a tool with hotkey G.

Sunday, September 16, 2018

Retrieving old file versions from Git in IntelliJ

IntelliJ can integrate nicely with Git for version control. One very nice feature is the ability to see and roll back to old versions of specific files. Right-clicking a file in the Project pane and choosing Git | Show History produces a window with the commits affecting that file. Those commit entries can be double-clicked to see the file as it was at that commit. The version can be restored by right-clicking the commit and choosing Get.

Thursday, September 13, 2018

Artificial Intelligence Stack Exchange gets a sponsor

Last week, Artificial Intelligence Stack Exchange got a nice surprise announcement from Stack Exchange the company. IBM signed on as a sponsor, so AI.SE got a really neat new design, plus a "sponsored by IBM" logo in the upper right. Apparently IBM's Win with AI conference mentioned our site, so we might get an influx of traffic. Other than the design and help with promotion, site workings will proceed as normal.

Tuesday, September 11, 2018

Showing a message to the interactive session

One user needed a program in a background session (like from a service) to display a simple message to the currently logged-in user. If no fancy UI or choice-making features are required, the msg command will work great. It can use a session name to specify the session that receives the message, so you don't even need to determine the account name of the interactive user:

msg console Your message here

Monday, September 10, 2018

getLastLocation isn't necessarily the current location

My Android app uses the fused location provider client's getLastLocation method to get the user's location when needed. Usually this works great. I have noticed, however, that it sometimes gets a stale location (where the user was during a previous fetch). When having the exact, most up-to-date location is necessary, I use requestLocationUpdates and have found that this works well.

Sunday, September 9, 2018

Use the activity context for UI-related operations

Many Android API calls require a Context. Activity objects serve as contexts, but a different context can be acquired with getApplicationContext(). One might be inclined to call that function from inside an inner class when a Context is necessary, but when doing anything UI-related, using the enclosing activity class's this is a much better idea. Using the application context is likely to use a different theme than the activity, which can make the elements of inflated layouts look weird. In my application, that made text views use the wrong color and become extremely difficult to read on some (but not all!) devices.

Saturday, September 8, 2018

Put a unique constraint on columns that should be unique

One of my applications retrieves data from a third-party service and caches it in an SQL database. The external service's responses use strings as the ID of certain records, but in my database those records are also given a numeric primary key. When correlating other responses for different record types from the third-party service, I often need to get the numeric ID corresponding to the service's text ID. This is a very simple subquery, but it broke recently due to an unfortunate concurrency issue. The text-ID-containing items got inserted into the table twice, so the subquery started returning multiple values, which removed the ability to put the result into a single field and therefore broke other parts of the system.

The duplication could have been prevented with transactions (which I have now put in place for that component - others already used transactions), but the cascade failure could have even more easily been prevented by putting a unique constraint on the textual ID column.

Wednesday, September 5, 2018

Updating the Ubuntu installation in Bash on Ubuntu on Windows

Recently I had some trouble installing a package inside the Bash on Ubuntu on Windows environment. I found that I needed to update my Ubuntu distribution. As I read in this Super User answer, that can be accomplished with:

sudo do-release-upgrade -d

In the process, there will probably be some prompts about replacing altered configuration files. I found that choosing any option other than a simple yes or no (the ones that let you explore the differences between the two config versions) makes it extremely easy to get stuck and unintentionally terminate the whole procedure. When I accidentally did that, I found that just running the upgrade command again mostly picked up from where it left off.

Tuesday, September 4, 2018

Excluding certain file extensions from a recursive Copy-Item

One user was using PowerShell's Copy-Item cmdlet to copy an entire directory structure and wanted to avoid copying certain file extensions. Copy-Item has a -Filter parameter, but more conveniently it has an -Exclude parameter that takes a simple array of file name patterns to skip. So using -Exclude '*.mp3', '*.exe' will skip copying MP3 and EXE files.

Monday, September 3, 2018

findstr supports wildcards in the form of regular expressions

One user wanted to use a batch script to search for a wildcard-enabled pattern in a file. findstr can do this, but with a somewhat different wildcard format. A period matches any single character (the equivalent of a question mark in usual batch wildcard style). Putting an asterisk after the period to make .* matches any run of characters, the equivalent of an asterisk in the usual batch style. Supplying the /c switch disables regex support and uses the pattern as a literal string. The end of the output of findstr /? has a quick regex reference.

Sunday, September 2, 2018

Doing a rebuild might work even if normal runs cause bizarre compile errors

My Android app project has developed a bizarre tendency. When I do a normal run from Android Studio, the build usually fails with an error about being unable to find a class that clearly exists in the project. But doing a Build | Rebuild Project works perfectly, and then a run will successfully deploy the result of that compilation. The downside of this is that a full rebuild takes a while.

Exporting an EFS key requires being logged in as that user

One user wanted to move an EFS certificate/key to a different Windows installation. They were interested in taking the key out of the offline system, but this would be very difficult because of how the keys are stored. The key material is itself encrypted by another key derived from a variety of things. To export the key, one can use certmgr.msc or, if it doesn't want to export the private key, do a bit of PowerShell. Unfortunately, both methods require being logged in as the key's owner on the machine.