Sometimes you have to deal with the rats in the attic.
A coworker dropped by to brainstorm a perplexing problem he noticed in the report he was working on. The report is a PDF document generated from XML using XSLT and Apache FOP. An index table appears on the last page of the report, listing the name and page number of each section in the report. All of the sections were listed with the correct page number, except the section output on page 2 of the report, which the index showed as starting on page 1.
After tracing through the legacy XSLT code for a couple of minutes, we realized that the section start was flagged in the XSL-FO code in an "invisible" table that happened to come out at the very bottom of page 1, forcing the "visible" table over to page 2. Thus the table of contents correctly but deceptively showed the section starting on page 1. The code base that generates this report is several years old, and it has gone through multiple hands, as such code often does, so we had no idea why the original designers chose to output the section start flag in this way.
We came up with a couple of possible fixes he could to try, like eliminating the "invisible" table and moving the flag into the visible table, or if the invisible table was really necessary, apply a "keep with next" attribute so it would always stick to its corresponding section.
My coworker then said the problem reminded him of a scene from Bad Boys 2 (caution, link is not PG or SFW!), wherein Cuban drug lord Johnny Tapia, crawling through the attic where he stashed a mountain of stolen cash, discovers a nest of huge rats gnawing through the piles of loot. After blasting the rats with a cannon-sized revolver, Tapia exclaims to his henchman, "Carlos, this is a stupid f****ing problem to have, but, it is a problem, nonetheless!"
Wednesday, March 28, 2012
Wednesday, February 15, 2012
Wednesday, January 11, 2012
How to write regexs matches that span multiple lines in Visual Studio search
Visual Studio has its own weird syntax for searching with regular expressions. Here's how to make a match across multiple lines. Given the sample XSL blocks below
The first bit,
The at sign @ is VS's way of asking "please can you find zero or more carriage returns, but only as few as needed." The alternative is the "greedy" match, using an asterisk *, which says "find as many lines as you can ending in carriage returns before you hit
<xsl:apply-templates select="Alph" mode="frobit"/> <xsl:apply-templates select="Bob" mode="zap"/> <xsl:apply-templates select="Cam"/>I want to match the two statements with the
mode="frobit", even though the first one has a carriage return in the middle. In VS, you'd use this regex statement to match just the first and last lines, skipping Bob with mode="zap":select.*\n@.*mode="frobit"
The first bit,
select.*\n, is standard Perlish for "match from the word select to the end of line character, \n."The at sign @ is VS's way of asking "please can you find zero or more carriage returns, but only as few as needed." The alternative is the "greedy" match, using an asterisk *, which says "find as many lines as you can ending in carriage returns before you hit
mode="frobit", so the match in this case would make one giant match, including all of the text from select="Alph" all the way to the last "frobit" on Cam, capturing poor Bob in the middle along the way.
Friday, January 6, 2012
How to clean up Windows Media Player
If you've relocated or removed a media directory but its contents are still showing up in WMP's libraries list, try deleting the contents of C:\Users\[username]\AppData\Local\Microsoft\Media Player. That should clear out phantoms!
Tuesday, January 3, 2012
How to restore TortoiseSVN icons in Windows Explorer
From the TortoiseSVN FAQ:
With TortoiseSVN 1.3.0 and later, you can also rebuild the icon cache by calling TortoiseProc from the command line like this TortoiseProc.exe /command:rebuildiconcache
Thursday, December 1, 2011
Open Windows Explorer from the command line with a Folder tree
Did you ever have one of those "GARGHH!" moments when someone shows you how to do something sorta obvious but not really? Like opening Windows Explorer from the command line the way you want it to look? For example, I changed the default action for files of type "Folder" from "open" to "explore". That way, when I double-click a folder shortcut or "My Computer", the sidebar in the Explorer view shows the list of folders instead of the list of tasks, other places, etc.
The commands C:\>start foo or C:\>explorer /e, foo (notice the switch and comma!) opens Windows Explorer view the way I like it:
The commands C:\>start foo or C:\>explorer /e, foo (notice the switch and comma!) opens Windows Explorer view the way I like it:
Typing C:\>explorer foo produces a standard or default view:
This respect for the user's preferences seems to extend to things like the tool bars and status bar and type of view, e.g. tiles or details. C:\>explorer foo seems to ignore all of your preferences.
Thanks to the mighty folks at How-To Geek for the awesome insights.
Saturday, November 19, 2011
Subscribe to:
Posts (Atom)
