Wednesday, February 20, 2008

OpenOffice.org 2.3.1 and FreeBSD

So, it turns out that OpenOffice.org 2.3.1 on FreeBSD was behaving oddly (not opening documents) due to a missing environment variable. This seems like a bug to me that will be fixed sooner or later. Regardless, normal OpenOffice.org functionality may be returned by setting the following:

OOO_FORCE_DESKTOP=gnome

References:
lucky.freebsd.ports
freebsd-openoffice mailing list archive at nabble.com

Friday, February 8, 2008

My Destroyed Faith in OpenOffice Presentations

So, I'm working on a presentation for work. I can't bring myself to use PowerPoint, since Microsoft has done such a good job of ruining my software self-esteem. I think to myself, "Well, why not OpenOffice.org Impress? It uses the OpenDocument Format, which is damn fine computing karma." So, I made my first draft in OOo 2.3.1 on Win32. Then, I attempt to continue working on the same ODP file on OOo 2.3.1 on FreeBSD. It seemingly hangs. No progress after minutes of processing. Fucking great. Running it from an xterm gives me these messages (no idea if they're related):

(process:1152): GLib-GObject-CRITICAL **: gtype.c:2242: initialization assertion failed, use IA__g_type_init() prior to this function

(process:1152): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:1152): GLib-GObject-CRITICAL **: g_object_new: assertion `G_TYPE_IS_OBJECT (object_type)' failed
That doesn't look good. I'm going to let it keep running for a while to see if things improve, but the outlook is poor. In the meantime, I've decided that the best alternative to multi-platform document creation and editing is Google Docs. It's not perfect, but at least you can save your files as PDF, which is what I use for read-only document exchange anyway.

Since I don't have a Microsoft Windows computer at my disposal, I have to figure out someway to get at least the text portion out of my ODP. This is my half-baked solution for extracting the text:
  1. $ mkdir presentation
  2. $ cd presentation
  3. $ cp ~/path_to_presentation/my_presentation.odp .
  4. $ unzip my_presentation.odp
  5. $ extract_odp_text.py > my_presentation.txt


#!/usr/bin/env python2.5
# extract_odp_text.py -- extract the text parts from an ODP's content.xml
import re
for line in open('content.xml', 'r')
for text_part in re.findall(r'<text:p.*?>(.*?)</text.*?>', line):
print text_part.replace('<text:line-break/>', '')

Wednesday, February 6, 2008

Ecplise 3.3 Exploded My Face

So, Eclipse + PyDev seems to be the premier way to visually debug python apps. The first time you debug your application, you have to choose the debug configuration you want to use, Python or Jython or some others. Anyway, after you make your selection once, you can hit "F11" to debug your last launched. Or at least that's how it used to work.

In Eclipse 3.3, you have to check a special configuration option to get the old behavior. That way you don't have to needlessly click the same debugging configuration each time. The PyDev documentation clued me in to this.

From http://www.fabioz.com/pydev/manual_101_run.html
Note: This behavior changed in Eclipse 3.3 -- but it's generally recommended to restore it in the preferences at: window > preferences > Run/Debug > Launching and set the Launch Operation to Always launch the previously launched application. This tutorial will always consider this as the default option.
After that, F11 rocks your world.

Tuesday, February 5, 2008

GVIM ♥ Python

When I'm not using UNIX, I'm not. To try and make things a little more tolerable, I use GVIM as much as possible. Unfortunately, the win32 GVIM release expects Python 2.4 if you want to use the amazing omnicomplete Python functions. I hit the wall today and broke down in tears, knowing that I had Python 2.5.1, but a GVIM that didn't use that.

The solution was to compile a GVIM executable myself! It turns out that it is fairly easy. I also assume that Vim is already installed.
  1. Download the source archives.
    1. ftp://ftp.vim.org/pub/vim/unix/vim-7.1.tar.bz2
    2. ftp://ftp.vim.org/pub/vim/extra/vim-7.1-extra.tar.gz
  2. Extract
  3. CD vim71\src
  4. "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"
  5. nmake -f Make_mvc.mak FEATURES=HUGE GUI=yes OLE=yes MBYTE=yes IME=yes GIME=yes PYTHON=C:\Python25 DYNAMIC_PYTHON=yes PYTHON_VER=25 CSCOPE=yes
  6. Make sure the regular Vim 7.1 is installed. I used the installer located at ftp://ftp.vim.org/pub/vim/pc/gvim71.exe
  7. COPY /Y gvim.exe "C:\Program Files\Vim\vim71\gvim.exe"
  8. COPY /Y GvimExt\gvimext.dll "C:\Program Files\Vim\vim71\gvimext.dll"
  9. Turn up your Ashlee Simpson CD
That seems to be it. I didn't add support for TCL, Perl, or XPMs, but you're a smart kid. You can figure it out.

I Threw My MBR Off The Deck

When installing FreeBSD, it gives you the option to install the FreeBSD boot manager or a standard MBR. Since I only have one operating system on my hard drive, a standard MBR will boot right into FreeBSD.

Well, instead of doing the right thing, I did the wrong thing and installed the FreeBSD boot manager, also known as boot0. Luckily, UNIX is amazing and gives you the option to fix things. A quick look at boot0cfg(8) (which means type 'man 8 boot0cfg'), and you can see that the fix is:
  • fdisk -B ad0


The -B option to fdisk means, "Reinitialize the boot code contained in sector 0 of the disk." In FreeBSD, your devices are referred to by the kernel module/driver they use. "ad" is the "generic ATA/ATAPI disk controller driver" and 0 is the number of the first ATA/ATAPI disk (zero-indexed, of course). You might have a different disk. Adjust that last argument as necessary.

Friday, February 1, 2008

X Windows and Unicode

X Windows does seem to support Unicode input. For learning a foreign language, often times an accent mark is put over a letter to indicate syllable stress (lookup diacritical marks if you're interested in more). Anyway, to put an accent over a vowel, placing U+301 after the vowel in question will place the accent mark.

  • In regular X Windows
    • I've bound it to an unused key. First, add 0x100000 to the Unicode code point in question, then bind that value to a keycode.
    • xmodmap -e 'keycode 117 = 0x1000301'
  • In GNOME
    • Hold CTRL + SHIFT, then press 3, then 0, then 1, then release
  • In gVim
    • CTRL + V, u, 0, 3, 0, 1