Thursday, September 22, 2011

iPad/iTunes arrgh

After using an iPad for a few days, the size is nice, there are some neat apps for it, but it feels so restricted. I run Linux for my desktop so I'm used to being to get into just about anything I want. The iPad doesn't even have a Back button. You navigate from one screen to the next the way they want you to do it. If you want to get back to somewhere you were before, either you figure out how to get there using the various buttons provided by the app. That's something you get used to, I guess. I think it's nice to be able to have an easy way to go back to a previous screen if you click the wrong button, or realize that you've gone down the wrong path. But there must be good arguments against the "Back" button.
My biggest gripe is iTunes. Why does everything have to go through it? Just now I wanted to report a problem with an app I purchased, so the email receipt Apple sent me contains a URL that opens iTunes. Why can't they provide a browser interface to my iPad store account? Why, for that matter, can't I report a problem right on the iPad itself? I get frustrated with Microsoft sometimes, but the iPad feels even more controlled. I'm glad I don't have an iPhone...

By the way, is anyone else getting tired of the iProduct naming convention? It's 2011, iThis and iThat sounds so 90s to me, why not thrown an @ symbol in there while you're @ it.

Friday, September 16, 2011

Converting mbox to maildir, the right way

I recently realized that I had made a bad choice in setting up my company's mail server to store emails in mbox format. mbox stores all the emails in one huge file which isn't such a good idea. So I decided to figure out how to convert to maildir.

There are several versions of a perl script called mb2md floating around. As far as I can tell, none of them work. They all seem to have a problem parsing some of the more complex messages from an mbox file and some of the your original messages get split into multiple messages in maildir.

Finally, I found something that works. Its also called mb2md, but it is written in python and, crucially, uses formail or reformail to actually parse the mbox file. In my tests, there were no split messages or other problems I could see. The only problem I found was that the mb2md script itself (luckly bash, not pearl) was missing some parenthesis around filenames in two places which made it not work with folder names containing spaces. Easily fixed, though!

Monday, May 9, 2011

Migrating from mbox to zarafa (or how to break up an mbox file into individual messages)

I'm currently evaluating zarafa for my company's groupware solution.

Currently, the email is served up over IMAP using dovecot.  That works great, but there's no shared calendar or contacts.

One big issue is, of course, how do I migrate the existing emails from our dovecot mbox files into Zarafa's database?

Some googling led me to zarafa-dagentzarafa-dagent is the delivery agent for zarafa.  Pass it a username and an email and it will deliver it to the user's mailbox.  The fedora project page claims that you can pass an entire mbox file to zarafa-dagent on standard input, but that fails with an error message.

So, you need to break the mbox file into individual messages.  Googling for an answer to how to do this led me to mb2md.  Unfortunately, mb2md was confused by some of the messages in the mbox files I need to convert.

Finally, while looking for a version of mb2md that works, I stumbled upon formail, part of procmail.  With this tool, an mbox can be migrated into Zarafa in one step:


cat mbox | formail -s zarafa-dagent username
 

Monday, April 11, 2011

The subtleties of getting a logwatch from a ddwrt router

This doesn't sound too complicated. I have a router running ddwrt and I would like to be able to enable logs on it and produce automated reports from those logs.
I do have a USB thumb drive hooked up to the router, but I was worried about wearing it out writing log files to it.  As it happens, ddwrt's GUI provides a place where you can specify a remote log server.  Perfect.

So, I configured my Fedora box to act as a log server, put the IP address into ddwrt and, surprisingly, it worked right away.  Log messages from the router started popping up in the logfiles on the PC with the router's IP address as the hostname.  It even directed the sshd logs to the /var/log/secure logfile.  Great!

At this point, I thought I was basically done.  But then, I ran logwatch.  logwatch seemed to only show the sshd log entries for the PC, and to be ignoring the router log entries.  I tried the --hostname option and tried setting HostLimit=Yes in logwatch.conf.  They seemed to have no effect.  Finally after 3 or 4 hours of frustration learning more than I ever want to know about logwatch, I figured it out.  A "standard" sshd log entry should be prefixed with sshd[PID], but my ddwrt log entries were prefixed with /opt/sbin/sshd[PID].  Another hour or two and I had the solution:

In /etc/logwatch/conf/override.conf add

services/sshd: *OnlyService = sshd|/opt/bin/sshd
services/sshd: *RemoveHeaders

Friday, February 11, 2011

Latex "List of X"

This is something useful (at least to me) that I figured out how to do after some messing around.

I'm working on a requirements document.  I wanted to have a macro that would automatically number and format all my requirement statements and provide a list of them, similar to the "List of Figure" functionality.

It turns out that the tocloft package does just that.  I also found a nice entry on the LaTeX Matters blog entry on how to do what I want.  Then I decided that I wanted to have more than one type of requirement.  So, I worked out a macro that does it all for you. It looks like this:

\NewListOfType{title}{macroname}{fileext}

title - The title of your list as it should print when you use the \listofX command.

macroname - The name of the macro that you will use to add new list entries.

fileext - The name of the file that's created for your list.  Before I started on this little project I didn't even realize that the table of contents creates a .toc file.

For example:
 
\NewListOfType{List of Functional Requirements}{FR}{frs}
\NewListOfType{List of Non-functional Requirements}{NR}{nrs}

The trickiest part was figuring out how to write a macro that creates another macro.

Here it is:

\makeatletter
% \NewListOfType{Title}{MacroName}{FileExt}
\newcommand{\NewListOfType}[3]{
 \@namedef{title#3}{#1}
 \newlistof{#2}{#3}{\@nameuse{title#3}}
 \@namedef{#2}##1{
  \def\@currentlabelname{##1}
  \refstepcounter{#2}
  \par
  \hangindent=.5in
  \textit{#2.\@nameuse{the#2}\hspace{.1in}} ##1
  \addcontentsline{#3}{#2}{\protect\numberline{#2.\@nameuse{the#2}} {\hspace{.25in} ##1} }
  \par
 }
 \@namedef{cft#3titlefont}{\Large\bfseries}
}
\makeatother

Wednesday, January 19, 2011

Can you make a tart crust from 100% coconut oil?

I am not vegan, but we've had a jar of coconut oil sitting around for a while.  Supposedly, coconut oil can be used as a substitute for butter.  However, I couldn't find a recipe for any type of pastry based on coconut oil in our vast cookbook collection and most of the recipes I found on the Internet cheated by combining coconut oil with butter.

I decided to see what would happen if I took a standard pastry recipe and substituted coconut oil for butter 1-to-1.

I had read several posts about how chilled coconut oil becomes too hard to work with.  I decided to chill it anyway and then combine it with the flour in the food processor, my hope being that the food processor would be powerful enough to chop it into the flour regardless of how hard it became.

It turned out that the coconut oil did get very hard.  I realized that I should have measured it before chilling; it was very difficult and messy to scrape it out of the glass jar and into a measuring cup.  Once I turned on the food processor, though, the oil did combine with the flour.  The consistency was not exactly what I am used to with butter.  I added in the water and eventually ended up with a mound of pastry dough.

The dough was somewhat difficult to work with, maybe I should have added more water, or maybe I should have let the oil warm up a little after taking it out of the fridge.  Eventually I got it rolled out, formed a crust and then baked it for 20 minutes with beans on tin foil to weigh down the middle.  Next I planned to put a glaze and some fruit on it but, for logistical reasons too complex to go into here, the tart shell sat in the fridge for a week before I could finish it.

The finished crust, when I finally tasted it, was pretty good.  Somewhat heavier than I think it would have been with butter and with a slight coconut flavor, but good!

Here are the ingredients:

2 1/2 cups of flour
dash of salt
3/4 cup of coconut oil
1/3 cup of water

dot2tex contd.

Well, dot2tex seems to do small graphs well, but when I tried to take a large dot graph and copy/paste it into my LaTeX document I ran into some problems.  First, some dot color names don't work in LaTeX.  Eventually I figured out that you can add extra color names with the xcolor package:

\usepackage[x11names, svgnames, rgb]{xcolor}

The svgnames option adds color names that match those in dot, except unfortunately have different case.  So, I had to change "lightblue" in my graph to "LightBlue".

The biggest problem, though, was with the output itself.  First the output didn't fit on the page and there's no option to fit it to a particular size.  You can use the lrbox environment to get around that.  Finally, though, the output just doesn't look as good as plain old dot.  Node captions didn't appear to be aligned properly, and the nodes themselves didn't look quite right. 

I concluded that, at least for what I'm doing, running dot as part of a makefile produces better output and is easier than dot2tex.