Archive for the ‘Tech’ Category

Azureus on Rails

Saturday, January 20th, 2007

Over the last few months I’ve been developing Azureus on Rails, a web interface for Azureus implemented in Ruby on Rails. The first release is now available for download at RubyForge.

For a while I had been using Strawp’s Azureus PHP Control Layer and the HTML Web UI plugin. Neither of these provided all the features I wanted though, so I developed my own. Azureus on Rails

  • displays detailed information about each torrent,
  • allows torrent and file priorities to be adjusted,
  • supports stopping, starting, pausing and removing torrents,
  • allows torrents to be uploaded or added by url
  • and has a feed of the downloading and seeding torrents

The Azureus on Rails Wiki contains the full list of supported features as well as screenshots and installation instructions.

FireBug

Thursday, January 19th, 2006

FireBug is a fantastic new Firefox extension for web developers.

It adds a console to the bottom of the Firefox window which shows you the log for the current page (including the ability to click on an error and have the source line that caused it hightlighted) and allows you to point-and-click to inspect any DOM element in the page. It can also inspect XMLHttpRequest calls and has a Javascript console.

Fixing rxml attribute escaping

Thursday, December 29th, 2005

The version of Builder used for rxml templates in Rails 1.0 doesn’t escape attribute values when they are written to the output. This means characters such as double quotes in the attribute values will cause invalid XML documents to be generated.

To avoid having to manually escape every attribute value in rxml templates, I’ve put together a plugin that fixes this issue. Download rails_fixes.zip and extract it to your vendor/plugins directory (to create a new rails_fixes directory). The plugin replaces the _insert_attributes method of Builder::XmlMarkup with one that escapes the values.

Timezone support in Ruby

Tuesday, August 30th, 2005

I spent some time at the weekend looking for a library in Ruby that would support converting times in UTC to particular named timezones, such as Europe/London or America/New_York, taking care of whether daylight savings was in force.

Unfortunately, I couldn’t find one, so I had to write my own instead. The result, TZInfo, is now available at RubyForge.

Bugzilla - Making more attributes available in bug mail

Wednesday, August 17th, 2005

I spent a while trying to work this out a couple of days ago. If you want to show more attributes of the bug in the Bugzilla 2.18 bug changed email, you can do the following:

Edit Bugzilla/BugMail.pm. Find the NewProcessOnePerson sub. There is a section that sets several values in the $substs hash. The new attributes you want to show need to be added to $substs. The attributes of the bug can be found in $values (named the same as the columns in the bugs table). The following example makes the bug product and component attributes available:

$substs{"summary"} = $values{'short_desc'};
$substs{"reasonsheader"} = join(" ", @reasons);
$substs{"reasonsbody"} = $reasonsbody;
$substs{"space"} = " ";

# Added the following lines to allow product and component to be used in bug mail
$substs{"product"} = $values{'product'};
$substs{"component"} = $values{'component'};

Once this change is made to the code, edit the newchangedmail parameter (bug changed email template) through the edit parameters admin screen. You will now be able to use the new values added to $substs as %name%. For the above example, %product% and %component% can now be added to the template.

Simulating views in Ruby on Rails

Wednesday, August 17th, 2005

If you want to use views in Ruby on Rails but aren’t using a database that supports them, I’ve created a subclass of ActiveRecord::Base that can simulate selecting from a view in a normal ActiveRecord find.

The extension allows the table names in the from section of queries to be replaced with subqueries specified by ActiveRecord classes. The subqueries can do anything that can be done with a view. ActiveRecords using subqueries can be eager loaded with includes like any normal ActiveRecord. This allows group bys and aggregate functions to be used without having to write a custom find_by_sql method or load in lots of data.

Download the code and view the documentation.

10 Things Every Java Programmer Should Know About Ruby

Wednesday, August 10th, 2005

10 Things Every Java Programmer Should Know About Ruby

A useful introduction to Ruby for Java programmers.

Escape from Yesterworld

Monday, August 8th, 2005

‘It was a dark world… where technology fought reason and foiled progress…’

A somewhat bizarre advert for Visual Studio and SQL Server:

Escape from Yesterworld

Symbolic links in Windows Vista

Saturday, August 6th, 2005

From Windows 2000, directory symbolic links (junctions) have been supported in NTFS.

It looks like Windows Vista (Longhorn) may now support proper symbolic links on files as well as directories. A simple API allows links to be created.