Archive for March, 2008

Get scores of Indian cricket matches on twitter

March 29, 2008

I wrote a script to fetch the scores from CricInfo‘s Live RSS feed and post messages to Twitter everytime the score changes.

You can get scores by following indiablues on Twitter.

The code is available here .

UPDATE: Inspired by baggygreen and meninblue, I wrote another script to scrape the comments of off CricInfo’s famous ball-by-ball commentary using BeautifulSoup and post it to Twitter using their API. The only difference is that, I post only the comments mentioning boundaries or Sixes or Outs. Getting all commentary is boring. Anyways, the code is available here.

Advertisements

Showing white space ‘as-is’ in HTML

March 14, 2008

A common gripe about HTML rendering is that white spaces are not preserved.

For e.g. giving

<table><tr><td>This is       a                       test</td></tr></table>

will end up being shown as ‘This is a test’.

To show the spaces, people generally convert spaces to & nbsp;

to preserve the spaces. Instead, a CSS property ‘white-space’ can be used.

For e.g. to preserve the spaces, do this:

<table><tr><td style = "white-space:PRE">This is       a                       test</td></tr></table>

This will display preserve the white spaces and show

'This is            a                        test'

on the browser. We need to include a !DOCTYPE to make use of ‘white-space:pre’ property on IE.