Wednesday, March 01, 2006

html form tag without the top/bottom padding

This seems like such a simple thing, but I'm really happy to be able to add it to my collection of useful code snippets:

The important part (HTML code snippet):
<form style="display: inline; margin: 0px;">

Explanation/history/context:
For years, now, I've just accepted (but been annoyed by) the fact that the HTML FORM tag causes some whitespace to display above and below the form contents:

htmlscreenshot
Form outside table:

Text above table
<form>
<table border="1">
  <tr>
    <td>table cell</td>
  </tr>
</table>
</form>
Text below table


One common way of avoiding that whitespace padding is to stick the FORM tag inside a TABLE tag, floating freely without being inside any particular row/cell, like this:
htmlscreenshot
Form inside table:

Text above table
<table border="1">
<form>
  <tr>
    <td>table cell</td>
  </tr>
</form>
</table>
Text below table


I've never bothered to find a better way, until recently, when I decided that I didn't like HTML validators complaining about that. So I searched and found a method of avoiding that whitespace that's simple, seems to work fine in multiple browsers, and passes HTML validation:
html
Form outside table with style:

Text above table
<form style="display: inline; margin: 0px;">
<table border="1">
  <tr>
    <td>table cell</td>
  </tr>
</table>
</form>
Text below table
screenshot

Sunday, February 05, 2006

Removing empty macros from Excel, to avoid popup security dialog

Anyone that's ever dealt with Excel has probably seen this security warning dialog about macros:


It's one thing if the spreadsheet actually has macros in it, especially if it actually *uses* the macros in it. But even if you create a macro, and subsequently delete it, you still get this warning.

I found an Excel FAQ today that included instructions for fixing this. Worked for me!

Friday, February 03, 2006

Finding and un-removing files that I did a 'cvs remove' on yesterday

Last July, I posted a bash shell script called 'cvsrecent.bsh', the purpose of which was "to get a list of CVS revisions and log messages for all checkins within the past (some number) of days."

I've continued to use this script, to this day, but I found a shortcoming this morning that I hadn't noticed before. It doesn't find files that have been removed from your working directory or the repository. I removed some files from my working directory and did 'cvs remove' on them yesterday, and today I decided I need to undo that.

So, I wrote a set of commands to find and check out the last version of all files that were deleted some number of days ago. Here are the components I used:

First, a bash function to get previous revision of a file:
function cvsprev()
{
  cvs -q log $@ |     grep "^revision " |     head -2 |     tail -1 |     cut -f2 -d" "
}


Next, a bash function to get the date for some number of days ago, and format it the way cvs likes it:
function getdaysagodate()
{
  date --date="$1 days ago" +"%Y-%m-%d"
}


Finally, here's the set of commands I used to:

  1. find all the files that CVS put in the "Attic" some number of days ago (in my case, I used 1 (one) since I removed the files yesterday).
  2. for each file:
    1. get the full working-directory path
    2. find the last revision number, before it was removed
    3. do a 'cvs update -r' to check out the last version of the file
for f in  `cvs -Q log -SNd ">=$(getdaysagodate 1)" |  grep -A1 Attic |  sed -e "s/^.*Attic.*$//"    -e "s/^\-\-$//"    -e "s/Working file: //"`; 
do cvs update -r `cvsprev $f` $f; 
done


Another command could be added to check those files back into CVS automatically, but I wasn't 100% certain that I wanted to check all of them back in. I mainly just wanted to find them, and look at them. Maybe sometime I'll update the cvsrecent.bsh script, so it can handle files that have been removed. At least I'm half-way there after having written these commands today.