geek stuff


If you’ve used PLESK for any great length of time, you’ll know that whilst it is a great bit of software, for some reason it defaults to doing Reverse DNS lookups whenever a client connects to it to send mail.

Yeah rDNS is a useful tool for stopping spam and the like… but it also means that every single email sent takes 26-30 seconds to go out. That’s frankly unacceptable when you are trying to operate a commercial service and vastly undermines any possible benefits from it.

The good news is that it is (fairly) easily resolved. All you have to do is put in a command-line flag to tell the mail server not to perform an rDNS lookup. The hard part is figuring out exactly where to stick it.

Up to version 8, I used to refer to this handy guide, which resolved the problem though in ways I couldn’t quite understand! see here at

http://tyrannical.org/page-14

PLESK 8.4 introduces some major under-the-hood improvements, one of which is a subtle reorganisation of where the commands are stored. After some handy support from our ISP CWCS, we found that the command had moved to here:

/etc/inetd.conf

and all you have to do to switch off rDNS is to insert the following flag after the second occurrence of the phrase “tcp-env” in your inetd.conf.

-Rt0

More info and some other useful tips here

Anatomy of -Rt0
What does -Rt0 mean exactly? Well it’s a command that’s issued to the TCP server and it tells it to

R - Do not attempt to obtain $TCPREMOTEINFO from the remote host.
tn - Give up on the $TCPREMOTEINFO connection attempt after n seconds. (default is 26 seconds ho, hum)

The complete howto

  1. Login to your PLESK server using SSH
  2. type the command vi /etc/inetd.conf
  3. type the letter I (to insert)
  4. find the two lines that begin with smtp stream and smtps stream
  5. look for the second occurrence of tcp-env
  6. type -Rt0 into the line (note zero, not ‘o’)
  7. hit [esc]
  8. type : (shift-colon)
  9. type wq! (meaning write the file and quit from vi)
  10. hit [return]

now all you have to do is restart inetd, which is done on Ubuntu by entering the command

/etc/init.d/xinetd restart

You should now find that SMTP mail sending is lovely and quick. Phew!

Caveat
Please note that making some changes in the PLESK domain control panel will reset this command line, so you may need to edit it again if you start to notice delayed SMTP sends

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

This will copy a table, structure and data from SQL server database to another.
Damn handy!

[sql] SELECT * INTO TargetDatabase.dbo.MyTable
FROM SourceDatabase.dbo.MyTable[/sql]

I’ve just got my hands on a new* web browser, Flock. It’s built on the Mozilla core (Firefox, Camino etc) but boasts a number of interesting and innovative features, such as in-browser Flickr viewing and uploading and in-browser blogging.

Lets see if it works…

(you can get Flock from here www.flock.com)

Blogged with Flock

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.

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.

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
[js]var Weight = [
{name:'Short Ton (US)', toBase:linearForm(907.18474), fromBase:invLinForm(907.18474)},
{name:'Pound (US)', toBase:invLinForm(2.204622622), fromBase:linearForm(2.204622622)},
{name:'Ounce (US)', toBase:invLinForm(35.2739619), fromBase:linearForm(35.2739619)},
{name:'Long Ton (UK)', toBase:linearForm(1016.0469088), fromBase:invLinForm(1016.0469088)},
{name:'Metric Ton', toBase:linearForm(1000), fromBase:invLinForm(1000)},
{name:'Kilogram', toBase:linearForm(1.0), fromBase:invLinForm(1.0)},
{name:'Gram', toBase:invLinForm(1000), fromBase:linearForm(1000)}
];
[/js]
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.