Many Pies

Many Pies

Tuesday, October 20, 2009

Weather forecast via twitter - wycombeweather

Ages ago I thought it would be handy to have a local weather forecast delivered to my phone, for free. Then twitter came along and it looked like that might provide a possibility. By this time I'd come across the BBC weather RSS feeds.

I tried a couple of "RSS to twitter" services and both worked once and then never again. Google app engine looked like a good way of finding a server to do the stuff to join RSS to twitter. So I cobbled together bits of Python code and came up with this. (Update: September 2010 - updated to use oauth library. You'll need to register your app via dev.twitter.com to get the four keys below. )

(Paste in code from feedparser.org. Comment out the main program stuff.)
(Paste in outh stuff from http://github.com/mikeknapp/AppEngine-OAuth-Library/blob/master/oauth.py)


# Cobbled together from
# http://highscalability.com/using-google-appengine-little-micro-scalability
# http://pydanny.blogspot.com/2008/04/feedparser-does-not-work-with-google.html
import wsgiref.handlers
import urllib
from google.appengine.api import urlfetch
import base64
import feedparser
import StringIO

from google.appengine.ext import webapp

def getWeather():
      content = urlfetch.fetch("http://feeds.bbc.co.uk/weather/feeds/rss/5day/id/2111.xml").content
      d = feedparser.parse(StringIO.StringIO(content))
      if d.bozo == 1:
           raise Exception("Can not parse given URL.")
      return d['entries'][0]['title']

class WeatherText(webapp.RequestHandler):
def get(self):
     self.response.headers['Content-Type'] = 'text/html'

     self.response.out.write(getWeather())
     self.response.out.write('
supported by backstage.bbc.co.uk')


class UpdateWeather(webapp.RequestHandler):
def get(self):
     self.response.headers['Content-Type'] = 'text/plain'

     message = getWeather()
#      self.response.out.write(d['entries'][0]['title'] )
#      message = datetime.now().ctime()
     payload= {'status' : message,}
#      payload= urllib.urlencode(payload, True) Removed when switching to oauth client
# Get rid of degree marks because they turn out as question marks in the final tweet
#      payload = payload.replace('%3F','') degree marks work on twitter, appear as "deg" in txt, still wrong when main URL viewed
#      self.response.out.write(payload)

# Your application Twitter application ("consumer") key and secret.
    # You'll need to register an application on Twitter first to get this
    # information: http://www.twitter.com/oauth
     application_key = "im_not_telling_you"
     application_secret = "nor_this"
  
    # Get these from http://dev.twitter.com/apps/your_app_number/my_token
     user_token = "this_is_a_secret"
     user_secret = "this_is_definitely_a_secret"
  
    # In the real world, you'd want to edit this callback URL to point to your
    # production server. This is where the user is sent to after they have
    # authenticated with Twitter.
     callback_url = "%s/verify" % self.request.host_url
  
     client = TwitterClient(application_key, application_secret, callback_url)
     result = client.make_request("http://api.twitter.com/1/statuses/update.xml", token=user_token, secret=user_secret, additional_params=payload, protected=False, method=urlfetch.POST)
# Removed when oauth implemented
#      base64string = base64.encodestring('%s:%s' % (login, password))[:-1]
#      headers = {'Authorization': "Basic %s" % base64string}
#
#      url = "http://twitter.com/statuses/update.xml"
#      result = urlfetch.fetch(url, payload=payload, method=urlfetch.POST, headers=headers)
#
     self.response.out.write(result.content)


def main():
  application = webapp.WSGIApplication([('/', WeatherText),
('/updateweather',UpdateWeather)],
                                       debug=True)
  wsgiref.handlers.CGIHandler().run(application)


if __name__ == '__main__':
  main()

 You can see the results at twitter.com/wycombeweather and wycombeweather.appspot.com. If you want to do it for your local UK weather you'll need to change the figure 2111 above and use your own twitter account.

Tuesday, September 29, 2009

Presentations and Powerpoint

My colleague, Phil Prior, and I did a session this morning on presentations and use of Powerpoint. He has written up his thoughts on presentations.

We did a more advanced course last week. On that one I covered a number of steps to ensure things go smoothly. I hadn't practised what I preached (run through it on the actual equipment beforehand), and when I opened up clip art the PC froze so I had to borrow a laptop from one of the participants and carry on from there!


Thursday, September 24, 2009

My 1.5 seconds of fame

The BBC Digital Revolution people (putting together a 4 programme series on the web and stuff) asked on Twitter if anyone had questions for Shami Chakrabarti of Liberty.

Tweet: @bbcdigrev Can she (Shami Chakrabarti) forsee a time when Liberty is out of a job?

Her answer:


Original blog entry: Tim Berners-Lee and Shami Chakrabarti interview clips (Video): web privacy and obsession

(cross posted to my personal blog)

Friday, August 28, 2009

A picture of a radio programme in the making

I don't often point to other blogs, because you might as well just read them, but this one was worth highlighting. David Ker has put a photo on one of his blogs showing him at work producing a radio programme with Bible material. Click on the picture to see what the numbers in the stars mean.

some guys sitting around a computer

Thursday, August 27, 2009

Expedia no longer supports Passport/Windows Live id

I've searched blogs and looked on techmeme.com, but I can't find any reference to this. I got an email today from Expedia saying they no longer support .Net Passport aka Windows Live id.


When you click on the "Why?" link you get this. Which isn't really a satisfying explanation.
As we work to continuously improve the service we provide you, it's sometimes necessary to make changes. Unfortunately, recent upgrades required we end our support of Passport/Windows Live ID service.

Friday, August 21, 2009

An old hard disk and a new video

A few months ago someone from Wycliffe Canada contacted me. There was an old hard drive in the UK that had some music on it that he wanted to put on a video that he was producing. He wanted me to get the music off it and send it to him on a new hard drive.

The hard drive possibly hadn't been used since 2002. The hard drive was sent to me, and because it was in Mac format I got a colleague who used a Mac to help me get the files off. The drive span up OK and we started getting files off it, but then after 15 minutes or so it died mid-copy. It was pretty terminal and I couldn't get it to work at all after that. Not all of the original files for the music were there, but, thank God, the final mix of all files was there, including the song that was required.

This song now appears on a DVD. Here's the preview, but not with the song though:

Monday, July 27, 2009

Optimistic search button

This bike spares had an "I'm feeling lucky" button next to its search box, but then it changed on one page to this: