Three Monkeys, Three Typewriters, Two Days

April 21, 2008

Getting Shark to see headers in dist/

Dear Lazyweb,

Every so often, when I try to look at the source/assembly view in Shark it'll complain that it can't find the file at, say "../../../dist/content/nsINode.h". Ideally, I'd just tell it the directory relative to which these relative paths should be resolved. Any idea how to do it? Of course even more ideally it would Just Work without me having to do anything...

Posted by bzbarsky at 10:02 PM | Comments (0) | TrackBack (0)

April 16, 2008

Array.map + destructuring assignment = win

It's nice to write code sometimes unburdened by either C++ or performance considerations. It can just look so nice as a result!

function stringToURL(str) {
  return (new StandardURL(nsIStandardURL.URLTYPE_AUTHORITY, 80,
                         str, "UTF-8", null))
         .QueryInterface(Components.interfaces.nsIURL);
}

function pairToURLs(pair) {
  do_check_eq(pair.length, 2);
  return pair.map(stringToURL);
}

function test_setQuery()
{
  var pairs =
    [
     ["http://example.com", "http://example.com/?foo"],
     /* more pairs here */
    ].map(pairToURLs);
  for each (var [provided, target] in pairs) {
    /* Set the query and test for equality here */
  }
}
Posted by bzbarsky at 12:34 AM | Comments (2) | TrackBack (0)

April 14, 2008

Me N for N > 3

To go with this whole awk meme:

% history | awk '{a[$3]++ } END{for(i in a){print a[i] " " i}}' | sort -rn | head
37 latex
27 bibtex
13 cvs
4 ls
3 history
3 backupwork
2 xterm
2 emacs
2 clfiles
1 xdvi

Some notes:

Posted by bzbarsky at 9:41 PM | Comments (4) | TrackBack (0)