The Team Rubber developers spend a lot of time, love and craft doing what we do. If you want to know more about what we’re doing and how, follow us on twitter.
http://twitter.com/TeamRubberDevs
Archive for the ‘Developer’ Category
Team Rubber Devs Twittering
Anthony George - January 11th, 2010Linux as an alarm clock
Richard Barrell - January 8th, 2010I’ve yet to find a cheap and reliable alarm clock loud enough to rouse me from bed in the morning. Fortunately, I already have a laptop with workable (if small and tinny) speakers. All that’s needed to turn it into a loud alarm clock is a little software. Here’s an easy way to do it in Linux:
Python tip: zcd
Tim Wintle - December 16th, 2009Another developer here suggested this to me (Thanks Rich!) – but every time I use it I think it’s really useful, so I thought I’d share it.
When you’re working with a python package like “product.section.part”, you end up with a directory tree like so:
product.section.part
+ product
+ section
+ part
- module.py
Now, navigating through these directories is a pain – each time you want to edit module.py, you find yourself typing something like:
cd p[tab]p[tab]/s[tab]p[tab] [editor] m[tab]
# (the "/" is required to get past the .egg-info file) # i.e. this expands to
$ cd product.section.part/section/part/ $ [editor] module.py
Rich simply added a simple function to my .bashrc to do this automatically – so I now type
zcd p[tab] editor m[tab] #i.e. this expands to $ zcd product.section.part/ $ [editor] module.py
- It’s much simpler, and makes moving between packages that little bit nicer !
Here’s the script to add to your ~/.bashrc:
function zcd() {
X=`echo $1 | sed -e "s/\\./\\//g"`
cd $1/$X
}
The Greatest Web Framework ever!
Tim Wintle - December 10th, 2009Here’s a question for the non-developers among our readers:
What web framework is this a screen-shot of?

Answer:
(If you answered “WordPress” you’re wrong)
- it’s actually from something called TinyMCE – which happens to be used for editing blog posts as part of wordpress – but it’s certainly not “wordpress” – it’s commonly used when building all kinds of sites – using all kinds of frameworks.
What wordpress actually looks like (for the people who build wordpress sites):
WordPress:

You may not have got much from looking at that screen-shot – so, for comparison, here are what two other common web frameworks look like to the people that use them to build websites:
Turbogears:

Drupal:

The chances are that you probably wouldn’t have been able to guess which one of those was which [unless you are a developer who has worked on one or more of them for an extended period of time].
Which brings me back to the post title – What is the greatest web framework ever?
Well that depends on what you’ve got experience with, and what site you want to build.
So What’s the best?
For some reason, people often seem to thing there’s a golden bullet to solve all their problems – both developers and clients. During a discussion the other day I likened this argument to saying
“Excel is great – it’s the best Application ever”
- and from that point forward only using Excel – for anything.
You want to play some music while you work, so you fire up Excel, and start rocking out – Sure, some might say that Excel just isn’t as good at playing music as iTunes – but you carry on because “It’s the best Application ever”
Then you want to check your emails – so you fire up Excel again (Your colleagues are sniggering behind you as you ask the jumping paperclip how many new emails you’ve had today – but you use it all the same…)
Oh hang on – you don’t!
Yet as developers we often find that we’re required to build a site using a specific technology – because “It’s the best application ever”
Some examples:
If you’re creating a blog then wordpress is really great – if you’re editing a blog post then there’s a TinyMCE already built-in, along with blog comments, and the ability to list blog posts in reverse-chronological order on the frontpage. If you don’t want those features – or you want other features, then you’re going to have to start building those things from scratch – that means no easy-editing form, no automatic page generation etc (unless you code it yourself).
Google Wave is written using GWT – which is a great tool for their specific requirements as it lets you design web applications that look like desktop applications in a very nice manner (if you’re a pythonista then you’d probably try something like pyjamas for that).
One of the web apps I spend a lot of time in is written in a mixture of Python and ANSI C (no web framework at all) – and that’s the best decision for that application and it’s requirements.
Another project I work on is in Zope – and another one is based around the Shindig OpenSocial framework – again, they’re the right frameworks for the tasks at hand
- and they’re all different because the tasks are all different.
Multiple python versions – collective.buildbot
Tim Wintle - December 7th, 2009One of the applications I work on recently dropped support for python 2.4 – and much to my surprise I found out buildbot was failing – despite the instructions to use the 2.5 interpreter.
We had the following code as part of the a collective.buildout:project configuration:
build-sequence =
python2.5 bootstrap.py
./bin/buildout -t 50
test-sequence =
python2.5 bin/tests -v --v
But looking at the logs, this was being re-written to use “python” (i.e. the version the buildslave was running on) during the buildout.
I guess I could have created separate buildouts for 2.5 /2.6 buildslaves for these projects – but having one buildbot buildout is just simpler.
I found that calling python by it’s full path in the configuration has avoided this issue – although it does mean maintaining different project sections for different python versions.
i.e.
build-sequence =
/usr/local/bin/python2.5 bootstrap.py
./bin/buildout -t 50
test-sequence =
/usr/local/bin/python2.5 bin/tests -v --v
Browser usage stats – Windows 7
Tim Wintle - December 2nd, 2009I’ve just released our browser statistics for 2009 over on the viral ad network blog – but I thought I’d cross-post this here.
I found this chart quite amazing – it seems that users on Windows 7 have chosen Firefox over Internet Explorer.
Are we only seeing statistics for technical users of Windows 7 (i.e. those who upgraded early)? I don’t know – but here’s the chart:
(more stats are here)
Closure Compiler – Javascript optimising compiler
Tim Wintle - November 20th, 2009While I still haven’t got around to releasing my python port of the yui-compressor (I will soon, I promise), my plan had originally been to extend the compressor into an optimising compiler for javascript – but I just stumbled upon the a Google project that seems to have beaten me to it.
The Closure Compiler (google code page) does exactly that – it takes your javascripts and optimises them for both filesize and run-time.
I haven’t looked too deep yet, but it seems that it uses the parser from Rhino, and augments it with an implementation of a javascript AST, and an optimiser that works on the generated AST.
The Closure compiler is written in Java – anyone who feels like working on a python version is likely to find pynoceros (the python version of Rhino’s parser I annouced a few weeks ago) useful.
Optimisation – it’s sometimes needed.
Tim Wintle - November 10th, 2009Here at Team Rubber, we pride ourselves on working in a fairly agile manner. For the viral ad network in particular, this means that the most important thing at the end of an iteration is to ship working features, rather than to wait until everything is perfect before shipping.
As a side effect of this, optimisation is generally left until it becomes a noticeable issue. Obviously we worry about the complexity of our algorithms, and not designing ourselves into a corner – but I’m generally happy to take a constant speed reduction in exchange for faster development.
The code I’ve been working on this iteration was a different story, however, and I thought this story might be useful to people in the same situation.
My first implementation took about six CPU hours (in userspace alone!) to process just 1.5 Gb of data. Sure it scales sub-linearly, but I don’t want to have to bring loads of extra hardware on-line just to support this program.
The first thing to look at was the profiling information. pstats showed me that we were spending over 35 minutes looking up entries in my custom cache class – which is shared between different applications. This has a knock-on effects on the rest of the system as our cached items have to expire within a set time – this 35 minute delay means at least 10,000 extra (expensive) cache misses during this run. Each cache miss takes an average of 0.03 CPU seconds, so that’s an extra five minutes on top
Jaws screen-reader vs. Javascript modifying the DOM
Adam Alton - November 6th, 2009We’ve just finished building a site that is aimed largely at users with disabilities, and as a result we did quite a bit of testing with the Jaws screen reader to see how the site appears to a blind user.
I got into quite a fight with Jaws, Javascript and bad magic. I was adding some Javascript to modify a Wysiwyg editor to make it a bit more screen-reader friendly. At first it seemed that the Javascript just wasn’t working, but further playing revealed that it was but that Jaws wasn’t seeing the modifications that Javascript had made to the page, which was odd, as Jaws was able to see the Wysiwyg editor which itself had been created by Javascript And sometimes the Javascript just made Jaws read out the text for one link when the keyboard focus was clearly on another.
It turns out that (apparently) Jaws scans the web page when it finishes loading and creates its own copy of the elements on the page, so that when the user tabs through the items on the page Jaws tabs through its own copy of the page and reads out the elements.
Tbe problem is that a lot of Javascript gets run at page load time, (either because the <script> tags have been put at the end of the body, or because there’s some kind of jQuery type $(document).ready() thing in use). And it’s at page load time that Jaws makes its secret copy of your page. So if your Javascript is fast enough then it will run before Jaws reads the page, but if it’s too slow then Jaws wont know about the changes to the page, and so when your user tabs through the items on the page Jaws will read out the item that it thinks is there, even if it’s not.
Using pdb in Zope page templates
Adam Alton - November 5th, 2009It occurred to me a while ago that it must be possible to get into PDB in a Zope page template by using the ‘python:’ TALE and the magic ‘modules’ variable that is available there. And you can! It’s really dirty, but I’m sure it must be possible to do something useful with it:
<tal:x define=”x python:modules['pdb'].set_trace()” />
When the page is loaded it successfully drops you into the Python Debugger in the terminal, but it seems to be in some kind of context-less, etherial, undefined mystery state in which you can’t access any of the things that you would normally be able to access with python in a tal template.
Can anyone take this a step further and get it to be useful?












