Thursday, December 4, 2008

Cleaning up your computer to give away

While cleaning up the house, I came up across two old computers that I really don't want. One of them is old enough to recycle, the other one I'll give away for charity. Eitherway, I want the hard-drives to be clean before they leave the house. Not that I have any sensitive stuff on them, but there's probably enough info for some identity theft.

Fortunately, a while ago I came across this tool: Darik's Boot and Nuke. This is basically an image file you download and burn on a CD. You boot the computer you want to recycle/give away/sell with the CD and it just wipes all your hard drives.

I used it with both computers and it worked perfectly. Now I can give them away without concern.

Oh, using this software had an unexpected bonus! Because I had to open the CD drive, it stopped me from sending the computer away with a backup CD in it!

Sunday, September 28, 2008

Setting up Cake on a custom folder

I wanted to try the PHP framework Cake, but if you look at the documentation it assumes you want to install Cake under the /var/www/html folder.

You can obviously install to other folders, but if not done properly, you'll encounter a start page with no images, no styles, and some error messages.

The steps I took to make Cake work in my folder (/home/me/dev/myapp) and to work with the http://localhost/myapp URL where:

  1. Uncompress the latest version of Cake to /home/me/dev/myapp
  2. Edit my /etc/apache2/users/me.conf and add the following (replace braces with chevrons):
    Alias /myapp/ "/home/me/dev/myapp/"
    {Directory "/home/me/dev/myapp/"}
    AllowOverride All
    Order allow,deny
    Allow from all
    {/Directory}
  3. Edit the .htaccess file in your /home/me/dev/myapp folder and add RewriteBase /myapp/ to it. Should look something like (replace braces with chevrons):
    {IfModule mod_rewrite.c}
    RewriteEngine on
    RewriteBase /myapp/
    RewriteRule ^$ app/webroot/ [L]
    RewriteRule (.*) app/webroot/$1 [L]
    {/IfModule}
  4. Make sure your /home/me/dev/myapp/app/tmp folder is writable by all
  5. Restart apache

And that's it. After these steps you should be able to access your application and see the default Cake page, including images & CSS.

Saturday, September 13, 2008

Mighty Mouse design flaw

I bought a Mighty Mouse from Apple. I wanted a wireless mouse for my computer, and the Mighty Mouse seemed like the perfect choice for my Mac.

The mouse is beautiful, the buttons work pretty well and the scroll ball is great! But the mouse has a rather annoying design flaw:

You cannot lift the mouse while clicking!

Here's the problem: The mouse detects the button is pressed because you press the body of the mouse against the base of the mouse. When you lift the mouse, there's no longer pressure between the body and the base of the mouse. So our mighty mouse assumes you're no longer pressing the button.

There's somewhat of a work around for this... If you squeeze the mouse, the base does not drop and you can lift the mouse. But since squeezing the mouse brings up Exposé, things can get pretty weird...

This can be a real pain when you're trying to drag files from an end of the screen to another, or when you're trying to make a huge selection... it is one of those design vs. function options that I'm still not sure if Apple's done the right choice.

Thursday, August 14, 2008

Hello world in Cocoa-Ruby

Here's a short video on how to do a "hello world" application in Cocoa-Ruby.




This was based on this japanese video I found on the web.

Thursday, July 3, 2008

Killing programs on Windows shutdown

My Windows computer at the office takes quite some time to restart... so, whenever there's an update or such that requires a restart, I wait for a moment that I'm away from the computer to do so. Turns out that it's not that unusual to return to a dialog box stating that some program has failed to exit with a button to "click to end".

Fortunately there's a workaround for this not so smart behavior. Start regedit (*sigh*), go to HKEY_CURRENT_USER\Control Panel\Desktop and alter the key AutoEndTasks to the value 1.

PS: I'm not really sure if this works, because I'm always away when my computer reboots... but I haven't seen that message again!

Tuesday, June 10, 2008

PHP on the Mac

If you have a Mac with Leopard and want to use PHP, most of what you need is already installed. It's just a matter of making it work.

First you need to turn on apache. Just go to your "System Preferences", "Sharing" and turn on "Web Sharing". That's it, apache is running. You can check if all is ok by going to http://localhost.

You'll probably want MySql too. Just go to their site, download and install. No big fuss, but make sure you install the StartupItem if you want MySql to start when the system boots.

Next you must enable PHP. Launch a terminal and use your favorite text editor to edit /etc/apache2/httpd.conf. Look for LoadModule php5_module and uncomment the line. Restart apache with sudo apachectl graceful.

Now let's say your username is john, and you have on your home folder a ~/dev/phpproj where your php code is. One way to make this available (and there's lots of others) is to edit /etc/apache2/users/john.conf and add the following to the bottom of the file (replace [ with "lesser than" and ] with "greater than". Blogger doesn't like those symbols):
Alias /phpproj/ "/Users/john/dev/phpproj/"
[Directory "/Users/john/dev/phpproj/"]
Options Indexes MultiViews
Order allow,deny
Allow from all
[/Directory]
Now you can access http://localhost/phpproj/ to view your app.

At this point you might get a MySql error stating that you /var/mysql/mysql.sock does not exist, just go back to your terminal window and type:

cd /var
sudo mkdir mysql
cd mysql
sudo ln -s /private/tmp/mysql.sock mysql.sock

That's it!

I bought a Mac!

About a year ago I wrote some reasons why I wasn't buying a Mac. Well, a year has come and gone an I bought a Mac! And so far, I'm very happy with it!

I could go on forever about what's so great about my Mac, how cool it is just to unpack it, how beautiful the hardware and software are, and all that. But you can read about a million posts on the web about that, so I won't bother.

Instead I'm going to focus on the parts that aren't so good. This way people switching from Ubuntu to Mac will know what to expect.
  1. You have to pay for the software: Oh yeah, most software is closed source and payed for. I really miss doing apt-get and it just works, no payment, no registration...
  2. The keyboard is... different: I have a portuguese keyboard. The Mac doesn't have a } anywhere visible on the keyboard! It took me a while to figure I had to type --9
  3. X11 compatible... kind of: You can run X apps on the Mac. I installed Gimp, and it works. But the UI is a bit clumsy... For starters, the keyboard shortcuts aren't the same for X and Mac (e.g. in Mac you copy with -c, in X with -c). Second, the windows interaction is awkward. In "X mode" you have to click the window to get the focus, then click the button on the window to make it work. Since the Gimp has multiple windows, this is very annoying.
  4. No out of the box NTFS write support: C'mon! I have an external 500Gb HD formatted in NTFS! I had to install MacFUSE from google to make it work!
  5. Only 2 USB ports: Good thing I have a hub!
  6. Strange video output: It has a mini-DVI. Never seen one before. Oh well, I don't have another monitor, so it's not a big problem.
And I can't remember anything else... but I only have the laptop for 4 days!

Don't get me wrong, I love my Mac! But, like all things, it has some downsides. And the biggest one AFAIK is the non-open nature of this platform. Still, if I was going shopping again today, I would still buy the Mac!

Saturday, May 3, 2008

Reso. not supported

I bought a 500Gb Iomega Screenplay HD. I needed some place to backup my photos, and since I don't like watching long videos sitting at the computer, I figured a multimedia drive was the way to go.

I tried it out with a bunch of videos and it seems to work pretty good. It supports enough formats, it has support for subtitles, and it lets me see my photos (though it is a bit slow showing pictures).

Then I tried another video that I really wanted to watch, and I got this error:
Reso. not supported
I must confess it took me a bit to understand that it meant "Resolution not supported"! After I got finally got that, the solution was obvious! Change the resolution of the video.

To do that I used Avidemux. It is very easy to use and has these "Auto" configurations that basically do exactly what you want. All I had to do was open the video, select "Auto/DVD", configure to do a single pass (double pass is the default, but it takes twice as long to convert), and wait. Now I can see the video on my multimedia drive!

Thursday, May 1, 2008

Problems with Picasa 2 in Ubuntu

I've upgraded my Ubuntu installation to Hardy Heron.

I had some new photos to check, so after installing the system the 1st thing I did was get Picasa. I ran the software, it started scanning my hard drive, and it just didn't go past the 5th photo folder on my hard drive (I've got about 400 photo folders).

I immediately cursed the new Ubuntu release, because after my upgrade to Gutsy Gibbon I also had problems with Picasa.... but turns out that this time the problem wasn't in Ubuntu, it was in Picasa.

The symptoms of the problem are:
  • Hard disk always on
  • Computer stand still... even the mouse moves slow
  • No matter how long you wait (I left the computer working over night) nothing happens
The solution is a bit drastic, but it works. Basically Picasa is generating huge invalid Picasa.ini files, and those are messing the system. All you have to do is delete the invalid files. One easy way to spot them is by their size:

find . -size +512 -name Picasa.ini

To make Picasa get back on track, just delete them. You can use xargs to do this:

find . -size +512 -name Picasa.ini | xargs rm


or (if you have directory names with strange characters):

find . -size +512 -name Picasa.ini -print0 | xargs -0 rm

Note that this will not destroy any of your photos, but it will destroy any changes you made to the photos in Picasa, like crops, tunnings, ...

Tuesday, April 1, 2008

Registry entry for Java Preferences

Java Preferences in Windows are stored in the registry entry:

HKLM\Software\Javasoft\Prefs\

and

HKCU\Software\Javasoft\Prefs\

There, now I don't have to dig this information on the net again!

Monday, February 18, 2008

Creating an SVN repositoy

I do a bunch of personal projects and, in the spirit of keeping it all under source control, I always create an SVN repository for all of them (even if I don’t finish them… after all, I suffer from NADD). Because I like to automate everything, here’s the script I use to startup projects:

#!/bin/sh
TMPDIR=/tmp/svntmpdir
REPODIR=/home/rsc/Documents/repositories
REPOURL=file://$REPODIR

if [ $1 == ""] ; then
    echo Usage: $0 {repository name}
    exit 1
fi

echo Creating directory structure
echo $TMPDIR
mkdir $TMPDIR
mkdir $TMPDIR/trunk
mkdir $TMPDIR/branches
mkdir $TMPDIR/tags
echo Creating repository $1
svnadmin create $REPODIR/$1
cd $TMPDIR
svn import $REPOURL/$1 -m "Initial structure"
echo Checking out
cd -
svn co $REPOURL/$1/trunk $1
echo Cleaning up
rm -Rf $TMPDIR
echo Done!