Keep your SSH sessions alive

Most Internet service provider will try shutdown active Internet connections after a view minutes to prevent their network from streaming videos or other bandwidth killers. This happens often because of some router setting you can’t change. As a web developer your SSH session (and other active connections) will freeze, if you stop working in the terminal window for just 5 minutes or by getting a fresh cop of coffee.

To get rid of this problem you need to change your SSH config file, enter the following inside to the terminalwindow

sudo nano /etc/ssh/ssh_config

and add this setting to the end of the file

ServerAliveInterval 60

Safe your file and start a new SSH session which will stay active because the client sends every 60 seconds a bit of data to the server.
Check also this article for more information.

RSS script with cache function

The native function SimpleXML in PHP5 is a great functionality to parse a XML feeds as HTML show content on your website. Maybe you like to show your last blog posts on your company’s website? If your website has some bigger traffic, you should think about to cache the RSS/XML file to lower the server load on the host where your RSS feed is hosted. This small PHP snippet will check if there is already a fresh cached version and if not a new feed is requested with PHP file functions. In that case a cache version for the new XML file is stored on the website’s host. With this function the XML is stored unchanged, why? The XML has already a data structure which we use for later purposes. Using simpleXML, the XML is converted into an object and this object is used together with a loop to show some content in your HTML. In our example the RSS feed from our WordPress weblog is parsed to show the latest posts on our website.

Continue reading RSS script with cache function

Extract the TLD from a domain name

There is no standard PHP function to extract the TLD from a domain name, parsing an URL with parse_url() will return the host name and other URL information. If you need only the TLD, for example to query the WHOIS data of a given domain name, the following script should be useful. To run this script you need a database with all TLD’s. The snippet is using a database table which is required for the scripts functionality, download the MySQL table dump here. Continue reading Extract the TLD from a domain name