Archive for September, 2008

Beamer fragile frames

Monday, September 22nd, 2008

If you want to include verbatim text, say for some program code, in a frame in beamer, you have to pass the fragile option to the frame, like so:

\begin{frame}[fragile]
\frametitle{a fragile frame}
\begin{verbatim}
some verbatim text here
\end{verbatim}
\end{frame}

Though latex usually doesn’t really care about whitespace at the beginning of a line, in this case it does. If you don’t have your begin and end frame statements at the beginning of a line when you are trying to use the fragile option, your document will not compile. It’s frustrating.

p.s. also note that you can’t use verbatim text with overlays in beamer.

  • FriendFeed
  • Reddit
  • del.icio.us
  • Digg
  • Slashdot
  • Technorati
  • Facebook
  • Fark
  • TwitThis
  • LinkedIn

Why doesn’t Mac update standard UNIX utilities?

Monday, September 15th, 2008

I am currently teaching a course on programming for linguists. We are using python, but for the first few classes, I have been going over some standard UNIX utilities like cd, ls and such, plus using regular expressions with grep and sed. I actually don’t use sed that much. I tend to reach for perl, since I know it better, and it can do pretty much all the same stuff that sed can plus much more. But sed is simpler than perl, and I basically just wanted to use it for doing substitutions.

Today I got an e-mail from a student asking why the following did not seem to be working:

echo abcd123 | sed 's/\([a-z]*\).*/\U\1/'

The student reported the following output: “Uabcd”. (The expected output is “ABCD”, which is what I get on Linux)

I tried it, and it worked fine for me. Then I thought: maybe this is a Mac/Linux problem. Sure enough, when I look at the man page for my Fedora 7 box, it tells me that my version of sed is GNU 4.1.5, from June 2006. Mac Leopard (10.5) is using BSD sed from July 2004. Leopard came out in 2007, as did Fedora 7. Why is it 2 years behind? Why is it still using python 2.4? Why doesn’t it come with useful utilities like dos2unix? Mac has done a great job of making a nice GUI, with some pretty cool applications like iLife. It is falling behind when it comes to the command line utilities though.

  • FriendFeed
  • Reddit
  • del.icio.us
  • Digg
  • Slashdot
  • Technorati
  • Facebook
  • Fark
  • TwitThis
  • LinkedIn

Collaping categories 0.6.1

Sunday, September 7th, 2008

I just released version 0.6.1. This update is mostly bug fixes introduced in 0.6. I apologize for all the bugs in 0.6. It was a major rewrite, and I expected bugs, but probably should have labeled it alpha. I want to especially thank Hans Klaus for doing quite a bit of testing in 0.6.1, including testing the formatting with several different themes. Here is the changelog for 0.6.1:

  • Improved styling so that collapsing and expanding symbols use a fixed-width font, but category names do not
  • When using the option to have category names trigger expansion, and not showing posts, categories with no subcategories now link to the category
  • Added option to use images instead of html for collapse/expand characters
  • +/- now uses UTF-8 encoding instead of html entities (may not work for pages not encoded in UTF-8

Please post any comments in the Collapsing categories page.

  • FriendFeed
  • Reddit
  • del.icio.us
  • Digg
  • Slashdot
  • Technorati
  • Facebook
  • Fark
  • TwitThis
  • LinkedIn

Perl slurping

Wednesday, September 3rd, 2008

It seems like whenever I go to slurp in a whole file into a string in Perl, I have to search around to remember the exact syntax. So I decided to put it here for myself, so I won’t have to search any further than my own site. In this particular instance, I am trying to remove any <code> blocks from a file. I can simply do the following:

perl -e '$string = do {local( $/ ); <> }; $string=~s/<code>.*?<\/code>//gs; print $string;' < infile > outfile
  • FriendFeed
  • Reddit
  • del.icio.us
  • Digg
  • Slashdot
  • Technorati
  • Facebook
  • Fark
  • TwitThis
  • LinkedIn

Strange bracketing behavior in grep and sed

Wednesday, September 3rd, 2008

I finally figured out this thorny issue I have been dealing with for the last hour. In perl, if I can create a character class like “[\[\]a-f]” which matches any characters a-f, [, and ]. This does not work in grep or sed though. I finally discovered that the right bracket “]” should not be escaped in grep or sed. I don’t really understand why. Perl will let you do it either way.

You know what they say: “knowing is half the battle.”

  • FriendFeed
  • Reddit
  • del.icio.us
  • Digg
  • Slashdot
  • Technorati
  • Facebook
  • Fark
  • TwitThis
  • LinkedIn