Tuesday, January 30, 2007

Separate user for each webapp's MySQL database

The following commands will create a separate user for each MySQL database.

> GRANT ALL PRIVILEGES ON PureExample.* TO 'pureuser'@'localhost' 

This is good practice when writing web applications, so that each web application has its own database user.

Sunday, January 28, 2007

PDF bookmarks with LaTeX

After the mail fiasco was taken care of, I decided to pursue one of the things I've been wondering about: how to make PDF files have bookmarks (those links on the side pane that let you jump to well-defined sections of the document). For my setup, all I had to do was add this in my document:


Since I use Ubuntu, I had to install the tetex-extras package, which contains hyperref.sty for running pdflatex.

Thursday, January 25, 2007

Thunderbird's "too many connections" message and Courier IMAP

When we use Mozilla Thunderbird at my workplace for our IMAP mail, Thunderbird often tells us that we have too many connections. It makes going through my folders impossible. This article explains that it's because Courier IMAP (which is used by Plesk) limits the number of connections from a single IP address to something like 4. Since we're all behind a firewall, we're all considered to be one user, as far as the server is concerned. I just had to change the values of MAXDAEMONS and MAXPERIP in /etc/courier-imap/imapd to allow more connections. Mozilla Thunderbird caches something like 5 connections by default, so even one user will put the IP past the limit.

While I was figuring my way around this problem, I set up another server to copy my mail over. It's an Ubuntu machine and I just used the distribution's Courier IMAP, but since I've been using UW-IMAP all these years, the configuration process for getting a system user up and running was completely foreign to me.

It turns out all I had to do was run this as that user in the user's home directory:

maildirmake -S Maildir

So now I have a nice little IMAP setup, pretty much out of the box. Some assembly required, apparently. To really understand it, I should do some deeper reading of my source for this command.

One problem with my setup right now with this single command is that it's not yet integrated into the MTA on the system, so that mail can't be delivered into that mailbox, only copied via IMAP in a mail client such as Thunderbird.

Wednesday, January 24, 2007

Iteration produced the Constitution

The other day, I was in a meeting with a potential customer. I explained that when I'm faced with the daunting task of having to build something complicated, I take what's called an iterative approach.

Taking an iterative approach starts with an early phase of exploring the problem by creating a quick, throw-away prototype that works. It gives a sense of what's possible and what's not, and quickly pokes holes in any weak spots in the overall idea.

Sometimes, I think I'm crazy for taking this approach, but it works wonders for me. It helps that people like the folks at 37signals and Fred Brooks have written explanations of the methodology more thoroughly and eloquently than I could possibly write, but I was doubly reassured during my reading lately when I read about how the United States Constitution came about.

In particular, the odd setup of our legislative branch is due to an iterative approach the Founding Fathers took at the Constitutional Convention in 1787. Large states favored a scheme now known as the Virginia Plan, which proposed a two-house legislature where both houses had representatives that were apportioned according to population. The smaller states favored the New Jersey Plan, which proposed a single chamber with one representative from each state.

Now, we look back on the process with our mighty historical hindsight and we look at the Virginia Plan coming from the large states. We might be tempted to think, "Oh, they're just pandering to their own interests. What a crock. That's a terrible scheme to have. How dare they have the audacity to propose something so blatantly self-serving?" The same could be said of the small states.

But what's important is that they tried. They came up with something, put it forth, and asked, "How about this? What do you guys think?" Both the large states and the small states knew that their proposals would have holes poked through them, but they gave it a shot so they could make some progress.

And when this happens, you get something like the Connecticut Compromise, which looked at what everyone thought of the schemes proposed up until then, and said, "Hey, if we go with the Virginia Plan's two houses, we've got some room to work with. What if we make representation in the lower house proportional to population, but give each state equal representation in the upper house, like the New Jersey Plan proposed?"

If even the Founding Fathers had to resort to iteration, I would think it mighty cavalier of me to think I could possibly plan out a complicated system in one fell swoop.

A cheap and nutritious lunch

I remember when I first tried ugali during my trip to Kenya last May. It didn't taste like it had much nutritional value, but it made me full very quickly.

It's been a slow month at the company, so we've been saving some money on food. I have stopped going out to lunch, and instead I go home to my apartment and cook myself some pasta. I treat myself to parmesan cheese on top, but no meat.

The trouble with this is, it has been tough to get full, even after a lot of pasta.

Today I was impatient and ate two bowls of cereal while my pasta was cooking. I ended up having room for only one bowl of pasta, and I was stuffed. Normally, I'd eat four bowls of pasta and still be a little hungry. I guess I accidentally stumbled upon a solution to staying full.

I'm writing this down for my own reference: for cheap eats, have two bowls of cereal and a bowl of pasta.

Tuesday, January 23, 2007

Helping the rich world keep its livelihood

This week's Economist cover story, "Rich man, poor man", about globalisation's winners and losers, offers three categories of solutions to help out those who lose out.

  1. Education in rich countries must equip people with general skills that make them more mobile in the workforce.
  2. Detach health care and pensions from employment, so people who move jobs don't have to worry about much else.
  3. Beef up assistance for those who lose their jobs, in the form of generous training and policies to help them find new work.
These all sound good, but as the editorial acknowledges, these will take years to implement, and it won't be easy. I've also got my own reasons to be skeptical about the effectiveness of these general measures.
  1. People who are part of the educational system in rich countries will see these "general skills" as irrelevant because they want something that's very close to practical. It's difficult to learn something if you're not really interested.
  2. I never really understood the wisdom of tightly coupling health care and pensions to people's jobs, either. Benefits, when tied to jobs, are peripheral concerns, but I suppose it's a temporary hack in the system that just happens to meet the needs of the moment. The thing is, there is no other viable alternative at the moment to this dirty hack.
  3. Greasing up the labour market to make it more mobile is a task I'm very passionate about, but I'm not sure where government or industry can step in effectively. For private concerns, it may not really be profitable. It's an area where I see a lot of room for improvement, but most of the ideas I've got to remedy the problem are more humanitarian than profitable.
It also occurred to me that it may actually be in the rich world's interest to not have job security--or rather, security at the same job. Personally, I have trouble working on the same kind of thing for more than two years, at best, and I am one of the least fickle people I know. It's always best to keep one's options open.