On Tuesday evening, I gave a 20 slide ‘lightning talk’ at the London Ruby Users Group (LRUG) entitled “Ruby Poetry”. Inspired by Murray Steele’s ”My First Ruby” talk at a previous LRUG, I decided to tell a story about a small progam I wrote about five years ago, when I was fairly new to Ruby. At the time, I had just made the transition to Ruby after years as Java developer, and I was amazed at how easy it was to solve problems without having to write very much code.
The story starts when I was invited to a party. The party was a themed Burns Night dinner. These celebrations are common in Scotland to celebrate the life and poetry of Robert Burns. I had been invited to the same party the previous year, and remembered back to enjoying the haggis and whisky. One thing I recalled that had not felt particularly comfortable with, is that I had been asked to bring a poem to read. On the evening, instead of bringing poems from books, most people had written their own, and I felt bad for lacking creativity. I decided that this time around, I would try to be creative in my own way, and wrote a Ruby program to generate some topical poetry from the day’s news headlines. I won’t go into too much detail here, as my five minute talk was kindly videoed by Skills Matter:
The code below is what I used to generate the couplets on the day. While I had been tuning my algorithm, I wrote the headlines to a file so I didn’t have to reload them each time. The full source is on github.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
As the couplet finding algorithm was fairly crude, only looking for matches of the last three letters, and not the phonetic representation, I allowed myself to pick the best couplets as generated on the day. To demonstrate my code, I reran the program on the day of my talk, and read the best couplets it generated at the end of my presentation:
The final poem, as generated on the day of the talk
I particularly like the last one, which like the others, was genuinely generated on the day.
So the two talks I have given at LRUG have been entitled Ruby Poetry and Ruby Golf. What Ruby <insert word here> should I do next?