Wednesday, May 30, 2018

List of cmdlets removed in PowerShell 6

PowerShell 6 (also known as PowerShell Core) has significantly fewer cmdlets than PowerShell 5 (the latest Windows-only version). That's because many cmdlets relied on native Windows functions, so if they weren't re-implemented in a platform-independent manner, they had to be removed. For this Super User answer, I generated a list of cmdlets that are gone in one version relative to the other:

Tuesday, May 29, 2018

Wildcard certificates from Let's Encrypt

Let's Encrypt started offering wildcard certificates a while back, but not all client programs are able to take advantage of the new API. This Microsoft blog post is a very good guide to using the official certbot client under Bash on Ubuntu on Windows. Two things to note:

  1. *.example.com does not cover example.com, so you need two domains on the certificate: -d example.com -d *.example.com. This will require putting two different TXT records into the same DNS zone.
  2. It can take a while for the DNS changes to become visible to Let's Encrypt. I used Google's dig tool to check that both TXT records were consistently being returned. (Different nameservers may pick up the changes at different times.) Only press Enter on the second verification after both records are live.

Monday, May 28, 2018

Windows feature updates might fix the desktop not appearing

I recently worked with a Windows 10 computer that, on only one user account, had stopped displaying the desktop and task bar (all Explorer components). Explorer tried to start, but pegged one CPU core and never got around to displaying anything. The Windows Push Notifications User service for the stuck account displayed similar behavior. I found a handful of purported fixes on the Internet for the lack of desktop, but none of them helped. What did help was the 1803 feature update that happened to be coming down - after the system installed it and rebooted, everything was functioning normally.

Sunday, May 27, 2018

Forcing a Start menu layout without restarting Explorer

One user was trying to set the Windows 10 Start menu layout with Group Policy's Start Layout setting. They found that changes to the layout XML file only took effect after restarting Explorer or logging out then back in. For a while I thought it was impossible to make Explorer reload the XML (none of the usual Win32 change notification functions worked), but then I found that restarting just the Windows Shell Experience Host process (shellexperiencehost.exe) will do the job without interrupting other Explorer functions. It'll automatically come back right after being terminated.

Saturday, May 26, 2018

PSThar - v1.2

I was hoping to add Simultaneous Tileset support to PSThar so it could set both $CurLevel and $CurTileset in the same console, but in the interest of getting the other new features out to users as soon as possible, I decided to release what I have as v1.2. The only change I didn't mention yet was that, to make it clear which mode the console was opened in, "Level" or "Tileset" is added to the caption of the console window as appropriate.

Friday, May 25, 2018

PSThar - Tileset support

One user was running a PSThar script to migrate some tile properties. She noticed that the PSThar console wouldn't open when only a tile palette was visible, which is to be expected since PSThar gets registered as a level tool. I definitely see how that could be inconvenient, though. So today I made PSThar also register a tileset tool, called with the same hotkey. When the console is started on a tileset, a $CurTileset variable is set instead of $CurLevel.

Thursday, May 24, 2018

FMod - Clipboard palette improvement

The single-tile minipalettes, once opened, can be toggled between storing and retrieving mode by a tap of the just the Up or Down key (as opposed to the Alt+Up or Alt+Down required to call them up in the first place). It seemed appropriate for the clipboards palette to have the same convenience feature, especially because Ctrl+Alt+Up/Down requires yet another key, so Up and Down now change the mode of the clipboards palette while the form is up.

To make the existence of the clipboards palette more discoverable, I added two menu items to the Edit menu, one for each mode. They call the palette form up into the appropriate mode and also serve to display the shortcut keys.

Wednesday, May 23, 2018

Getting the contents of a .NET embedded resource

Setting a file's Build Action to Embedded Resource in Visual Studio causes the file to be embedded in the assembly, but it's not obvious how to actually access the file's data. A Stream for a given resource can be acquired through the GetManifestResourceStream function on an assembly, most likely Assembly.GetExecutingAssembly() for the current one. The resource name is qualified by the root namespace, so a project with a root namespace of SomeProgram with an embedded file named TheDocument.txt would find that file at SomeProgram.TheDocument.txt.

Tuesday, May 22, 2018

Bad graphics drivers can cause extreme general slowness

For several months, one of my computers was being extremely slow for its specifications. There wasn't any clear bottleneck - things would stop responding for many moments even under very light CPU and disk I/O loads. I had intermittently tinkered with various settings and tried uninstalling things, but I only saw noteworthy gains after reinstalling the graphics driver (for completely unrelated reasons). Apparently the NVidia driver I had was poor. I'm not sure how it caused such bad general performance, but the new driver is much better.

Monday, May 21, 2018

FMod - Cut convenience improvement

A new user asked me whether Abiathar has a convenient way to move tiles from one place in a level to another (other than copying and then deleting them from the original spot). I was about to reply that it does - the Copier will cut if you right-drag instead of left-drag - but then I tested it and found that feature to be highly inconvenient. It cuts all copied planes, but "all copied planes" includes visible but locked planes which shouldn't be editable. Using it without blowing away other planes requires hiding those other planes outright, which requires more and different keystrokes. So today I made cut mode only cut planes that are fully active.

Saturday, May 19, 2018

Finding the results of a phpBB search that won't render

Yesterday I investigated a situation in which a phpBB forum completely failed to display the search results for a certain query, instead rendering a PHP error spew about invalid characters. I knew that the problem was that a post turned up by the search contained badly mis-encoded characters, which I would usually fix by hunting down the post in the SQL database and manually removing the bad characters, but this time my LIKE-based searching wasn't finding the post.

I happened to notice a table called phpbb_search_results. Apparently it contains recent searches and the cache key for each. I tried the problematic search then refreshed the table listing - sure enough, a row appeared. I looked for the cache key in the directory listing of /cache/production; the relevant file turned out to be data_search_results_CACHEKEY.php. The last line of that file seemed to include an array of some sort, some entries of which looked like post IDs (and a few of which I had found with my earlier database-searching attempts). Navigating to /viewtopic.php?p=POSTID for each candidate found the specific post that refused to render.

Removing garbled characters from that post made the search results page load as normal.

Friday, May 18, 2018

Policy Plus - Comments in Semantic Policy

One user found that Policy Plus doesn't have a convenient way to export POL files and keep the policies' comments with the policy states. Preserving comments in POL files would be difficult because they never hold comments at all - that's what CMTX files are for. The existing Semantic Policy (SPOL) format seems ideal for keeping everything about each policy together, so today I extended it a bit to include an optional Comment: line between the policy ID and the general state. Since comments can include newline characters, those are escaped as \n and backslashes as \\. The Inspect SPOL Fragment form has been updated to provide the comments from the appropriate policy-to-comment map.

I also updated the ADMX download URL to point to the package for Windows 10 1803.

These changes are live on GitHub.

Thursday, May 17, 2018

Backup Operators are only special because of assigned privileges

One user wanted to know how to replicate the effect of the Backup Operators group on a Windows edition that doesn't have it. In their case, there was an easier solution: making the backup user a full administrator wasn't a problem. In other cases, a Backup Operators-like group can be created by assigning any group the following privileges in the Local Security Policy snap-in's User Rights Assignment section:

  • Back up files and directories
  • Log on as a batch job
  • Restore files and directories
  • Shut down the system
The most important privileges are the ability to back up and restore files and directories. Logging on as a batch job is useful for scheduled tasks; shutting down the system is just something server managers might need to do.

The NTRights utility can be used on systems without the Local Security Policy tool to assign SeBackupPrivilege, SeBatchLogonRight, SeRestorePrivilege, and SeShutdownPrivilege to the group.

Wednesday, May 16, 2018

PSThar - v1.1

Over a year ago, I released PSThar, an Abiathar extension that embeds a PowerShell runspace in the Abiathar process to allow scripting of the editor. A week or so after the release, I added the ForEach-LevelTile cmdlet, a convenient shortcut for iterating over every tile in a level. I realized yesterday while writing some scripts for a user that I never released the new version. So today I bumped the version to v1.1, filled in the "long description" metadata field that I had missed before, and published the new AEX.

Tuesday, May 15, 2018

FMod - Fix order of startup warnings

A very helpful Abiathar user reported a UI issue. After program initialization is complete, Abiathar checks its command-line arguments to see if it should try to un-LZ an EXE or open a project file; that's all fine. If a project file's version is not recognized, Abiathar will produce a warning before trying to open it; that is also the intended behavior. However, if the project open attempt is made at startup (like when the user drags a project file onto the Abiathar executable), any warnings will appear under the splash dialog and therefore be unreadable. I fixed that by doing the command-line argument processing when the main form is shown (after the splash screen is gone), not during its load.

I also made the temporary level wrappers used by the clipboards palette read-only, since there should be no way for a tool to operate on them and render planes shouldn't be changing the levels.

Monday, May 14, 2018

FMod - Render copied blocks

Today I tied together all the infrastructural loose ends into a completed implementation of a clipboards palette for Abiathar. A view state - just like the ones for real levels - is maintained for each of the nine copied blocks. The clipboards palette form creates a level wrapper and a view state when a copied block is stored in a slot. The main renderer function now takes a plane filter function, which the clipboards palette uses to hide planes that the copied blocks do not contain. This avoids rendering an opaque background (of the background zero tile) when the copied block doesn't include the background plane. Since the palette form uses the main rendering function, hidden planes are also hidden in the palette. Likewise, tile properties and the find highlight are displayed if appropriate.


To select a clipboard slot for retrieving or storing, the user can click the image, click the label, or press the appropriate numeric key on the keyboard (probably the numeric keypad since the form is laid out to match that, but the normal numbers work too).

Sunday, May 13, 2018

FMod - Persistent saved clipboard

Yesterday I wrote the infrastructure needed for Abiathar to save and load chunks of tiles to/from project files. Today I used that to store the nine saved copied blocks when saving. The chunks of tiles are saved as the Base64 encoding of a simple binary format. Each plane has a byte of value zero or one indicating whether the plane is present in the copied block. If the plane is there, its width and height follow as 32-bit integers, then the tiles in the plane as 16-bit integers.

Saturday, May 12, 2018

FMod - Work on multiple clipboards

Today I implemented a good chunk of the multiple clipboard functionality. There is now a clipboards palette that can be called with Ctrl+Alt+Up to store or Ctrl+Alt+Down to retrieve. Clicking the spaces under each header indeed stores or retrieves the clipboard in that slot. The next order of business is to actually draw the copied blocks in the palette.

I also wrote some functions to serialize and deserialize chunks of tiles to/from text for purposes of stashing the copied blocks in the project file. This is mostly done but not quite hooked up yet.

As a really quick minor feature, the period key now selects the zero tile in all active planes. This is especially helpful for the foreground because if Assimilate Infoplane is off, the zero tile doesn't actually appear in the tileset. It's not hard to select the zero tile from a blank spot in the level, but if there are tons of foreground tiles everywhere for some reason, it'd be nice to have a guaranteed quick way of getting the zero tile.

Wednesday, May 9, 2018

FMod - Further refactoring for temporary levels

The function that prepares a level's view state (whether or not the level is a real level or actually a copied block) is responsible for adding all the render planes to it. The planes that involve the infoplane receive a function that tells them whether to render a given tile ID; this is used to hide the hex composites corresponding to links when the visual link overlay is enabled. If the user copies something that happens to look like a link, though, it wouldn't be good to display a link in the rendering of the copied block because, when pasted, it wouldn't end up pointing to the spot it appears to. (Galaxy links use absolute coordinates.)

So I adjusted the "create level drawing surfaces" function to accept the dimensions of the level for purposes of link identification. The old "create drawing surfaces for a real level" function just supplies the real level's dimensions. I also added a Boolean to the constructor of the level wrapper class that indicates whether the "level" should be treated as just a temporary chunk of tiles.

Monday, May 7, 2018

FMod - Refactoring for temporary levels

To implement multiple copied blocks in helpful way, Abiathar will need to be able to draw chunks of tiles that don't comprise a real level. To do that, I will need a way to manage level view states independently of level IDs. Today I did a bit of refactoring to make that possible. There is now a separate method to draw a given view state on a given surface, which is called by the main rendering function that historically assumed the current level is always the thing being drawn. A couple other little things, like the infoplane icon/link delimiter function needed to be adjusted as well.

Level wrappers now have a new Temporary property that will indicate whether they're just a temporary chunk of tiles instead of a full level. Tools should never see such wrappers, but render planes will.

Friday, May 4, 2018

If Android Studio shows nothing in Logcat, restart the emulator

I've noticed that sometimes Android Studio's Logcat window (where logged information from the attached or virtual device appears) stops updating with new log entries. Restarting and recompiling the app don't help; it just seems that Logcat gets stuck. Restarting the emulator solves the problem. I've observed this behavior with both the included Android Studio emulator and the Visual Studio Emulator for Android, but not with a real phone attached via USB.

Wednesday, May 2, 2018

If Android Studio can't resolve R, do a Clean Project

Occasionally Android Studio gets itself stuck in a state where it can't resolve R, the auto-generated class that stores all the IDs of the app's resources. (Sometimes it decides to stop resolving other important things too.) The solution is do force a full recompile using Build | Clean Project and Build | Rebuild Project.