XDebug, PHP and Sublime Text 2 on Ubuntu 12.04

Getting Xdebug for PHP working with Sublime Text 2 is slightly tricky.

Most of the instructions are at https://github.com/Kindari/SublimeXdebug - these notes are just a bit extra as a reminder to myself.

After installing Xdebug with “sudo apt-get install php5-xdebug”, you have to add some xdebug  settings in /etc/php5/conf.d/xdebug.ini:

zend_extension = /usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=1

In ST2, you use SHIFT+F8 to get the Xdebug menu, and select “Start debugging”. In your browser session, add a url parameter like this:

?XDEBUG_SESSION_START=sublime.xdebug

The page request should hang while the debugger has control – if nothing’s happening in ST2, you’ll need to check the console window by using ”CTRL`”.

You may get this output:

Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./Xdebug.py", line 553, in run
File "./Xdebug.py", line 97, in read
File ".\xml\dom\minidom.py", line 1927, in parseString
File ".\xml\dom\expatbuilder.py", line 32, in <module>
File ".\xml\parsers\expat.py", line 4, in <module>
ImportError: No module named pyexpat

In which case you’ve got the problem with Python versions – 2.7 is the default on Ubuntu 12.04, and ST2 and the Xdebug plugin are using Python 2.6.

So follow the instructions at the bottom of the README at https://github.com/Kindari/SublimeXdebug

On Ubuntu 12.04, Python 2.6 isn't available, so here's what worked for me:

    * Download python2.6 files from <a href="http://packages.ubuntu.com/lucid/python2.6">Ubuntu Archives</a>
    * Extract the files: dpkg-deb -x python2.6_2.6.5-1ubuntu6_i386.deb python2.6
    * Copy the extracted usr/lib/python2.6 folder to {Sublime Text directory}/lib

(I actually copied the usr/lib/python2.6 directory to /usr/lib/python2.6, and symlinked to there from {Sublime Text directory}/lib)

Then restart ST2 and try again. Once you hit a breakpoint, it should look like this, with the Xdebug Context and Xdebug Stack windows showing content:

Enable trackpad coasting in Ubuntu 10.04

I like the way trackpad edge-scrolling allows you to “coast” (start scrolling with the edge of the trackpad, then release it, and the scrolling continues until you tap the trackpad again).

It’s not enabled by default on Ubuntu 10.04, but here’s how to turn it on (put it in a startup script):

xinput set-prop –type=float “AlpsPS/2 ALPS DualPoint TouchPad” “Synaptics Coasting Speed” 1

Installing Ruby Active Record on Ubuntu 10.04

I had to jump through a few hoops..

I tried the obvious “sudo gem install activerecord”, but it gave an error – it needs to install the i18n gem, but that needs rubygems version >= 1.3.6, and I had rubygems 1.3.5.

So I had to upgrade  rubygems first, which would normally be :

sudo gem update --system

but that reports that it’s been disabled on Debian, and directs you to use apt-get instead (which doesn’t have a better version). So I had to use the gem-updater gem:

sudo gem install rubygems-update
sudo update_rubygems
after which I had rubygems 1.3.7. Then I could get active record:
sudo gem install activerecord

I still needed to get the mysql gem installed, which in turn needed the libmysql-dev stuff installed

sudo apt-get install libmysqlclient15-dev
sudo gem install mysql

Ubuntu and CloudInit on Amazon EC2

Alestic and Canonical have released new Ubuntu AMIs for EC2 – the EBS version in the eu-west-1 region has AMI ID “ami-38bf954c”, and the source is “099720109477/ebs/ubuntu-images/ubuntu-lucid-10.04-i386-server-20100827″.

Ubuntu images support CloudInit, which runs scripts on startup to allow you to configure the server (set up ssh keys, update the repos etc). There’s a load of different ways to specify what should get run (see https://help.ubuntu.com/community/CloudInit for full details).

One of the simplest is just to give it a script in the User Data, like this:

#!/bin/sh
echo "Hello World.  The time is now $(date -R)!" | tee /root/output.txt
EOF

It runs as the root user, so you can do pretty much anything you want to configure the box.