Sunday, May 15, 2011

Subtitles

There have been a few occasions recently where I have been watching non english films with my partner and the subtitles have been so bad, it's not worth watching. Each time I have been able to find a perfectly acceptable SRT file that has decent subtitles. But if I'm watching on a DVD player this doesn't help. So, today, bored, I decided I would write a program that would parse an srt file and display the subtitle for me, it's a simple console app (in python at the moment but I plan to write another in C++ (and maybe one for my phone!)) which means, as long as I find the srt beforehand and start my app at the same time I start the film (or start watching on tv) I have pretty decent subtitles. Here's a short video of it in action.

Sunday, February 20, 2011

Arduino Pager with Google App Engine Part 2

I've now updated the web app and the arduino to only show unread messages. Pressing a button on the arduino marks a message as read and grabs the next unread one.

Saturday, February 19, 2011

Arduino Pager with Google App Engine

Today I decided to turn my arduino into a pager (albeit a not very portable one). The project had two parts.

1) A Google App Engine application that would store messages submitted via a HTML textbox and provide a way of querying these messages.

2) An arduino sketch that would make requests of the web app and display the results on an LCD screen. Here's the result:






http://mattywpager.appspot.com/

The hardest part was working out how an arduino can query this app using the shared ip address of appspot.com. This was acheived by using wireshark to see what my browser was doing. The resulting sketch simply sends this to the client

    client.println("GET /last HTTP/1.1");
    client.println("HOST: myappname.appspot.com");
    client.println("Connection: keep-alive");
    client.println("Cache-Control: max-age=0");
    client.println("Accept-Language:en-us,en;q=0.5");
    client.println("Accept-Encoding:gzip,deflate");
    client.println();


The whole thing took about 4 hours. But was great fun.

Friday, February 18, 2011

Agile in a Flash

Got Agile in a Flash the other day. At the end of our standups we pick a card at random and read it out. Any ideas we find relevant to our current situation we try to act on that day.


Wednesday, January 12, 2011

2010: A retrospective

As someone who considers himself an agile developer It seems only fitting that I do some kind of look back at the last year to see what went well and what I need to do better next time. In 2010 my big achievements were.

1) Android App published
2) iPhone App Published
3) Monthly blogging
4) Tracking software on a git repository

1 & 2 were done to provide some software that potential employees could download and try out as an example of my ability (also, they were fun to do). 3 was done to try to show to the world my interest and passion for what I do.4 was done because up until 2010 I only had my code saved on a hard drive which made swapping between laptops tedious. The last year has certainly been fun, and I've learned a lot of stuff.

For the next 12 months I am going to carrying on investigating functional programming. I still haven't got my head around monads! I have been playing around with the arduino board a lot recently to satisfy my low level programming itch that I can't satisfy at work. I want to try to get involved in an open source project this year as well, it would be good if I could combine this with the arduino work. I've spent the last few months looking, but haven't been able to settle on a a project. It would be nice to do that this year. Then there's also the matter of a couple of articles I have been writing that I want to publish. There's lots of stuff here to fit between work and family. So for the next year I would want to commit to:

1) Publish a blog entry or video that explains monads, teach someone at work how to use them.
2) Contribute to an open source project related to the arduino.
3) Finish one of my articles and submit it to some publishers for consideration to publish.

That seems about the right sort of level. Let's see how it goes

Friday, November 26, 2010

Currying in Ruby

I've spent the last month playing around with ruby, mostly because I feel I should. I'd like to share with you some cool things you can do with functions in Ruby 1.9. I discovered this by starting with a question.

In python, you could do this sort of thing.

def foo():
    return "bar"

x = foo

print x() # "bar"

In ruby you can call a function without brackets. So you can do:

def foo()
    return "bar"
end

puts foo # "bar"

My question was. How would you pass a function in ruby? This is one way:

def foo()
    return "foo"
end

x = lambda {foo}
puts x
puts x.call() # "foo"

Starting from humble beginnings. I wondered if I could use this mechanism for setting up a function with arguments that I could call later. The way you do this is quite intuitive.

def add(a,b)
    return a+b
end

y = lambda{add(3,2)}
puts y
puts y.call() # 5

From here its easy to think that currying in ruby must be very simple. It is!

def add(a,b)
    return a+b
end

plus = lambda {|a,b| add(a,b)}
curry_plus = plus.curry
plus_two = curry_plus[2]
puts plus_two[3] # 5