{ Don't Repeat Yourself ! }

Browsing Posts published in March, 2010

If you want a secure channel when visiting unencrypted websites you can use an ssh port forwarding to tunnel all
browser traffic through ssh.

ssh -D localhost:5555

Then configure your browser to use manual network settings and
enter localhost and port 5555 as SOCKS host.

Download and install the PHP Apache Module provided by Marc Liyanage

This package comes in handy if you want to use some advanced features like ZipArchive, XSLT, curl, etc
Apples default PHP  installation lacks all these useful extensions.
If you don’t want to spend time compiling PHP first, this package is a great time saver.

This does not seem to work with snow leopard.

After upgrading to Snow Leopard and a couple of hours headache, I finally got my custom AMP running again.
These are the problems I encountered and what I had to do to fix them:

  1. My Apache configuration files were completely overwritten. I had to recreate my vhost settings under /etc/apache2/extra
  2. MySql did not work anymore. I had to download and install the latest dmg image for 10.6 and then copy my databases into the new data directory under /usr/local/mysql-5.1.45-osx10.6-x86_64/data
  3. PHP was installed without php.ini and gave warnings about timezone settings – had to copy /usr/local/php5/lib/php.ini-recommended to /etc and set the date.timezone to my local timezone

I found this page quite helpful.

I have been looking for some tools that can create nice looking graphical reports of my server performance over time.
There quite a few useful command line utilities available such as sar, iostats, top, etc

But today I finally found what I was looking for.
The program is called Munin and here is a nice article on how to set it up on a Debian system:

Here is an example  of how to access joomla session data from another php script.
This is particular useful for implementing an AMF gateway or other ajax functionality.

To access the Joomla! session variables from another script, the easiest way is to instantiate the joomla application in that script. Please note that this will only work if that script is not already using its own session.

Example Code:

define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(__FILE__) );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe =& JFactory::getApplication('site');

$session =& JFactory::getSession();
$user = $session->get( 'user' );

In this example I’m assuming the script is located in the main joomla directory.
If the script sits in some subdirectory you’ll have to adjust the JPATH_BASE definition.

Great news – Nathan Mische has released a Firbug Plugin for Firefox that allows us Flash and Flex developers to view decoded AMF Traffic Requests and Responses from within our browser.

Check it out here:

The only problem at the moment – it is not very easy to find requests/responses if you have an application that is making a lot of requests simultaneously. It takes quite a bit of clicking and scrolling to find what you are looking for.

Nevertheless I’m absolutely impressed so far and I think it is a great tool. I’m very much looking forward to future developments.

This is a screenshot, that I took when running my flex password generator:

This is a bit off topic but I just came across a pretty cool animation by Fredrik Andersson called Watch Alice Bleed.

Watch Alice Bleed Animation


Watch Alice Bleed is a gore-filled stop motion animation. It opens with Alice being decapitated, and having her head fed to a dog. Then things start getting gruesome…

It can be found on which features quite a few good free movies from creators who WANT to share their work! Movies are shared over bit torrent.

use the following command to install time zone description tables into a MySQL server on a LINUX system.

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

you can then run ‘SET time_zone’ queries, e.g.  SET time_zone = “Pacific/Auckland”

This is very easy to do.
Assuming the database on the remote server runs on the standard mysql port 3306, the following command will establish the tunnel.

ssh username@remoteserver -L2000:localhost:3306

If successfully logged in through ssh, you can then connect your mysql client to port 2000 on your local machine and
will be able to use the remote database just as if it was running on your local computer. The good thing – all traffic will be encrypted by ssh.

obviously the L2000 means the port to be used on your local machine and 3306 is the port that will be used on the remote machine.

Note you can also add -f paramter to the ssh call:
ssh -f username@remoteserver -L2000:localhost:3306
if you want ssh to run in the background.

ever executed shell commands that process large amounts of text data?

for example mysql mydatabase < data.sql

with data.sql being a huge file.

this cool little tool called bar can display a nice ASCII progress bar for commands

Get Adobe Flash player