Installing Snow Leopard… with a flashlight

I recently had occasion to install Snow Leopard on an older MacBook Pro. I put in the install DVD and started the process going. After it rebooted, the startup sound played, the Apple logo showed, the activity animation spun around for a bit… then the screen went black. I let it sit for a while, assuming things would happily re-appear. No such luck. The machine was running and sounded active, but nothing ever appeared on the screen.

After some consulting with good friend Google, I gathered that this same behavior was witnessed by a number of people (blog, forums). Older MacBooks upgrading to Snow Leopard sometimes apparently fail to engage the backlight.

Thankfully, there was a lo-tech and amusing workaround: a flashlight!
Continue reading

Share and Enjoy:
  • email
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • Technorati
  • Netvibes
Posted in Apple | Tagged , | Leave a comment

Dealing with “could not create shared memory segment” from postgres on Ubuntu

After installing postgresql-8.4 from the Ubuntu repos on an Ubuntu 9.10 machine, I received the following when the daemon tried to start up:

1
2
3
4
5
6
7
 * The PostgreSQL server failed to start. Please check the log output:
FATAL:  could not create shared memory segment: Invalid argument
DETAIL:  Failed system call was shmget(key=5433001, size=35233792, 03600).
HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter.  You can either reduce the request size or reconfigure the kernel with larger SHMMAX.  To reduce the request size (currently 35233792 bytes), reduce PostgreSQL's shared_buffers parameter (currently 4096) and/or its max_connections parameter (currently 13).
    If the request size is already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising the request size or reconfiguring SHMMIN is called for.
    The PostgreSQL documentation contains more information about shared memory configuration.
[fail]

Fail indeed. Here’s the fix:

1
2
3
4
sudo cp /etc/sysctl.conf /etc/sysctl.conf-orig &&
sudo sh -c 'echo "#\n# For postgres\nkernel.shmmax = 104857600" >> /etc/sysctl.conf' &&
sudo sysctl -p &&
sudo /etc/init.d/postgresql-8.4 start

This increases a particular kernel parameter to allow postgres enough memory to start. Yay for poor defaults…

Share and Enjoy:
  • email
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • Technorati
  • Netvibes
Posted in CLI | Tagged , , , | Leave a comment

Tune MySQL like a pro with MySQLTuner

I don’t know why I didn’t know about this before (or why I forgot about it, more likely), but I came across MySQLTuner recently and was most pleasantly surprised. It’s a Perl script that only requires your MySQL user and password to provide detailed and useful checks of a running MySQL instance. First though, check out the awesome URL you download it at:

1
wget mysqltuner.pl

Yeah, that’s the actual URL that works. Pretty sweet.

Anyway, next you make it executable, run it, enter creds:

Get MySQLTuner running

Then the goodies appear:

MySQLTuner Results

Oh, that query_cache_limit is tiny! At this point, no changes have been made to your setup. But at a glance you get helpful stats, validate that changes you’ve decided to make are in place, and get alerted to potential improvements.

If I knew Perl now and refreshed my MySQL tuning knowledge, I’d love to help as a maintainer of this lovely script. Maybe sometime soon…

Share and Enjoy:
  • email
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • Technorati
  • Netvibes
Posted in MySQL | Tagged , , , | Leave a comment

Converting multiple images to one PDF on Linux

There are a number of ways you can go about the process of converting image files into PDFs, most simply by opening a given image and printing it. You can select “Print to file” instead of a printer device, PDF format is the default for this type of output. But say you have a folder full of images and you want to make one big PDF of them. Here’s how you can do that:

1
2
3
4
5
6
7
cd FOLDER_WITH_IMAGES
FILES=$(ls *jpg)
mkdir temp && cd temp
for file in $FILES; do BASE=$(echo $file | sed 's/.jpg//g'); convert ../$BASE.jpg $BASE.pdf; done &&
pdftk *pdf cat output ../FINAL_NAME.pdf &&
cd ..
rm -rf temp

This loops through all the .jpg images in the directory and converts them to a PDF file of the same name. Once that is done they are all combined into FINAL_NAME.pdf by pdftk, a handy PDF utility. The temp dir business is there to make the temp PDF file removal easier.

Share and Enjoy:
  • email
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • Technorati
  • Netvibes
Posted in CLI | Tagged , , | 2 Comments

git tip: Ignoring modifications to tracked files

Problem

You have a file already tracked in your git repository, but you don’t want future modifications to it to be tracked.

A perfect example of this is the DB config file for Rails projects (config/database.yml). You’ll probably want to track this to keep the production and staging configuration stored and consistent. But it’s quite likely that individual development configurations will be different. Having a commit for each developer adding their own local configuration and thereby polluting it for others when they push is just silly.

Solution

1
git update-index --assume-unchanged FILENAME

The fun details

I had initially thought that git-ignore was the thing to use for this. That was wrong: git-ignore’s purpose is to allow ignoring of untracked files. In the case of the Rails DB conf example above, the file is already tracked. It has the instance information that needs to be shared and now we want to add local development details. Since it’s tracked, any modifications are going to be picked up by git-status. When you do a commit including changes to tracked files listed in .gitignore, the changes do indeed get pushed, which isn’t what we want.

When looking around for solutions to this, I saw “git rm –cached FILENAME” suggested as a way to stop tracking currently tracked files. And it does this, but it also deletes the file in the commit, which isn’t what we want either.

git update-index allows you to alter your staging area more manually than usual. With it you can perform a wide range of operations not otherwise possible through standard commands. Continuing with the Rails DB conf example, here’s what the workflow would look like:

  1. config/database.yml with permanent instance info is added, committed, and pushed
  2. Application code is pulled down by new developer
  3. Local modifications made to database.yml for new developer’s local DB setup
  4. git update-index –assume-unchanged config/database.yml

Thereafter, the changes to conf/database.yml won’t appear in status or get committed. You can continue making and committing other changes, going about business as usual. But any changes to config/database.yml won’t ever appear.

In case you decide you do want to start tracking changes on a file previously ignored, just run:

1
git update-index --no-assume-unchanged FILENAME

Thereafter changes to FILENAME will appear in git-status.

Gotcha

The annoying part about this solution is that it has to be run against every new checkout of the repo with the files whose modifications should not be tracked. The command sets a particular bit per checkout, and it’s not passed on to new checkouts.

Just as I was finishing up some fact checking for this write-up, I came across Jesper Rønn-Jensen’s post on this exact topic. If only it had come up in my initial searches! Here’s hoping the next searcher has better luck.

Share and Enjoy:
  • email
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • Technorati
  • Netvibes
Posted in Programming, RubyOnRails | Tagged , , , | 1 Comment