Perl has a native support for different character encodings, like the well known UTF-8, but its default behavior is to use Latin-1. This brings easily to a lot of problems if you don’t tune certain settings. Read more
Remove “compatibility view” button in Internet Explorer
Old Internet Explorer version are often a big problem for web developers. Fortunately everyday the people using IE 7, IE6 or even IE5.5 became lesser and lesser. So usually we don’t have to spend to much time to fix everything in our CSS to make every page look perfect in all this old browsers because people using them are not so relevant.
Passing from IE7 to IE8 Microsoft had the “brilliant” idea to help developers with this huge step forward, in particular enterprise sites was in past often strictly related to a browser version and the change could be a big problem for them. The solution was the “compatibility view” button, the button with a broken page icon, which switches your modern browser to an old IE7 mode. Holy crap! :-O
The “Compatibility View” is domain scoped and remembers the setting even after the browser was closed. So what can we do?
We can say to Internet Explorer: hey don’t worry, everything is okay! It’s pretty easy, we have just to use the X-UA-Compatible header and set this value: IE=edge. In a HTML page you can use a meta tag:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Or you can choose to add it to your web server configuration. What does it mean? It says to Explorer to use his last standard mode. So IE8 will render the pageas IE8, IE9 like IE9 and so one and the “Compatibility Button” will disappear. Gotcha!
Remove frameBorder on Internet Explorer in quirks mode
I know that the most of the internet pages run in standard mode, but sometimes it happens to work for some generic plugin and so you have to check your code in such a situation and especially with Internet Explorer 6, 7 and 8 there are a lot of bad surprises 🙁
A page runs in standard mode when a doctype is set. It’s common to use the simple HTML5 doctype on the first row of a HTML page: <DOCTYPE html> Very easy! Without such a definition your page runs in non-standard mode, also called Internet Explorer 6 mode, but everyone knows it as “quirks mode”.
But there is a workaround that looks like this:
var iframe = document.getElementById('myiframe'); iframe.frameBorder = '0'; iframe.outerHTML = iframe.outerHTML;
That’s awful, I know, but it works! The iframe is forced to be rendered again and this way IE updates the frame border. Yay! 😀
But pay attention. The iframe must be already inserted into the DOM. If you created an iframe using document.createElement you have first add it somewhere in your page and then apply the workaround, otherwise nothing can happen.
And the last one: I noticed that if you have a handler to your iframe and apply the outerHTML workaround the handler invalidates somehow, so it’s safer to get a new one using, for example, getElementById.
“My unqualified host name (localhost) unknown; sleeping for retry” with sendmail
Sendmail is a easy to use mail delivery service. I use it on my linux box for developing purposes for deliver test mails to an example.com domain to my local mail box. Very easy and effective.
Same time ago sendmail began to hang on startup apparently without any reason. I’m start it on demand through the command line, so it wasn’t an important problem because it doesn’t hang the operating system start up, but in the end I had to fix it. A look into the /var/log/maillog gave me the hint for a solution:
My unqualified host name (localhost) unknown; sleeping for retry
Obviously localhost was correctly defined in my /etc/hosts file, and everything else than sendmail seemed to work properly. I also checked the /etc/nsswitch.conf file and the host resolution settings was right (first the “file” option and then the “dns”).
Finally I found the problem in my /etc/resolv.conf file. The DHCP defined a “domain” called “lan” for my PC. So in fact the full name for my box was “localhost.lan” and was defined nowhere.
Not too bad, just added it in the /etc/hosts and everything works fine again 🙂
Port rewriting with iptables
Sometime it is useful to rewrite incoming connection to a different port. It’s very easy with iptables:
iptables -t nat -A PREROUTING -i eth0 -p tcp –dport 443 -j REDIRECT –to-ports 9090
Obviously you have to change source port (443 in my example) and the destination post (9090 in the example) and maybe the interface.
I used this solution for a Apache server running inside a VirtualBox that offers HTTPS through VB’s NAT. The problem is that I don’t launch the VirtualBox using root, but with a not privileged user, so I cannot map the NAT on hosts’ 443 port, but I choose for a not standard 9090 port. Unfortunately external applications need to access the service on the standard port. Rewriting the port with iptable was a cheap solution 🙂
Using command line subversion with svn+ssh and identity file
Apache Subversion (SVN) is a good and commonly used versioning tool. Even if there are a lot of graphical interfaces for it you sometimes have the need to use it on command line (using the svn client) or it can be your choice. Anyway using Subversion this way isn’t very difficult, just a little bit less comfortable.
A secure system configuration requires that connections to your remote repository will be tunneled through SSH and a more secure configuration avoids password and uses identity files. The question is: how can i pass the position of my identity file to svn? And the user to use on the remote machine?
The solution is not obvious, but really simple: use the ~/.ssh/config file!
The SSH config file allows you to set different values to be used when connecting with SSH. This is a example:
Every time you try to connect to www.example.com the given identity file and username will be used. Very easy!