Freebase apps without cookies

August 9, 2007

Freebase just announced that

Within a week or so we will be removing the registration requirement in order to view Freebase.

Soon all my demo apps will work without requiring a Freebase invite. Cool!


Avoiding timeouts – Using MQL cursors with MJT

August 4, 2007

If you start to develop Freebase applications you then at some point you will inevitably see the error message “Query timeout”

For example, if you wanted to get a list of Musical Artists in Freebase you might try this query


But as there are almost 1/3 million artists in the database this query will timeout. That’s just as well, otherwise you would be loading a 30MB JavaScript file!

That was an extreme example, but as more users register with Freebase, my Map of Freebase Users occasionally timeouts. (It’s actually the MJT library which imposes the deadline here, not necessary the database which timeouts). Even if your application isn’t timing out, you find that your browser becomes unresponsive as it loads large JavaScript files from the database.

The solution is to use MQL cursors

I’ve created an example using MQL cursors in MJT which demonstrates a number of concepts:

  • Using MQL cursors
  • Calling MJT templates with arguments
  • Incremental queries (the page updates without reloading)

Auto-suggest with MJT – two demos

July 9, 2007

Nick’s demo

The latest version of MJT supports auto-complete. See Nick’s simple example.

Will’s demo

image Here’s my example (currently specific to films) Notice how the thumbnail updates as you navigate the menu 🙂 I had to add an extra ‘onchange’ hook, see source code for details.

Map of Freebase users – updated

July 9, 2007

I made some updates to my Map of Freebase Users (see old post and Freebase topic)

  • Lots more user photos (using /common/topic/image rather than picture_s)
  • Does not randomize if map location is unqiue (Thanks Dannyman!)
  • Disabled clustering – it seemed to be a performance hit. It’s easy to make maps with 1000’s of markers so I may have to reconsider this.
  • Markers are added to the to map in a separate thread. GUI is more responsive
  • Built-in error reporting
  • Code is now valid xhtml


  • Use cursors to make data-loading more responsive. This should also fix the timeouts that Dan reported.
  • IE support (but only if somebody bugs me)

MJT: Built-in bug reporting

July 9, 2007

I’m a big believer in built-in error reporting. When your app goes wrong, most users just give up and the ones who do report a bug tend to write things like “It doesn’t work”.

By building error reports into your app, your users can send detailed bug reports with just two clicks.

Here’s a self-destructing MJT app with error reporting.

Is there any interest in having this included in the MJT library? It could be My demo shows how it could be added to the template compiler and the the MQL task runner. (Updated: 21 Aug)

Editing MJT code with Emacs – nXhtmlMode

July 8, 2007

If you don’t use Emacs to write MJT code then stop reading now.

nXhtmlMode will dramatically improve your productivity if you write MJT code in Emacs. It highlights invalid XHTML as you type so you never have strange MJT bugs due to unclosed DIVs. You can also add a MJT schema to avoid unnecessary warnings about proprietary attributes.

Step by step guide to installing nXhtml mode

Install nXhtml:

  • Download the latest version of
  • Unzip into a directory, for example: ~/.emacs.d
  • Edit your .emacs and add
    (load "~/.emacs.d/nxml/autostart.el")
  • Run emacs, open an HTML file and type M-x nxhtml-mode

Accept the default customization:

  • Click “remove this message”
  • Set Nxhtml Skip Welcome: “toggle” to on
  • Click “Save for future sessions”
  • Click “Finish”

Install the MJT schema
(At this stage, any errors in your HTML should be highlighted. Unfortunately all the special MJT attrbitues will be highlighted as errors too. We can fix this by overriding the XHTML schema with a MJT schema)

  1. Download mjt.rnc
  2. Move mjt.rnc to ~/.emacs.d/nxml/nxml-mode-20041004/schema/
  3. Edit mjt.rnc and change the first line from
    include "emacs/lisp/nxml-mode/schema/xhtml.rnc"
    to this: include "xhtml.rnc"
  4. Load a MJT html file and type M-x nxhtml-mode. Check the mjt.task attributes are now accepted

Make nxhtml-mode load automatically on opening .html files
Add the following to your .emacs

;; nXhtml-mode
(load "~/.emacs.d/nxml/autostart.el")
;;WILL: there should be a cleaner way to do this

(fset 'html-helper-mode 'nxhtml-mode)
(fset 'html-mode 'nxhtml-mode)


Now whenever you open an HTML file with Emacs you will automatically see any markup errors. This can save a lot of debug time!

TODO: make multiple modes work so that mjt.script appears as formatted javascript inside an HTML file.

Thanks to Nick for the pointer to nxml-mode and to Jessica for prompting me to write this doc.

Please leave a comment if you try these steps. I’d like to know if it works for other people (or if you know a better way)

MapIt – a Freebase Google Maps builder (updated)

May 31, 2007

My latest version of MapIt has a better GUI. Less black-magic going on now.

Try it (probably Firefox only for now)

mapit builder

Building a query:
origin of rivers + image



Resulting mashup
showing Freebase rivers on Google Earth

Example maps:

Let me know if you manage to build any interesting maps. Feedback and bug reports very welcome.