Sunday, November 30, 2008

Firefox Radio Button Alignment

I have been doing a bit of front end work on a web site and while I am still developing ideas I have been viewing my results in Safari because that it allows me to use cool CSS 3 effects like -webkit-box-shadow and -webkit-border-radius for rounded corners. This is great for design mock ups because it is so much quicker than creating bitmaps and then maybe deciding not to use them.

I can see that WebKit also has a lot more install for Safari users with gradients, masks and more. But my current version of Safari does not include these features yet.

But then I noticed that when I looked at my page on FireFox all the radio buttons seemed out of alignment and looked very messy. I wasted hours trying to figure out if my style sheet was the culprit. Then I noticed that even Google looked weird so it was not something I was doing to mess up the formatting:

Safari:




Internet Explorer:




Firefox:






Notice how the radio buttons seem to float above the text.

After a bit of experimenting with various alignment options I found that setting vertical-align: text-top made the alignment look OK in Safari and Firefox but terrible in IE.

For now I have given up on Firefox and just accept that its looks a bit shit.

Thursday, November 20, 2008

Copying music off an iPod

My external hard drive broke taking with it my iTunes library. All my music is also on my 80GB iPod but iTunes annoyingly does not let you copy music from your iPod back to your computer. I guess it was one of the conditions Apple negotiated with the record companies when setting up the iTunes store.

When my iPod is connected to my Mac Mini it shows in the Finder as an external hard drive but the music folder is hidden. From the command line


john@mini:~$ ll /Volumes/John\ Patterson’s\ iPod/
total 64
drwxr-xr-x 4 john staff 136B 30 May 19:55 Backup
drwxr-xr-x 2 john staff 68B 1 Jan 2000 Calendars
drwxr-xr-x 2 john staff 68B 1 Jan 2000 Contacts
-rw-r--r--@ 1 john staff 1.0K 16 Dec 2007 Desktop DB
-rw-r--r--@ 1 john staff 2B 16 Dec 2007 Desktop DF
drwxr-xr-x 3 john staff 102B 1 Jan 2000 Notes
drwxr-xr-x 6 john staff 204B 18 May 2008 Photos
drwxr-xr-x 2 john staff 68B 1 Jan 2000 Recordings
drwxr-xr-x@ 11 john staff 374B 16 Dec 2007 iPod_Control

Now we can see the iPod_Control directory that contains all the music
Simply copy the music onto your local disc:

john@mini:~$ cp -r /Volumes/John\ Patterson’s\ iPod/iPod_Control/Music/ /Volumes/External/Music/iPod


The folders are still hidden so you need to remove the hidden attribute like this

xattr -d com.apple.FinderInfo /Volumes/External/Music/iPod/F*


And when that is done drag the whole folder onto your iTunes icon and all the music files will be imported into your current library. If you have iTunes set up to keep your music folders organised it will rename the cryptically named music files and create correctly named folders for you. Neat.

Thursday, November 13, 2008

Watching BBC online overseas

I need to watch the All Black playing Ireland on Sunday but here in Spain I have no idea where to watch the game with English commentary. BBC makes a lot of video content available on their website but only if you are in the UK.

I have servers running in the UK and knew it must be possible to somehow use them as a proxy so that the British Broadcasting Commissioners think that I too am in old Blighty. But how to hook it all up?

After a bit of Googling on the interweb I discovered that OpenSSH can be used as a SOCKS proxy which creates a secure connection to any server you can ssh into and then fires off your requests from there. OpenSSH is the flavour of SSH that runs on Mac OS X so all I had to do was type this at the terminal to start the proxy:

ssh -ND 9999 myserver.co.uk

The -N just tells ssh that I don't want to send any commands - just set up the proxy and listen on local port 9999.

Then you need to tell your browser to use the SOCKS proxy. Safari proxy settings are just the system wide network preferences. Just click on advanced and then Proxies and add a SOCKS proxy at localhost port 9999 and voila!. But I don't want all my browsing to use the proxy - most sites should connect directly.

So I installed the handy little FireFox plugin, FoxyProxy, which can selectively send some requests through the proxy and not others. It looks pretty flexible but I simply set it to use my proxy for all URL's and then used Safari as normal for direct browsing.

Now I can watch Top Gear on BBC too! And also, when I look at my website which has advertising including Google AdSense and Yahoo PPC ads I can see the same ads that users of my site in the UK see!

Nice.

Tuesday, November 4, 2008

Filtering resources in Eclipse

When you have a lot of files in an Eclipse 3.4 workspace things pretty much grind to a halt. I have a folder containing 200,000 images for a web project I'm working on and I need to include in the workspace. Starting Eclipse with this folder takes forever and Subversive hangs trying to to something with all the files.

I filed a bug report on this issue 3 years ago! https://bugs.eclipse.org/bugs/show_bug.cgi?id=84988. Eclipse development seems to move slowly.

I can exclude files from the Package Explore using a filter but the problem remains. Under the covers Eclipse is still monitoring these files at the resource level.

I found this plugin which claims to do what I want but I could not get it to work for me.

https://sourceforge.net/projects/eclipseresfltr/

Some people have posted about adding a "resource filter" to filter out files at a lower level
In the Resource Navigator (Window -> Show View -> Navigator) you can choose to filter resources that match .* or *.class but you cannot add your own filters. These default ones are added by plugins as extension points.

But you can add your own filters by messing with an existing Plugin and adding a filter definition to its plugin.xml. Just find a plugin that is not in a jar file - they are signed so you cannot alter their contents. I chose the jdt plugin org.eclipse.jdt.debug_3.4.0.v20080604 and added this to its plugin.xml

<extension point="org.eclipse.ui.ide.resourceFilters">
<filter selected="false" pattern="my-large-folder"></filter>
</extension>

However, this does NOT stop the resources from being scanned for updates for some reason. It just hides the folder from view but my machine was still pegged on close to 100% CPU.

Then I re-read one of the comments on my bug report above and finally solved the problem.
  1. Move the large folder outside your workspace.
  2. In the Package Explorer New -> File
  3. Enter the name of the large folder as the filename
  4. Click Advanced and check "Link to file in the filesystem"
  5. Enter /dev/null (on Mac OS X) and click finish
  6. Move the large folder back to your workspace.
Now the null file hides your folder. I also added a filter to the Package Exploer so the linked null file does not show. Now when I refresh the workspace or restart my machine no longer hangs. Nice one.