Planet Botfu

November 02, 2008

Alberto Simões (albie)

Victory - 1981

victory.png

Victory is an old movie about the second World War, and War prisoners that play Soccer. Nazi prepare a game against these prisoners in the occupied France (Paris). But the game gets complicated, with referee helping the German team. The Allied team had great players from all the occupied countries, and specially Pelé (well, and Sylvester Stallone). Everything ends well when the team escapes.

Now, is this movie good? I think there are few but good jokes, and some of the actors are good. Then, you can watch a movie and a soccer game all in one. So, you can't really complain.

I just would like to know how much of the game was prepared, and how much went naturally by the players in the field.

by null at November 02, 2008 06:10 PM

November 01, 2008

Alberto Simões (albie)

Live Free or Die Hard

MV5BMTEwOTE1NzUzODNeQTJeQWpwZ15BbWU3MDczODQ3NDE@._V1._SX94_SY140_.jpg

A lot of time since the last movie I got the time and state of mind to watch a movie. I was not needing any comedy or drama. Horror wasn't a choice as well. Thus, action woult it be. And Live Free or Die Hard was a good choice.

You know, knowing from the beginning this was a Hollywood like movie was a good thing. This way I know that the hero was not dying. Thus, I could concentrate on the action, laughing to the jokes, laughing of the stupidity of the technology shown (specially when showing local IPs, that are quite strange when dealing with the whole network), and wondering how Bruce Willis would get out of the situations.

Now, a final question arises... can that fight plane flight like that? Is that real? That's real cool!

by null at November 01, 2008 08:02 PM

October 22, 2008

Tim Riley (Safari_Al)

Using Markov Chains to provide English language seed data for your Rails application

I spent a portion of last weekend’s Rails Rumble preparing a script that would seed our application’s database with test data. Among other things, having a well populated database is useful to fully test all the parts of the application’s interface that might not come into play when using a smaller data set. It also gives you the ability to get a true sense of how your app will look and feel after the real users start to pour in content (hopefully!).

For the Rumble project, I used the faker Ruby gem, which provides methods for generating realistic names, domains and email addresses. It also provides a text generator that pulls random strings from Lorem Ipsum. However, while the app may feel have felt fully populated, seeing the Latin everywhere didn’t make it feel right.

So for the next project, I will generate random English language strings for the seed data. Rather than pulling words ad hoc from a dictionary or something, we can use Markov Chains to generate reasonably realistically structured text for us. A bit of searching revealed a Ruby Quiz page with an implementation of a text generator using Markov Chains. It explains that the generator:

read[s] some text document(s), making note of which characters commonly follow which characters or which words commonly follow other words (it works for either scale). Then, when generating text, you just select a character or word to output, based on the characters or words that came before it.

I took implementation provided on this page, and added a couple of convenience methods to easily fetch sequences of words or whole sentences:

# Courtesy of http://rubyquiz.com/quiz74.html

class MarkovChain
  def initialize(text)
    @words = Hash.new
    wordlist = text.split
    wordlist.each_with_index do |word, index|
    add(word, wordlist[index + 1]) if index = random
    end.first
    next_word
  end
  
  # Convenience methods to easily access words and sentences
  
  def random_word 
    @words.keys.rand
  end
  
  def words(count = 1, start_word = nil)
    sentence  = ''
    word      = start_word || random_word
    count.times do
      sentence  word  ' '
      word = get(word)
    end
    sentence.strip.gsub(/[^A-Za-z\s]/, '')
  end
  
  def sentences(count = 1, start_word = nil)
    word      = start_word || random_word
    sentences = ''
    until sentences.count('.') == count
      sentences  word  ' '
      word = get(word)
    end
    sentences
  end
end

Then, in my seed data script, I prime a MarkovChain instance with some good literature (I chose Sir Arthur Conan Doyle’s The Lost World from Project Gutenburg), and then use it to populate my records:

mc = MarkovChain.new(File.read("#{RAILS_ROOT}/db/populate_source.txt"))

# create_or_update method taken from http://railspikes.com/2008/2/1/loading-seed-data

1.upto(100) do |comment_id|
  Comment.create_or_update(
    :id => comment_id,
    :title => mc.words(3).titleize,
    :body => mc.sentences(3)
  )
end

Done! While the text isn’t the kind of fluent prose you’d expect from the real-life internet commenters, it does look much more realistic than Lorem Ipsum, and often provides cause for a bit of a chuckle. An example of the kind of stuff you’ll get from The Lost World is below. Feel free to choose your favourite text as the source :)

Luxurious voyage I had a solemnity as one would no sneer would have just after two surviving Indians in a precipice, and were accompanying to his thumb over his shoulders, the effort.

For some background on how to load seed data into your Rails app, see this page on the Rail Spikes blog for a good introduction.

October 22, 2008 01:41 PM

October 20, 2008

Tim Riley (Safari_Al)

For the win!

In the last 48 hours, two friends and colleagues and I laboured over a brand new web app, for our entry in this year’s Rails Rumble. The result is something we’re proud to share with you: Ideas FTW!.

Screenshot of Ideas FTW

We all have plenty of ideas, most of which we never have the opportunity to act on. Ideas FTW is an idea incubator that allows you to see your ideas come to life. You can vote on ideas, post your own, take up an idea and start an effort to achieve it on your own or in a group.

The site is simple and colourful, and will only become more fun to use as more ideas get added. So, please do sign up with your OpenID and empty your overflowing brains! I’m looking forward to seeing some interesting ideas fill the site.

Of course, the app is far from perfect yet. A few bugs slipped through and there are certainly a couple more key features we would like to add. If you have any suggestions for improving Ideas FTW, please feel free to leave a comment on our effort page.

Hugh, Michael and I all had a great time working together to create this site. We learnt a great many new things over the weekend and I am sure that I can speak for the others to say the lack of sleep was worth it. If you enjoy the site, please feel free to vote for us when the tallies open in a couple of days.

October 20, 2008 09:51 AM

October 18, 2008

Alberto Simões (albie)

God bless Yahoo

y3.gif

Google started a nice service that provided a remote API to perform queries. You need to register for a key, and each key was limited to 1000 queries a day. Unfortunately that ended, and now you can query using Google if you are writing a web application and want to access Google using some AJAX.

Fortunately, Yahoo! still exists. And Yahoo! has a remote API. And has some examples in Perl. And you do not need to register and get a private key (although you are encouraged to). And you really do not have any kind of limit on the number of queries.

You know, there is smoething more out of the web.

by null at October 18, 2008 09:31 PM

October 04, 2008

Alberto Simões (albie)

Miss Conception

MV5BMTU3MTcwNDc0Nl5BMl5BanBnXkFtZTcwNTk1MjA3MQ@@._V1._SX95_SY140_.jpg

Miss conception is just another comic movie with romance and some relations to sex and sex jokes. The 4.8 rating in IMDB might be a little harsh, but I wouldn't give it much more than 6.

There are jokes. There are nice girls. While Heather Graham has nice eyes and is blond, let me tell you that I feel Mia Kirshner a lot more attractive. Yes, the first is taller and thinner. But probably this has something to do with the Portuguese proverb: A mulher quer-se pequenina como a sardinha. Probably that is my point of view ;)

by null at October 04, 2008 07:42 PM