Noise reduction headphones

April 16, 2005
1 comment Work

My kind company just gave me a little gift to make our office environment less noisy. A pair of Bose noise reduction headphones. Click here for a picture

I was sceptic at first thinking that noise reduction will work but only in such a small way that one might as not bother. Boy was I wrong! It actually only really works if you play music through them. Unsurprisingly the sound quality is stunning (wouldn't expect less for that price :) and when you play music it starts to look like people are miming and you stop hearing little noises like tapping the keyboard, distant phones ringing and air conditioners. From now I'll have to keep my mobile in my pocket so that I can feel it vibrating because I've missed a call when the mobile was on my desk and I didn't notice at all.

They really work! A word of warning though, not having music is pointless. Noise is reduced but you can actually hear the headphones themselfs in a strange way. It's difficult to explain but it sort of rings in your ears like when you exit a nightclub and come somewhere it's quiet. If you don't want music and just quiet, just buy some ear plugs

Interior Octopus

April 14, 2005
25 comments Photos

Interior Octopus Someone added a test issue on the Demo issuetracker with an amazing file attachment.

I have no idea where it comes from and the person who uploaded it might have left an email address that doesn't work. I've tried emailing this person in hope of more info.

Imagine that some rich person has this as interior design in their house. (the person must be rich if he/she can afford a piece of art to consume so much space in the house)

Find print statements in Python code

April 12, 2005
6 comments Python, Linux

Do you, like me, use the powerful print function to debug your Python code? Do you, like me, sometimes forget to remove lines with print and ship this out to less development-like environments? Do you, like I did, need a way to check for forgotten print statements?

I've written a dumb-simple script that scans through a directory for print statements. It uses a recursive grep command so this won't work for you hopeless Windows people :)

Download it and put it in your ~/bin (you might want to read it through) then all you have to do is to run it against a directory where there are lots of .py files:


$ find_print_statements.py ~/dev/mypythonmodule

If it doesn't work perhaps you can patch it and let me know. This might not be for the faint-hearted. There might be serious security concerns unless you have full control over your users and su account. I take no responsibility if this script rm -fr / your hd.

Truncated! Read the rest by clicking the link below.

Your webpage in Lynx

April 8, 2005
0 comments Web development

Lynx is a web browser that is so basic in functionality that even Microsoft Internet Explorer is more userfriendly; sometimes. It's not graphical which means that you can run in on the command line of a computer where graphical applications aren't an option such as SSH access.

Another more important thing about Lynx is that it indicates how a blind person might see a website. (Remember, Google is blind) If you want to make a really accessible website that works universally you have to make sure it works in Lynx too. For non-Linux people it might not be so obvious how to install Lynx, and that's where LynxView comes in.

Here's what you see if you browse my website with Lynx and the IssueTrackerProduct.com

So if you're serious about your website please do make sure your site works reasonably well in LynxView.

Control comment spam

April 5, 2005
1 comment Python

Did you see my mentioning about addhrefs last week? addhrefs is a python module that turns a text full of URLs and email addresses into links. For example:


>>> from addhrefs import addhrefs
>>> print addhrefs("""Visit www.peterbe.com 
and email mail@peterbe.com""")
Visit <a href="https://www.peterbe.com">www.peterbe.com</a>
and email <a href="mailto:mail@peterbe.com">mail@peterbe.com</a>

Then I saw this instruction on google.com about Preventing comment spam They suggest you add a rel="nofollow" to links in your comments on your blog and with a bit of luck this will reduce the amount of comment spam you get on your blogs. So, how to do that?

Truncated! Read the rest by clicking the link below.

Python Cookbook arrived

April 5, 2005
2 comments Books

python cookbook I got my copy of the Python Cookbook today. This book might have been available in the US for some time but I had it preordered here in the UK. So for all fellow UK Python people who have been waiting like myself, just wanted to let you know that now it's avaible.

callable Python objects

April 2, 2005
8 comments Python

Python gurus are going to laugh at me for this one but I learnt it today; how to check if an object is callable. Before this I thought I was clever with this:


>>> def foo(): return "s"
>>> hasattr(foo, '__call__')
True
>>> hasattr(foo(), '__call__')
False

But there was an easier way. I discovered this by accident and looked it up in the documentation after. Use the builtin function called 'callable()':


>>> def foo(): return "s"
>>> callable(foo)
True
>>> callable(foo())
False

D'oh!

Ugly one-liner to debug an object in Zope

March 31, 2005
2 comments Zope

If you're a Zope developer like myself you will most likely have written code like this many times:


class MyProduct(...):
   def showName(self, nameobject):
       """ doc string """
       print dir(nameobject) # this is the example
       return nameobject.getName()

Namely that you use the dir() builtin function to inspect an object's attributes. It's a wonderful function that from what I've experienced only Python excels. (Apparently Bruce Eckels lists introspection as one of the best features of Python and he's a guru with Java and C++)

Truncated! Read the rest by clicking the link below.

Searching for the obvious

March 29, 2005
0 comments Wondering

Have you ever searched Google for something obvious like "news", "software" or "internet"? I have, but doing it felt very original.

Before reading on (unless it's too late) to guess what you'd find on the top spot of a Google search if you search for "news".

Ok, here are the results.

Truncated! Read the rest by clicking the link below.