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
{
“query”:[{
"id":null,
"limit":0,
"name":null,
"type":"/music/artist"
}]
}
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)
1 Comment |
cursors, example, freebase, mjt |
Permalink
Posted by Will Moffat
July 12, 2007
I’m working on a BBCode generating bookmarklet for Freebase data. I didn’t want to pollute online forums with lots of test posts so I whipped up my own BBCode live editor.
Type BBCode into the top textarea and the rendered HTML will appear after a second of inactivity.
There are other live editors on the web but since I’m running my own I can easily configure it to support the different dialects out there.
Will’s live editor in action:
- bolded text
- italicized text
- underlined text
- http://wikipedia.org
- Wikipedia

Leave a Comment » |
bbcode, freebase, php |
Permalink
Posted by Will Moffat
July 12, 2007
When I show developers Freebase and the query language MQL, the first thing they often try to do is extract all the info they can out of the database for a generic topic.
This is actually quite a good learning experience, as you have to learn lots of MQL concepts:
- How “*” expands (default values v objects, type specified or not)
- Multiple queries v nested queries
- Reflection
I had been keeping my own notes, but I thought they might be worth sharing so I whipped up a nice stylesheet and here they are:
Step by step MQL with Jimi Hendrix
Still lots of uncompleted TODO points but I’d be interested in your feedback. Is this something worth working on?
6 Comments |
doc, example, freebase, mql |
Permalink
Posted by Will Moffat
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
TODO:
- 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)
Leave a Comment » |
freebase, google maps, mjt |
Permalink
Posted by Will Moffat
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)
Leave a Comment » |
bugs, freebase, mjt |
Permalink
Posted by Will Moffat
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 nXhtml.zip
- 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)
- Download mjt.rnc
- Move mjt.rnc to ~/.emacs.d/nxml/nxml-mode-20041004/schema/
- Edit mjt.rnc and change the first line from
include "emacs/lisp/nxml-mode/schema/xhtml.rnc"
to this: include "xhtml.rnc"
- 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)
Conclusion
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)
3 Comments |
emacs, freebase, mjt, nxhtmlmode |
Permalink
Posted by Will Moffat