Posts Tagged efficiency

Automation-assisted manual transformations

I had been unit testing an SQL generator and had a bunch of tests that gave various input to the generator and tested its output against expected SQL.   The SQL in my tests looked like this:

Now I was ready to feed the SQL to a database engine to verify that it was validly formed.  I would generally use grep for this type of task; but here my SQL statements were formatted multiline for easier reading, and grep operates in a line-by-line mode.  There were over 100 test cases, so it was worth figuring out an automated solution.  I also wanted to avoid writing a single-purpose text-processing utility if possible.

I ended up writing down the following steps for myself:

  1. Turn the tests into a single line of text for ease of working with tools
    On command line: cat Test*.cpp | tr -d "\n\r" > all-one-line.out
  2. Discard everything but the queries, inserting a newline after each
    In editor (SlickEdit for me), open all-one-line.out and Replace All (using Perl-style regexes):
    .*?("(?:\( )*SELECT[^;]+?;)
  3. Clean up what the regex didn’t
    Delete the last line
  4. Get rid of quotes
    Replace \" with nothing
  5. Get rid of semicolons
    Replace ;$ with nothing
  6. Get rid of extra spaces
    Replace <space>+ with <space>
  7. Save the file in the editor
  8. Get rid of Oracle-specific tests
    grep --invert-match TO_DATE < all-one-line.out > all-one-line.sql
  9. Let cool for 5 minutes before serving
    Paste all-one-line.sql into MS SQL Server Management Studio and execute (with Results to Text)

This may look like a large number of steps, but I got to where I could run through them in about 30 seconds and test all 130  queries on the server.  Nice!

Future improvements

Once I had the ability to test my test output against the database server, I wanted to do that each time the tests’ expected results changed.  So where I had originally envisioned a single smoke test run, I ended up going through these automation-assisted manual steps ten or twenty times.  In retrospect, the single-purpose utility script would clearly have been the better approach after all.  I need to get more comfortable whipping up such scripts to lower the barrier to writing them when these occasions arise.

Twelve years in, I would think I would be at the top of my craft by now, but there are still things that seem pretty basic that I’m learning.  Hmmm…I wonder if life really does begin at 40?

, , , , ,

Leave a comment

Default view settings in Adobe Reader

I’m running Adobe Reader 8 for Windows, and it’s slowly (I mean over the last year or so) dawned on me that every time I open a document it’s showing it to me at 112% zoom level in “jerky pagedown mode” (the non-continuous mode where if you’re near the bottom of the page but not yet exactly to it, pressing PageDown only scrolls a little way until you are exactly at the bottom; but if you’re already at the bottom of a page, PageDown goes completely to the next page).  I find it jarring that PageDown goes down different amounts depending on where you are on a page when you press it — I almost always want the “continuous” layout where PageDown always goes down one screenful.

Today I opened up a PDF document and once again found myself at 112% zoom level in non-continuous layout.  This time I decided to see if there is a default setting I could change.  And I found one!

I went to Edit -> Preferences… and chose the Page Display category.  In the Default Layout and Zoom area, I saw:

Old Settings
Page Layout Single Page
Zoom Fit Width

I changed these settings as follows:

New Settings
Page Layout Single Page Continuous
Zoom 100%

Clicking a link to a PDF, now it opens at 100% zoom in continuous display format. Ahhh!


Sage (-Too) for RSS reading

As the number of websites I read has grown, my reading algorithm — roughly summarized as: “Bookmark each site-of-interest; regularly check each bookmark to see if there is something new since last time I checked” — has not scaled well.  The checking is starting to take too much time.

My solution is to use a feed reader (the Sage-Too add-on for Firefox, in my case) and it can check all the websites I follow efficiently (that is, using very little of my brain) and only show sites that have new posts I have not already seen.

This solution requires that I change over to using “live” bookmarks pointing to each site’s RSS feed.  Before my New Solution, some of my bookmarks were live and some were the simple regular kind.

Sage-Too in Action

You start with just the little sage leaf in the Firefox toolbar:

Once you press that (or Alt+Z if, like me, you’re keyboard-inclined), the Sage-Too sidebar appears:

Press the “Check Feeds” button () and sites that have updates since last time I checked* show up in bold:

When I click on one of these bold titles, a list of the most recent updates appears in the bottom of the sidebar with unread posts appearing in bold; and in the main browser window, a few of the most recent posts are rendered in a way that makes it easy to skim the beginning of the article and see if I want to open it to read more:

If I do want to read more, I just click on the bolded article title in the bottom of the Sage-Too sidebar, and that takes the browser to that page:

I can toggle the Sage-Too sidebar closed so I have more space to read, by clicking the Sage button (or pressing Alt+Z) again:

If I bring up the Sage-Too sidebar again after closing it, feeds I visited last time are no longer shown:

This is true even if I didn’t visit all the new articles.  If I want to see a feed that is not showing up anymore, I just temporarily toggle “Show only updated feeds”:

…and now I can see all the feeds I’ve set up, not just ones with new articles.

The Benefit

Using Sage-Too has enabled me to expand the range of sites I keep in touch with while cutting down the time it takes to do so.  What a help!  I appreciate the work of the Sage and Sage-Too teams to provide this.

Thanks also to Jon Fuller for introducing me to Sage, months ago.  (New ideas take a while to sink in sometimes!)

Maybe sometime I’ll write about how I set up feeds in Sage-Too.

*I took these screenshots this past Monday morning, and many of the sites I follow had updates over the weekend – when checking throughout the week I keep up with them more so there isn’t such a big list of sites with updates all at once.

, ,

1 Comment