Get database size in phpMyAdmin

It looks like phpMyAdmin doesn’t include a way to see how much space takes the MySQL database. I found that a bit weird, but hey, if phpMyAdmin doesn’t do it, let’s cut to the chase and go SQL!

The most straightforward way to get your database size from phpMyAdmin is the following SQL query:

SELECT table_schema "Data Base Name",
sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES GROUP BY table_schema ;

Originally from the MySQL forums.

Changing an application icon under OS X

I don’t like the default icon for Preview.app in OS X.

The sight of that child, giving me this creepy grin, sitting here in the Dock while I’m browsing pictures, is just weird.

Icon for preview.app
Seriously!

There are two ways to make him go away.

The hard way

I call this method the hard way because it involves having another .icns file (the filetype for OS X icons), and navigating through folders supposed to be hidden. But it doesn’t matter, you’re a hardcore user!

Right-click Preview.app and click “Show Package Contents”.
Navigate to Contents/Resources.
Replace Preview.icns with the icon of your choice.

The easy way

This method allows you to replace an icon with another application’s icon.

Open the information panel of said other application (Cmd+i in the Finder).
Click on the big icon at top-left (not the one in the menu bar).
It will appear highlighted:
The information panel with an highlighted icon

Enter Cmd+c to copy it.

Open Preview.app’s information panel.
Click on the icon:
Preview.app's information panel before changing the icon
Enter Cmd+v.

Voilà!
Preview.app's information panel after changing the icon

Another advantage of this second method is that it also works for disks, folders, and about any file.

You can find a lot of great icons at InterfaceLift (though it doesn’t seem to be updated very often). The icon I used to replace the child is part of the Aqua Neue set.

Put OS X to sleep via command-line

When connecting to an OS X box via SSH, you may want to put it to sleep after you’re done.

This is no system call to put the computer to sleep that I know of. However, Applescript can do it, and it is trivial to call the OSAScript interpreter in bash.

The following script puts the computer to sleep:

#!/bin/bash

osascript -e 'tell application "System Events" to sleep'

Edit: found a better way!

I don’t know if this is specific to Snow Leopard, but the following command will work as well without having to use Applescript or administrator rights:

pmset sleepnow

On designing mockups

As part of a group project, I am currently involved in designing an application from the ground up. Designing the UI first drafts, before even chosing a programming language or environment, is something that should be easy and straightforward. We needed a tool that allows easy sharing between people, regardless of operating system.

Please welcome Mockingbird.

An amazing web application to design sleek and elegant UIs, Mockingbird is Javascript-based (no Flash!) and especially powerful if you’re working as part of a team or if you share a lot of mockups. Try it!

Screenshots and OS X: capturing a single window

One pretty awesomely simple thing under Mac OS is making great screenshots.

You might already be familiar with Mac OS X’s classical shortcuts for screenshots, Shift+Cmd+3 (full screen) and Shift+Cmd+4 (selection). But did you know you can shoot a single window without the hassle of selecting it from edge to edge, or worse, cropping from a full screenshot?

Press Shift+Cmd+4, then press the space bar.

A little camera appears, and allows you to capture the highlighted window of your choice.

The resulting image can be found at the same place as usual screenshots – by default, on the desktop, as a PNG file. With transparency and drop shadows, nothing less!

NB: apart from “real windows”, this camera can also capture the Dock, the menu bar, the desktop wallpaper, and even widgets.