Better icon for XAMPP

I recently set XAMPP up on my mac (get it here). It’s an easy to setup and flexible web server environment. The best part is you don’t need to have it running all the time – just fire up the XAMPP control panel whenever you need to do some localised development (ie. when you’re on the train or out of range of wifi) and start the relevant servers. It’s a one-click install and lets you flip between php 4 and 5 at the click of a radio button. Sweet!

The only thing is – call me a snob – the dock icon for the control panel is rubbish – it’s pale and faded, and a bit meaningless looking…
See for yourself

Old XAMPP dock icon

I had a peek around the net and there’s some much better logo images for XAMPP but not available as a replacement icon file. So I grabbed one and made my own. Here it is in action:

Updated XAMPP dock icon

OK it’s not perfect – the anti-aliasing at the top is a bit hooky but at least it’s a bit more presentable.

Here’s how to set it up:

  1. First download the xampp.icns.zip file from here
  2. Unzip it
  3. furniture Bulgaria

  4. Open Finder and browse to ‘Applications>XAMPP’
  5. CTRL-click the XAMPP Control Panel application and select ‘Show Package Contents’
  6. Browse to ‘Contents>Resources’
  7. drop the xampp.icns file into this folder
  8. then copy it and replace ‘xcp.icns’ with it

That’s it. Job done and nice shiny more XAMPP like icon on your dock

Photoshop CS3 / Dell Monitor colour profiling issue (Mac OSX)

my good friend Dan has been exploring the quirkier side of Photoshop CS3 recently. It seems that when he hooked up his shiny new Dell monitor to his MacPro that it reset the CS3 Colour space to a Dell RGB one... that then forces all images and colours to be converted when they are saved out for web. Here's the lowdown:

The problem I was having with PS CS3 web export was to do with the color profiling set up.

The Dell monitor(s) installed automatically impose a Dell RGB color space on PS leading to a color shift when you go to 'save for web'. This is because the default profile (Dell) is automatically converted to sRGB when you select 'Save for web/devices'. The shift in tone, gamma and saturation levels means that the colours become lighter and quite obviously different to the original.

To ensure this doesn't happen (and that your colours are correct when they are exported out as GIFs, JPEGs and PNGs etc.) go to:

1) Edit > Colour Settings

2) Change your RGB space to 'sRGB IEC61966-2.1'

This seems to fix the issue that I was experiencing and sets a precedent for future set ups.

Host spoofing in Mac OS X

This is a handy way to test sites that are in the process of being moved from one domain to another, or even to create your own "invisible" internet.
Normally when a user requests something from a web-based domain, their computer will connect to a Domain Name Server (DNS) and request the correct IP address for that domain. As you can see for everything that is requested on a web site you will have at least one and possibly two net requests (one for the domain translation to ip and one for the asset itself) taking place. This can slow the whole process down.

What you can do is log a set of special domains (frequently used, personal, etc) in your /etc/hosts file. This is a kind of static file DNS server if you like. This is always consulted first and you can in fact use this technique to override any web address. By creating a web site that responds to requests on a certain domain (even if it's not registered to that server) and by "spoofing the host," you can create extremely secret / secure web servers as they have no visible presence on the internet, except to those users who have manually set their host files up.

We'll be using vim which is a slightly nicer version of vi the linux/unix text editor. It's a little unwieldy at first - all keyboard commands and odd-shortcuts but it's a doddle to use once you're comfortable with it.

Anyway, here's how to do it:

1. open Terminal

2. type

sudo vim /private/etc/hosts

3. press I (for Insert)

4. scroll to the bottom

5. hit return to enter a space

6. type the following line

# TEMPORARY SPOOFED IP FOR TESTING

7. hit return to enter a space

8. type the following line

123.456.789.101 www.example_domain.com

where the ip address and the example domain are those that you wish to use

9. hit return to enter another blank line

it should look like this

# SPOOFED HOST
123.456.789.101 www.example_domain.com

10. hit escape

11. type

!wq

to save the file

¡IMPORTANT! You will have to re-start your mac to refresh it's internal dns

Windows Users: It's pretty much the same process, with the hosts file living in c:\windows\system32\etc\ (on WinXP) usually and you can edit the file notepad.

How to customise the Unit Converter Widget in Mac OS X Dashboard

Dashboard! What a cool app - there when you need it, gone when you don't. That's my idea of usefulness.

Now one of the Widgets I use the most is the Unit Converter widget. It's very handy indeed and saves me having to browse through half a dozen Google results to find the conversion that I need.

However, for one reason or another, I was brought up to measure my weight in Stones - these don't seem to relate to anything real except bodyweight and unfortunately I can only appreciate my weight in these terms (Kg mean nothing to me, though suffice it to say I have a lot of them!).

Unit Converter doesn't have a facility for converting between Stones and Kilograms at present but actually adding one is very simple - all the information is contained in one script file that's part of the widget and in fact the hardest part of the operation is changing the permissions on the file. This should work for any other type of conversion you wish to add as well.

Here's how to do it:

This operation will require you to restart Dashboard (I think), which could mean you having to restart your mac. Ideally the best time to make this change is after you've booted up and before you start Dashboard up. That way, you can save your change, hit F12 and see it working straight away.

1) Launch Finder and browse to the Library folder on your hard disk

2) Browse to the Widgets folder

3) Ctrl-click the Unit Converter widget and choose Show Package Contents from the options

4) Now make a copy of Conversions.js to be on the safe side (you will need to enter your password to do this)

5) Highlight Conversions.js and Get Info on it

6) Here you will need to change the Ownership & Permissions on the file so that you can Read & Write it. You will need to enter your password again

OK, here's the fun bit

7) Open up Conversions.js in a text editor.
You will see it's made up of blocks for each of the conversion types, which look something like this

JavaScript:
  1. var Weight = [
  2. {name:'Short Ton (US)', toBase:linearForm(907.18474), fromBase:invLinForm(907.18474)},
  3. {name:'Pound (US)', toBase:invLinForm(2.204622622), fromBase:linearForm(2.204622622)},
  4. {name:'Ounce (US)', toBase:invLinForm(35.2739619), fromBase:linearForm(35.2739619)},
  5. {name:'Long Ton (UK)', toBase:linearForm(1016.0469088), fromBase:invLinForm(1016.0469088)},
  6. {name:'Metric Ton', toBase:linearForm(1000), fromBase:invLinForm(1000)},
  7. {name:'Kilogram', toBase:linearForm(1.0), fromBase:invLinForm(1.0)},
  8. {name:'Gram', toBase:invLinForm(1000), fromBase:linearForm(1000)}
  9. ];

so you can see, all we need to do is add another line in there with our conversion in it. Now the way that the Unit Converter appears to work is that for each set of units, it has a base unit - in this case it is Kilograms and you can see that the conversion ratio for Kilograms is 1.0. Whenever a conversion is made, the unit is first converted to the base unit, and then converted to the required unit.

Looking at an entry, for example

{name: 'Gram', toBase:invLinForm(1000), fromBase:linearForm(1000)}

you can see that the key information we need to put in to create a new entry is a name and a single figure, that being the amount of the new unit (Gram) per one of the base unit (Kilogram), that is, 1000.

To create a new conversion, we need to get that ratio. I went here and retrieved the following information:

1 kilogram is equal to 0.15747304441777 stones.

so all we have to do now, is go to the bottom of the weights block and:

1) Add a comma, after the final conversion (Grams), so the end of the line looks like this

... fromBase:linearFrom(1000)},

2) Put in the following line after the last entry but before the closing square bracket
{name:'Stones', toBase:invLinForm(0.15747304441777), fromBase:linearForm(0.15747304441777)}

3) Save the file and fire up Dashboard

Here's a copy of the complete and working file:

Conversions script updated to include Stones

Troubleshooting

You will know if it has worked because Unit Converter will run the way it always does and Stones will now be an option to choose from. If you find that you can't select any units and the image across the top does not look right, then there's something wrong with your update to the script: you've missed a comma, a quote or a bracket or brace or square bracket. Go back and look at it. In the worst case scenario, you can copy your original backup of conversions.js over the new one but you will need to restart Dashboard and possibly your Mac for it to work again.