Monday, September 28, 2009

Controlling PDF Minor Version in LaTeX

I just had to submit a paper to a conference that was using some web based submission system. As part of that system, the PDF version of the paper I submitted was validated. The system refused my paper because it was seemingly a version 1.4 PDF (w.t.f. do I know about PDF versions?). I spent some time trying to update my LaTeX installation on my Mac (didn't work), compiling the paper on my university's Linux machines (also didn't work), and then I hit Google...

It seems that you can control the PDF minor version by using this magical LaTeX command
\pdfminorversion=5
This will make pdflatex create a version 1.5 PDF document (you can also create version 1.6 and 1.7 PDFs, but 1.5 was all I needed).

Friday, September 18, 2009

Native Mac PyGTK for Snow Leopard

I have just made a fresh build of native PyGTK for Mac on my new Snow Leopard install. It seems to be working - I have only tested my simple hello_pygtk.py script, and that works at least ;-)

You can grab the new build here: MacPyGTK_SnowLeopard_091809.dmg

Remember to follow the three simple instructions in README.txt in order to make it work. B.t.w., one has to be running Python in 32-bit mode for it to work. This can be done in two ways:
  1. By setting this environment variable VERSIONER_PYTHON_PREFER_32_BIT=yes
  2. By issuing this command (once): defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
I would prefer setting the environment variable in a script starting my PyGTK application. That way I am changing as little as possible in the standard setup of the machine...

Thursday, September 17, 2009

Piping output of shell commands into the clipboard

I love my terminal! The availability of a proper shell and set of *nix tools is one of the main reasons that I dared switch to Mac OS X two years ago. I have been used to having the full GNU tool chain on the Linux systems I have been using the last 10 years, and there is no way I will ever give that up :-)

Today I learned something new about my terminal on OS X; I learned about the pbcopy and pbpaste commands. These two shell commands copy shell output into the clipboard, and pastes the clipboard content into the shell, respectively. I.e., today I needed to grep+cut through some large log files, and the results of these commands I wanted to paste to a spreadsheet. Instead of having to 1) perform the command, and then 2) use the mouse to scroll up and select all of the results to copy-paste them into the spreadsheet, I found that I could use pbcopy to pipe stdout directly to the clipboard:
grep foo logfile.txt | cut -d " " -f1,2,4 | pbcopy
After running this I could just go to my spreadsheet application and insert the three selected rows.

This little command is a real time saver I can tell you! I must have saved at least an hours work today alone ;-)

Sunday, September 13, 2009

Fresh PyGTK build for Leopard/Intel

I have just built a fresh version of native Mac OS X PyGTK and all of its dependencies. This time I have only made an Intel build for Leopard, so no PPC version this time around.

You can grab the new dmg file here: MacPyGTK_Leopard_Intel_091309.dmg

The install procedure is the usual:
  1. Download and mount the dmg
  2. Drag the MacPyGTK folder to /Developer
  3. Copy the contents of site-packages into the site packages of your Python installation (on 10.5 this should be /Library/Python/2.5/site-packages)
  4. Test that it works by running the hello_pygtk.py file with your Python interpreter.
That's it - now you should have a fully functional PyGTK installation to play around with.