Skip to content

Whatallo

Update, 20 February 2012: Though you probably won’t need to run your own whatallo, the code may serve as a Hello World for Google App Engine, therefore the code for the site is available here https://github.com/mdneale/whatallo.

We were just watching ‘Allo ‘Allo!, something we are prone to do and it reminded me of something I wrote last year, of which more in a moment. On the subject of ‘Allo ‘Allo, I still find it hilarious even after all this time. My favourite character is probably Monsieur LeClerc who arrives each episode disguised badly as some unlikely character or other in order to convey a message on behalf of the French resistance. He appears briefly at the end of this clip as an often-seen-in-wartime-France Christmas Pudding Seller.

The original Monsieur LeClerc actor Jack Haig had French mannerisms perfectly exaggerated. On the flip-side of that I could also have chosen Officer Crabtree, also featured in the clip, the English agent disguised as a French policeman poloceman whose French is probably something akin to mine.

Anyway, I’m skirting the point. If you watch it as much as we do (perhaps unlikely) then you need a simple way to randomly choose an episode to watch. Enter whatallo.com – it picks you a random episode and remembers what you have watched so that it doesn’t suggest the same episode twice.

It’s just a bit of fun, put together with Python, Django and jQuery running on Google App Engine, and I wholeheartedly recommend all of them.

Image

Outsiders

Outsiders

Variety

A bit of light observation. Different ways to do an else if with examples from languages I use or have used frequently.

Type 1: else if

Separated else and if, minimising the number of keywords required in the language. Personal favourite.

if (expr) {
    statements
} else if (expr) {
    statements
} else {
    statements
}

As in: C, Java

Type 2: elseif

Remove the space, for a bit more typing efficiency.

If expr Then
    statements
ElseIf expr Then
    statements
Else
    statements
End If

As in: Visual Basic

Type 3: elsif

Contracted by one more character, while still reading as “else if”.

IF expr THEN
    statements
ELSIF expr THEN
    statements
ELSE
    statements
END IF;

As in: Oracle PL/SQL, Perl

Type 4: elif

if expr:
    statements
elif expr:
    statements
else:
    statements

As in: Python and the Korn shell

Does anything use eif?

Image

Rue Montorgueil has a Space Invader

I am tracking-down the invasion, one Space Invader at a time…

Rue Montorgueil has a Space Invader

What would you attempt to do?

This quotation was sent to me the other day by a colleague, and has been sitting in my inbox awaiting my decision on where to ‘file’ it.

“What would you attempt to do if you knew you could not fail?” – Dr Robert H. Schuller.

Random motivational image

Random motivational image

I shall think about it, but it’s easier to ask it than to know the answer.

By the way, though I have no interest in the Church, Dr Robert H. Schuller’s life is worth reading about – even if it’s a quick peruse of his Wikipedia page, and a cursory glance at the first page of Google search results.

Email filed!

Amazon AWS Signatures

Last Thursday I presented an afternoon overview on Web Services to a group. We were using soapUI to demonstrate some SOAP Web Services written for a customer, and I wanted to demonstrate also that it is just as easy to call public services which are remote. For this I chose the Amazon Product Advertising API, partly due to the fact that it’s already an example on Eviware’s soapUI website, and partly because Amazon is such a well-known company. This post is a very short follow-up to explain how to do properly, something which I had to use a nasty workaround for during the afternoon.

The problem was the signature required in the header of the SOAP request, which I had to drop-to an executable I had written to generate. I would rather have used an off-the-shelf tool, but I couldn’t get openssl to work (completely due to user-error you understand).

I knew it was one of a few gotchas that was giving me the problem but I didn’t have the time to figure it out. Now I have, so what follows is, in as few a number of steps as I can manage, a 1-2-3 of how to send a request to the Amazon Product Advertising API.

Before we begin, sign-up to Amazon AWS. Amazon will send you an email – follow the link provided in the email and grab your AWS Access Key ID and Secret Access Key and paste them somewhere – we’ll need them in a moment.

To send a SOAP request (without WS-Security):

  1. Run soapUI
  2. Create a new project with the Product Advertising API’s WSDL by entering the URL:

http://webservices.amazon.com/AWSECommerceService/
AWSECommerceService.wsdl

  1. In the Navigator pane on the left of the soapUI main window, find the request for the ItemSearch action and paste in:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://webservices.amazon.com/AWSECommerceService/2009-10-01">
   <soapenv:Header xmlns:aws="http://security.amazonaws.com/doc/2007-01-01/">
      <aws:AWSAccessKeyId>?</aws:AWSAccessKeyId>
      <aws:Timestamp>?</aws:Timestamp>
      <aws:Signature>?</aws:Signature>
   </soapenv:Header>
   <soapenv:Body>
      <ns:ItemSearch>
         <ns:AWSAccessKeyId>?</ns:AWSAccessKeyId>
         <ns:Shared>
            <ns:SearchIndex>DVD</ns:SearchIndex>
         </ns:Shared>
         <ns:Request>
            <ns:Title>Allo Allo</ns:Title>
         </ns:Request>
      </ns:ItemSearch>
   </soapenv:Body>
</soapenv:Envelope>
  1. Replace the search criteria if you don’t wish to search for Allo Allo DVDs (I do – it is hilarious)
  2. Insert your AWS Access Key ID in the two places provided.
  3. Choose a date and time for the timestamp. Right now will do.
  4. Concatenate the name of the action you are invoking and the timestamp in the format YYYY-MM-DDTHH:MM:SSZ, e.g. ItemSearch2009-10-11T16:11:30Z.
  5. Generate the signature using openssl as follows, inserting your Secret Access Key where indicated:

$ echo -n ItemSearch2009-10-11T16:11:30Z | openssl dgst -sha256 -hmac secret_access_key -binary | openssl enc -base64

  1. Paste the timestamp and the signature into the request where indicated and click the ‘Play’ button in soapUI to send the request. If all is well you’ll get a set of results from Amazon.

If you don’t have openssl you can download it from http://www.openssl.org/. There are links to binaries there, including for Windows.

The -n option to echo is very important, and was where my problem lay. On UNIX it suppresses the carriage return – important since we don’t want a carriage return as part of the text to be signed. On Windows however there is no equivalent (to my knowledge) and including the carriage return gives the wrong signature.

My best suggestion for a workaround for Windows is as follows. Open up notepad and write the text to be signed “ItemSearch2009-10-11T16:11:30Z” into it with no newline after. Save it, making sure to save with ANSI encoding (an option in the Save Dialog). Then at the prompt, execute the following command, again inserting your Secret Access Key where indicated, and the filename of the file that you just created.

$ openssl dgst -sha256 -hmac secret_access_key -binary filename | openssl enc -base64

If you’re not using openssl, or you just want verification, assuming the hypothetical Secret Access Key of 1234, I get the following:

$ echo -n ItemSearch2009-10-11T16:11:30Z | openssl dgst -sha256 -hmac 1234 -binary | openssl enc -base64

FRnAn5puzTwI47vJ33sQHYQ9SSSIBjChTKd8u8Mbfs4=

If you’re getting the same then you’re okay 🙂

Full documentation of the Amazon Web Services security can be found here.

Wood Smoke

It just happened again! I tweeted about this last winter, and I may be repeating myself but I *love* living in a city where I can open the window and get a good waft of wood smoke. It evokes memories for me of Mousehole in Cornwall as a child. Just as soon as le ramoneur has visited, I shall be lighting a fire in our chimney.

These days it may be un-green to light a fire when it’s cold (wood is better than coal, I know) and it’s really not good for city pollution. For me though it smells like magic, and that is what this city is. Round every corner and down every rue there is something new to be discovered every day. Some days I hate it, and I may have to leave it, but magic is what it is – a city which hasn’t lost touch yet with its past.

%d bloggers like this: