Medallia Blog

July 24, 2006

Norwegian Students in International Mathematical Olympiad

Not all students take the summer off! Some of them are not content with just having the summer exams, and are willing to spend a week having more tests and challenges.

The summer internship at Medallia includes quite varied work, and apart from writing interactive css graphs, I was this July as a deputy leader following the Norwegian IMO (International Mathematical Olympiad) Team, which this year was arranged in Ljubljana, Slovenia.

The IMO is the oldest one of the International Science Olympiads, where bright pupils from secondary schools all over the world meet to test their skills and to have fun. In the beginning (early sixties), the competition was held in Eastern Europe and featured mainly European countries, but in the last years, the competition has been held in Mexico, Greece, Japan, UK and South Korea. This years 47th IMO was arranged in Slovenia, and featured 90 countries and an astonishing number of 498 contestants.

NorwegianTeam.jpgThe Norwegian Team. From left: Børge Nordli (deputy leader), Jørgen Vold Rennemo, Atle Rygg Årdal, Aslanbek Sjamsutdinov, Nils (mascot), Espen Arild Jenssen, Knut Dagestad Rand, and Vidar Klungre.

Click on "READ FULL ENTRY" below for more details and pictures.

The official programme lasted from July 6th to July 18th, starting with the leaders selecting which problems to give. The contenstants (and me) arrived July 10th (eight hours late because of a reroute through Frankfurt), and the contest was held on July 12th and July 13th. The contest itself consists of six problems (three each day) with topics from number theory, algebra, combinatorics and geometry taught in general secondary schools. (Not always in Norway, though.) The problems are by no means solvable by any secondary school student, but requires exceptional mathematical abilities, knowledge and intuition to solve. Try for yourself: First day, Second day.

Then followed some day of coordination (grading). All national leaders must meet with coordinators and agree upon the contestants score. This can take some time, so the contestants have a lot of time to see the country and to make friends. Amongst other things, the contestants and leaders were shown the Slovenian cities of Portorož, Bled, Kranjska Gora, and of course Ljubljana.

Bled.jpg
Lake Bled, with the only (!) Slovenian island

Kranjska Gora.jpg
The Julian Alps of Kranjska Gora

Ljubljana.jpg
View of Prešeren Square (main square of Ljubljana, b.r.), Tivoli Park (u.l.) and surrounding scenery

The competition concluded July 17th with the closing ceremony at Cankarjev Dom, with closing speeches, awarding of the medalists, and local dance performance.

We went home early the next morning by plane via Prague.


The main goal for Norway in the IMO is to beat Sweden. The secondary goal is to beat all other Scandinavian and Nordic countries. The third goal is to have fun. I am sad to tell that we did not fulfill the two first goals (we only beat Denmark), but Jørgen brought home one fine Bronze Medal (best half), and Norway also got two Honourable Mentions (fully solved problem). The last goal was fully met, and I believe the last night was especially fun. (Picture from departure.)

ClosingCeremony.jpg
Norwegian Team after closing ceremony at Cankarjev Dom, fulfilling the last of the three goals

This year's score is around the norm for Norway. We have no chance to stand up against China (six gold medals (best 1/12)) and those getting an amazing 42 points (full score). I was very proud of the Norwegian contestants, and Jørgen was only 1 point away from getting a Silver Medal, still having two more years to participate! I myself participated in the IMO 2000 and 2001, without even getting an Honourable Mention, and it was very interesting to follow IMO from "the other side".

All in all, the trip was very rewarding, the students were great and had a lot of fun, and we all got inspired from the mathematical aura that surrounded this very well-organized event. More information and pictures available from IMO 2006 official home page.

I hope I will get the chance to be at the next IMO in Hanoi, Vietnam, and that Norway then will beat the Swedes.

July 17, 2006

From Web Page to Podcast

Autodiscover MP3 links as you browse and auto generate a Podcast RSS file you can import into a media player.
webtopodcast.jpg
Did you ever come across a web page with many MP3 links and wondered how to play those through iTunes, or with your MP3 player or iPod? If it's just one MP3 link, you can save the MP3 file to the desktop and then drag the file into your iTunes jukebox view. But what if there are 10 or 30 MP3 links? What a drag, literally, it would be to save each and import each into iTunes. Even if you did that, your files would then be scattered all over your player's library, rather than grouped into a simple, findable, titled structure, like the one your player's Podcast area provides.

A much cooler approach for playing a web page's audio files through your media player would be to have your browser detect the sound files on any web page and automatically generate a single Podcast file, which contains links to all those MP3s your browser found. Then you'd only need to import the one file into your Podcast player and you're good to go.

This hack does just that by integrating various technologies including the Firefox browser, Greasemonkey, tabs, Javascript, MP3, XML, XPath, RSS, DOM, regular expressions, CSS, a local web server and your favorite Podcast media player (e.g. iTunes).

Already know how to use Greasemonkey? Want to hack the hack?


  1. Turn on Greasemonkey (you must be using the Firefox browser of course)
  2. Load & activate the Greasemonkey script webpagetopodcast.user.js
  3. Visit any web page with sound file links.
  4. If MP3s are found, the script will display a small yellow box in the upper right corner, which indicates how many MP3 files were found and a link.
  5. Click on the link to open a new browser tab which contains your Podcast RSS XML file.
  6. Save that file to your local web server (e.g. the ~/Sites directory on Mac OS X)
  7. Import the RSS file into your Podcast reader, then drag items to your MP3 player, and you're ready to go.

I tested this script on various web pages which had MP3s scattered in various DOM arrangements and various sound file link labeling approaches. Much of the effort went into extracting what seemed like a good label for the sound file, ignoring hyperlink text such as "listen" or "play", which wouldn't make any sense in a Podcast reader. Perhaps you can find a better approach than my hack uses.

It tested well on the following examples:

Note: This script is intended for use with publically hosted and web accessible MP3's
and the resulting podcast file is intended for personal use only. To use this
script, you must visit the original publisher's web page. The functionality
contained here merely creates a link to the original content, arranged in an
XML format, and allows playback through your computer. There is no
physical difference created or implied as compared to merely playing the hosted
MP3 file with your computer's media player. The script only helps you to
categorize the audio in the convenient podcast format for local personal use.
The audio content itself is copyright by the producer of the web page through
which the original audio files are hosted.

Click on "READ FULL ENTRY" below for more details and explanation on Greasemonkey and Podcasts.

New to Greasemonkey and Podcasts? How does it work?
Greasemonkey was created by Aaron Boodman to make the web a better place. Greasemonkey is a Firefox extension that lets you augment any web page with your own Javascript. Besides handling the Javascript and DOM manipulation features, Greasemonkey provides powerful utilities that take advantage of the Firefox browser's features such as tabs and XPath. Greasemonkey also provides the ability to make Ajax type HTTP requests, but to any server.

A Podcast is an XML text file, written in the RSS format, which contains titles, descriptions and links to MP3 or sound files. And because a Podcast file follows a standard format, there are a variety of media players that support Podcasts. I like using the iTunes player, and although they've done some odd things to extend the RSS format to suit their player, I find iTunes to be a well thought out interface, and it's the only one through which I can update my iPod. Note that the words or technical concepts of "iPod" and "Podcast" have nothing to do with each other. A Podcast can be played on any media player which supports the Podcast RSS XML format.

More detailed Instructions:


  1. Install the Greasemonkey extension for Firefox. The extension is available at: https://addons.mozilla.org/firefox/748
  2. Be sure the little monkey icon on the bottom right corner of your browser is enabled.
  3. Load the Greasemonkey script "Web Page to Podcast" script and enable it by clicking here: webpagetopodcast.user.js. (I recommend to right click on this link and open it in a new tab). Click on the Install button that appears in the upper right.
  4. Surf to a web page that has some MP3 links. First, visually check for a Podcast link on the web page, as the author may have already created one for you. Look for a small orange RSS or XML button, or a link which says "Podcast". If you find such a link, click on it and skip ahead to step 10.
  5. If the script finds any MP3 links, it will display a little yellow box near the upper right corner, indicating how many MP3 links were found.
  6. Click on the link in the little yellow box, and a new tab will be created, containing a full Podcast RSS/XML file for your web page's MP3s.
  7. Click on the new tab and save the new tab by using the browser's File > Save As, to a local web server directory you can reach with a hyperlink starting with http://localhost....   On Mac, simply save it to your ~/Sites directory (the default Apache server location). Use an .xml extension. (if you're on a PC, check with a PC expert on the best approach to saving to/running a local web server.)
  8. The script makes an attempt to extract the best descriptive title for each MP3 link. Occasionally, it will not do a good job. In this case, simply edit the file's <title> XML elements as needed.
  9. Ensure that your web server is running. On Mac OS X, goto System Preferences > Sharing > Services and click on Personal Web Sharing and click "Start" (if it's already running, the button says "Stop").
  10. If you use iTunes, start it up and find the menu along the top and goto Advanced, Subscribe to podcast, and paste or type in the URL of your saved Podcast XML file. On Mac, that might be something like http://localhost/~al/samplepodcast.xml. And that's it.. iTunes will load a new item under the Podcasts section, and automatically load the first MP3. You can load the other MP3s in that Podcast by clicking on the tiny "GET" icon.
  11. If you use another Podcast player, it should have some utility for you to paste in a Podcast URL.
  12. If the MP3 titles are not adequate or distinct, go back to the saved Podcast file with your text editor and alter the <title> element contents. And import it to your media player again.
  13. Once the MP3 files are in iTunes, attach your iPod and drag and drop to your device as you like.
  14. You don't need to keep Greasemonkey active in your browser. But next time you see some MP3s on a web page, click on the little monkey, and refresh the web page. This Web Page to Podcast script will autodiscover all the MP3s.

The possibilities with Greasemonkey are endless. I hope this script can be a helpful source for your future Greasemonkey hacks. Check in with us in the future for more scripts.

Reference:

Greasemonkey download for Firefox
http://greasemonkey.mozdev.org

Mozilla Javascript Reference
http://devedge-temp.mozilla.org/central/javascript/index_en.html

Massive Greasemonkey script library
http://userscripts.org

Greasemonkey community's discussion forum
http://www.mozdev.org/pipermail/greasemonkey

Free Greasemonkey scripting eBook
http://diveintogreasemonkey.org

Greasemonkey Hacks book
http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?z=y&isbn=0596101651&itm=1

Aaron Boodman's home page (creator of Greasemonkey)
http://youngpup.net

Greaseblog blog
http://greaseblog.blogspot.com

Couple of presentations by Aaron Boodman, creator of Greasemonkey
http://greaseblog.blogspot.com/2005/12/slides-from-nov-8-emerging-technology_02.html
http://greaseblog.blogspot.com/2005/08/aarons-oscon-2005-slides.html

Greasemonkey API (let's you do things a normal web page cannot)
http://diveintogreasemonkey.org/api/index.html

Probably the most famous Greasemonkey script (now a Firefox extension)
http://bookburro.org

Podcasting
http://en.wikipedia.org/wiki/Podcast

RSS
http://en.wikipedia.org/wiki/RSS_%28file_format%29
http://blogs.law.harvard.edu/tech/rss

Juice - Podcast Receiver (formerly called iPodder)
http://juicereceiver.sourceforge.net/

RSSRadio
http://www.dorada.co.uk

How to find Podcasts
http://lifehacker.com/software/top/technophilia-find-great-podcasts-183411.php

Happy hacking..
Al Nevarez
Product Manager & weekend hacker