Thursday, October 11, 2007

Cheating iLike on facebook

Sometimes my overcompetitive tendencies get the better of me. The latest time this happened was using iLike on Facebook.

This little application has a game called the iLike challenge where you have to guess the artist, or the song title while the song plays. The quicker you do it, the more points you get. You keep a running total of points as you guess the answers correctly, and then if you get an answer wrong your running total is reset down to zero. The application shows your best run, and shows you how your best run compares to your facebook friends.

I have a reasonable music knowledge, but not enough to make me top of my friends. Luckily, I've got the sort of hacker brain that likes breaking these sorts of puzzles.

It turns out that because the whole application is web based the programmers had to decide what to do if you lose the connection before your time runs out. They decided to keep your running score, and take you back to a random question.

This immediately gives you an advantage - if you get a question you don't know, just click away, then click back to iLike challenge. You will never get a question wrong, and can get as high a score as you like.

However, this can still be a bit slow, as you might get a lot of questions you don't know. But there is another trick. The application seems to give you repeated questions fairly often when you click back, probably due to a weakness in the random number generator. So each time you get a song you don't know, remember some of the lyrics. Google the lyrics to get the song title or artist. Then have the answer ready when the question comes round again.

I can't decide whether this is something I shouldn't be doing as a Christian. Do other people think this is dishonest? I enjoy finding these lateral thinking solutions to computer flaws more than I enjoy the original games, so it is a good form of entertainment for me. I think it only becomes dishonest if I boast I am the best at iLike, without saying how I did it.

Friday, August 03, 2007

Audio on Facebook

Yesterday I got back from a great week away, helping at a Christian Camp for teenagers. Everyone is on facebook nowadays, so of course a facebook groups was created, and I wanted to add all the talks that we had recorded to the facebook group so people could listen to them again if they wanted.

Unfortunately, a few days before, the facebook Audio application was removed for copyright violation reasons

Now the simplest thing would just be to host them on my own server, and then, post a link on the discussion board, but I thought I'd be clever, and I thought I'd detail my adventures with this post.

First I tried posting them as video - after all, audio is just video without pictures, right? Nope. Facebook video needs a recognised file type.

Next I thought that I could create a video, by using a single photo, and the audio as background. I found a free application "Slide show movie maker" which would do precisely this (it's designed for producing slide shows of pictures, with pretty music background), but in the end I could only get it to work with the PCM/WAV codec, so the movie was huge and it would have taken hours to upload to facebook video. Sigh.

I suspect I could do it with a commercial Adobe flash video producer or similar, but I got bored. I uploaded the audio to my own server, and posted a link in the discussion group.

Maybe facebook Audio will come back in a few days - before bandwidth/storage is too high on my host. Unless anyone has any better ideas?

Thursday, June 14, 2007

Getting Boost Python working under Cygwin

Having trouble getting Boost Python working under gcc/cygwin/windows? I did. And I found the documentation not that great, so here's a step by step guide to what I did to get it working. But for those of you in a hurry, here's the short method:

  1. Download boost from, decompress, and copy to whereever you want it

  2. Download boost jam (bjam) from, decompress, and copy to whereever you want it

  3. Add bjam to your path (Start, Control Panel, System, Advanced, Environment Variables) from whereever you put it in step 2

  4. Make sure you have gcc and python installed from cygwin setup, not just windows python from the python website

  5. Edit /boost_1_34_0/tools/build/v2/user-config.jam from wherever you decompressed boost to in step 1. Add the line:
    using python : 2.5 : c:\\cygwin\\bin\\python2.5 : : : cygwin ;

  6. Start a cygwin shell and change to where you put boost /libs/python/example/quickstart. In this directory type bjam toolset=gcc --verbose-test and everything should work

Now for how I did it, which will hopefully help a few people googling for the error messages that I got.

I downloaded boost and decompressed, and following the instructions at i also downloaded and installed bjam. So far, so good. On trying "bjam toolset=gcc --verbose-test" in the /libs/python/example/quickstart directory I got the following message:

$ bjam toolset=gcc --verbose-test

Jamroot:17: in modules.load

rule python-extension unknown in module Jamfile.

~/boost_1_34_0/tools/build/v2/build\project.jam:312: in load-jamfile

~/boost_1_34_0/tools/build/v2/build\project.jam:68: in load

~/boost_1_34_0/tools/build/v2/build\project.jam:170: in project.find

~/boost_1_34_0/tools/build/v2\build-system.jam:237: in load

~/boost_1_34_0\libs\python\example\quickstart\..\..\..\tools\build\v2/kernel\modules.jam:261: in import ~\boost_1_34_0\libs\python\example\quickstart\..\..\..\..\tools\build\v2/kernel/bootstrap.jam:132: in boost-build

~\boost_1_34_0\libs\python\example\quickstart\boost-build.jam:7: in module scope

Oh dear. A bit of googling found this page which told me I needed to add the line "using python ;" to the user-config.jam file. On trying to build again, I hit lots of compiler errors which started like:

In file included from C:/Python24/Include/Python.h:82,
from ../../../../boost/python/detail/wrap_python.hpp:142,
from ../../../../boost/python/detail/prefix.hpp:13,
from ../../../../boost/python/class.hpp:8,
from extending.cpp:5:
C:/Python24/Include/intobject.h:41: error: `__int64' does not name a type
In file included from C:/Python24/Include/Python.h:84,
from ../../../../boost/python/detail/wrap_python.hpp:142,
from ../../../../boost/python/detail/prefix.hpp:13,
from ../../../../boost/python/class.hpp:8,
from extending.cpp:5:
C:/Python24/Include/longobject.h:37: error: `__int64' was not declared in this s
C:/Python24/Include/longobject.h:39: error: `__int64' does not name a type
C:/Python24/Include/longobject.h:40: error: `__int64' does not name a type
C:/Python24/Include/longobject.h:41: error: `__int64' does not name a type
In file included from ../../../../boost/python/converter/arg_to_python.hpp:17,
from ../../../../boost/python/call.hpp:15,
from ../../../../boost/python/object_core.hpp:12,
from ../../../../boost/python/object/class.hpp:10,
from ../../../../boost/python/class.hpp:13,
from extending.cpp:5:
../../../../boost/python/converter/builtin_converters.hpp:111: error: missing `>
' to terminate the template argument list
../../../../boost/python/converter/builtin_converters.hpp:111: error: template a
rgument 1 is invalid

This was confusing.

Eventually gave me the hint I needed. I had a windows python 2.4 installation, and boost python seemed to need cygwin's python to work under cygwin. So using cygwin setup I installed python (and updated gcc) for good measure. Unfortunately still no luck. Finally the boost instructions at gave the final hint.

bjam toolset=gcc --debug-configuration --verbose-test revealed that boost was still picking up my old python from the registry. By doing of expressly putting the new cygwin python in /boost_1_34_0/tools/build/v2/user-config.jam , by modifying my "using python ;" line so it read "using python : 2.5 : c:\\cygwin\\bin\\python2.5 : : : cygwin ;" everything started working.

A happy ending...