July 21, 2008

Tweaks to MySQL installation

After you install one of the MySQL packages available for the Mac, there are some steps that you should do.

First, make sure your MySQL installation knows about time zones. This is important if you want to run your MySQL in the UTC time zone.

To update the mysql database time zone tables, do:

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

Type the password at the prompt (hit enter if you don't have one yet).

And then make sure all your date/datetime fields use the Highlander-timezone. Edit my.cnf and add:

[mysqld]
default-time-zone=utc

Second, make sure your server is using UTF-8 everywhere. Add to my.cnf:

[mysql]
default-character-set=utf8

[mysqld]
character-set-server=utf8

Third, set mysql to strict SQL:

[mysqld]
sql-mode="TRADITIONAL,NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY"

Finally, make sure you use InnoDB by default:

[mysqld]
default-storage-engine=InnoDB

There are probably more tweaks to make your MySQL saner. This are the one I feel comfortable recommending.

DBD::mysql and db_imp errors

I'm installing all my MySQL stuff in a Leopard 10.5.4 desktop and I made some mistakes along the way that I though about documenting here for future reference.

First, although the hardware and OS are 64-bit in a lot of places, the standard perl installed is not one of those. So stick with the i386 MySQL package (or try a 64bit server, but use the 32bit client...). I'm using the Proven Scaling MySQL packages mentioned earlier, and I'm happy so far.

Second, make sure your regular user has all privileges to the test databases. I just do:

melo@DogsHouse:lib $ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 108
Server version: 5.0.62-enterprise-gpl MySQL Enterprise Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> grant all privileges on test.* to 'melo'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

This will make your DBD::mysql tests much happier.

Third, in case you see failing DBD::mysql tests with:

Can't use dbi_imp_data of wrong size (127 not 124) at ...

Upgrade your DBI. I'm now with 1.605 and no dbi_imp_data errors anymore. Clean DBD::mysql install.

$chromatic++

Nothing to add, really. Maybe another day.

QOD

In response to the FSF article on the iPhone, let me point you to the balanced view of Stu Charlton.

Quote of the day:

The OpenMoko counter-argument is "give it time, in the long run, it will win". And look, in a way, I hope so. Using the iPhone is a great case of following Keynes' adage, in the long run, we are all dead., where we optimize for short term gratification at the expense of our future.

July 18, 2008

Creating a new user using dscl

In case you ever need to create a new user in Leopard using the command line, the required steps are documented in the Porting UNIX/Linux Applications to Mac OS X document.

Disqus

Heads up: I'm switching my comments to Disqus. I had several people complaining about the current HaloScan-based system.

Expect minor disturbances in the force.

Update: we are now Disqus-powered. They still don't have an importer for old comments, so for a while, old comments are orphaned. Hope they fix that soon.

Subversion 1.5.0

I missed the release of the new 1.5.0 version of Subversion. Its funny, actually. This was somewhere around June (the blog post lacks a proper date), and I didn't see it mentioned on any of the blogs I follow.

Anyway, its out and I was expecting it to see the new merge tracking stuff. One of my gripes with Subversion is that yes, branching is cheap, but the merge part is awful hard to do and puts much of the load into your lap.

From my superficial first look, all I can say is this: what a mess!

I need to read the documentation more thoroughly but it seems full of special cases and workarounds for common scenarios that should just work.

For example, the "Reflective/Cyclic merges" that are mentioned, are the most common ones for me when I'm using feature branches.

I think this phrase is telling:

The only way to truly solve this is to invent a new merge algorithm in Subversion that does not rely simply on revisions

Of course you can think that branches are not good for you, and that they slow you down. I think its a matter of personal organization. Multiple active branches fit my brain and my workflow just fine, and I love to organize stuff with them.

Trying MarsEdit again

I've tried at least twice now to move from ecto to MarsEdit, but I was having some problems moving my ecto setup from 10.4.x to 10.5.4, so I decided to give it another try.

This time it seems to be working much better. Local Markdown works, and I could define my usual shortcuts easily with the markup editor.

I've still haven't found a way to import all my posts (I want to have the full history locally), so I'll have the check the manual for that one.

In the features-I-would-love-to-see-departement, I haven't found a decent pre-post analysis tool. If I repeatedly link Markdown to http://daringfireball.net/projects/markdown/, my blog tool should suggest the same link in future posts.

A nice tweak to the editor would be smart quoting: if I have a selection active and I type \``,",',*, or_`, it should wrap the selection with that characters.

So for now, I've switched. Let's see how it goes.

July 16, 2008

TechCrunchIT are a bunch of hypocrites

Really, its disgusting how low you can get.

Here we can see Nik Cubrilovic ranting about how close the iPhone is and all the DRM plague that it brings to our world.

Cool, thats nice, and certainly a valid point of view. It's certainly better written than the usual diatribe we get from the Portuguese open source evangelists.

But take a moment to search the TechCrunchIT site for openmoko. You can just click the last word. None. Not a single article. Now try for iPhone. Yep, 9 articles just this month.

search for openmoko - result page

Hypocrites. At least other trolls-for-ad-money don't try to wear the open-source t-shirt.

July 15, 2008

Feed cleanup

I removed all traces of the multiple feeds this site had to just one: http://www.simplicidade.org/notes/42.xml.

I've also added redirects on all of the old feeds to that one, so unless your feed reader cannot read RSS 2.0 it should all work out.

Feed Validator tells me that I have three things to fix at the moment. I'll probably fix two of them (done). The other is content related, and I don't know of a easy fix.

Update: in a effort to improve my ego (any bit counts), I've also started to use FeedBurner services to track usage of the feed. You don't have to change nothing, the official feed URL will always be http://www.simplicidade.org/notes/42.xml.

July 13, 2008

Hell broke loose around here...

The silence around here is caused by a 100% increase on the house population.

Our dog, Ginger, was pregnant and gave birth to 6 new puppies (pictures as soon as I get some power into my phone).

The problem was with the first puppy. It was too big (the father dog was bigger than her, so this puppies are big..) and she was couldn't deliver the puppies on her own. So she had to do a C-section.

It went well, but due to the number of puppies they had to do a lot of incisions. So the uterus was damaged, and they had to remove it. Also the ovaries. So no more puppies.

The other problem is that given that she didn't have them in the usual way, she didn't bond with the puppies. If you think of it, try to imagine awaking up from a drug induced sleep (you know, your regular morning), and having 6 rat-sized tubes of flesh sucking hard on you (ok, maybe that imagine is the wrong one for some of you...).

Anyway, the bottom line is that she is not accepting them as well as she should. And that means work for us.

Our first born waked up like clock work each three hours to eat. This time, we need to awake up each three hours to convince Ginger to let them eat. All six of them. Fortunately she has plenty of milk...

So its crazy time around here, not a lot of time at the computer.

I'll try to catch up next week. There is a lot going on with the iPhone launch, the crazy data plans in PT, the new apps, my new desktop at work, and XMPP stuff.

July 07, 2008

Middle-range Macs

I'm looking for a desktop Mac.

I'm pretty unhappy with the current Apple offering. We have the high-end Mac Pro, starting at 2.499€ (but you can configure a single CPU version for 2.049€, and at the low end, the Mac mini, starting at 499€. In the middle we have the iMac's but those have a built-in screen, and I already have dual 20" Wide displays that I would like to reuse.

I wonder if Apple will ever fill the void between the two head-less versions they have now. I want multiple internal disk-drives (or at least an eSATA connector) because for my main workstation I like to have RAID1, but the only way to get those is a Mac Pro, way to expensive.

There are alternatives, but I would like to avoid the hassle.

July 04, 2008

Lazyweb request: how to find full path to script

Dear Lazyweb,

this is something that I searched for quite some time and could not find yet, maybe a helpful soul knows.

In a bourne shell script, how can I find the full path of the script being executed?

Thanks in advance.

Update: the following command, sent by Celso Pinto, passes all my tests.

SCRIPTDIR="`cd $(dirname $0);pwd`

For the record, I used two scripts to test this. First, the script_dir.sh script:

#!/bin/sh

echo "\$0 is $0"
SCRIPTDIR=`dirname $0`
echo "    dir: $SCRIPTDIR"
SCRIPTDIR="`cd $(dirname $0);pwd`"
echo "    dir: $SCRIPTDIR"

The script to run the tests, run_script_dir_tests.sh:

#!/bin/sh

chmod 755 script_dir.sh

./script_dir.sh 1
../$USER/script_dir.sh 2
../$USER/bin/../script_dir.sh 3

sh ./script_dir.sh 1 with sh
sh ../$USER/script_dir.sh 2 with sh
sh ../$USEr/bin/../script_dir.sh 3 with sh

export PATH=`pwd`:$PATH

cd /
script_dir.sh "via path"

No more bazzilion git-* commands

In case you use the script from the last post, be advised that the current master branch of git.git no longer installs all those git-* on your PATH.

The current git/bin/ contents are:

melo@MrTray:melo $ ls -l /usr/local/git/bin
total 14664
-rwxr-xr-x   89 root  wheel  2826820 Jul  4 10:05 git
-rwxr-xr-x    1 root  wheel   573476 Jul  4 10:05 git-receive-pack
-rwxr-xr-x    1 root  wheel  2826820 Jul  4 10:05 git-upload-archive
-rwxr-xr-x    1 root  wheel   994596 Jul  4 10:05 git-upload-pack
-rwxr-xr-x    1 root  wheel   273636 Jul  4 10:05 gitk

I'm using version v1.5.6.1-204-g6991357. This is not the final 1.6 release (the next one), so you might see further commands added (git-shell might join this list).

At least for me, this required some training because I liked to git-TAB to complete...

x-git-update-to-latest-version

This morning in the git mailing list, I wrote a small shell recipe to update your git to the latest version but keeping the previous ones around, in case something goes wrong.

I noticed that what I wrote was a lot better than the hack-and-slash script I was using, so I promoted a cleaned up version of that to my scripts stash. Hence, you can now download x-git-update-to-latest-version and enjoy painless git updates.

You need to tweak two things at the top of the script:

  • the location on your hard drive of the git.git clone (you need to create that with git clone git://git.kernel.org/pub/scm/git/git.git first);
  • the base directory where all the git versions will live.

You'll end up with something like this (I use /usr/local as my base directory):

melo@MrTray:melo $ ls -dla /usr/local/git*
lrwxr-xr-x   1 root  wheel   25 Jul  4 10:05 /usr/local/git -> git-v1.5.6.1-204-g6991357
drwxr-xr-x   7 root  wheel  238 Jul  4 10:05 /usr/local/git-v1.5.6.1-204-g6991357

Each version will be named git-VERSION where VERSION is the output of git-describe. A symbolic link named git points to the latest version.

Just add BASEDIR/git/bin to your PATH and your are done.