<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>A box full of good experiments.</description><title>143th.net</title><generator>Tumblr (3.0; @143th)</generator><link>http://143th.net/</link><item><title>BXR - my implementation of mxr</title><description>&lt;p&gt;I would like to share with you a new tool, which was written over the weekend: &lt;a href="https://github.com/bakulf/mxr"&gt;bxr&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This tool implements a subset of the functionalities of mxr.mozilla.org using a local database and it can be used as a standalone application or combined with vim.&lt;/p&gt;

&lt;p&gt;This is how I use it:&lt;/p&gt;

&lt;pre&gt;
$ cd ~/Sources/m/central # this is a checkout of mozilla-central
$ bxr create .
&lt;/pre&gt;

&lt;p&gt;With this command, bxr indexes the source tree and creates the database (&lt;em&gt;.bxr.db&lt;/em&gt;). This operation should be done each time the tree is updated. It takes about 25 minutes.&lt;/p&gt;

&lt;p&gt;Then, for searching, just type:&lt;/p&gt;

&lt;pre&gt;
$ bxr identify nsIDOMFile

Result for: nsIDOMFile

File: ./content/base/public/nsDOMFile.h
Line: 37 -&amp;gt; class nsDOMFileBase : public nsIDOMFile,

File: ./ipc/glue/InputStreamUtils.cpp
Line: 14 -&amp;gt; #include "nsIDOMFile.h"
....
&lt;/pre&gt;

&lt;p&gt;At the moment BXR can be used to:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;strong&gt;identify&lt;/strong&gt;, to search for the definitions of particular functions, variables, etc. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;search&lt;/strong&gt;, to search in the source code. &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;file&lt;/strong&gt;, to find files whose name matches a pattern&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;I love working with this tool alongside vim using a &lt;a href="https://github.com/bakulf/mxr/blob/master/bxr.vim"&gt;plugin&lt;/a&gt;.
This allows me to do:&lt;/p&gt;

&lt;pre&gt;
:BI nsIDOMFile
:BF ArchiveReader
:BS ArchiveReader::V
&lt;/pre&gt;

&lt;p&gt;This app is just an experiment. I am still working on it. What I want to do is to reduce the size of the database (right now 800~Mb are required for indexing mozilla-central…). I hope to have something stable and usable soon!&lt;/p&gt;</description><link>http://143th.net/post/40519528783</link><guid>http://143th.net/post/40519528783</guid><pubDate>Mon, 14 Jan 2013 15:51:00 +0100</pubDate></item><item><title>Transferable objects for FF</title><description>&lt;p&gt;A short introduction: if you want to send data to/from a &lt;a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html"&gt;Web Worker&lt;/a&gt;, you have to use &lt;strong&gt;postMessage()&lt;/strong&gt; method. Internally what happens is that the data is duplicated using the &lt;a href="https://developer.mozilla.org/en-US/docs/DOM/The_structured_clone_algorithm"&gt;structured cloned algorithm&lt;/a&gt; and then the copy is sent.&lt;/p&gt;

&lt;p&gt;To make this sharing faster, HTML5 specs add a new concept: transferable objects, data is transferred from one context to another &lt;strong&gt;without copy&lt;/strong&gt;. Note: data is no longer available once transferred to the new context. Right now we can transfer just ArrayBuffers, but maybe in the future we will support other data types.&lt;/p&gt;

&lt;p&gt;I wrote this patch  (&lt;a href="https://bugzilla.mozilla.org/show_bug.cgi?id=720083"&gt;Bug 720083&lt;/a&gt;) and it will be available in the nightly build soon. Here a demo/benchmark app: &lt;a href="https://people.mozilla.com/~amarchesini/code/transferrable/"&gt;demo&lt;/a&gt;. Here another one: &lt;a href="http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fast"&gt;demo2&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Have fun!&lt;/p&gt;</description><link>http://143th.net/post/32874476488</link><guid>http://143th.net/post/32874476488</guid><pubDate>Thu, 04 Oct 2012 17:24:36 +0200</pubDate></item><item><title>Archive API for DOM Blob!</title><description>&lt;p&gt;I&amp;#8217;m glad to present my first DOM API: The &lt;strong&gt;ArchiveReader&lt;/strong&gt;. This new object allows to open ZIP files and read the content from javascript. Here the webIDL:&lt;/p&gt;

&lt;pre&gt;
interface ArchiveRequest : DOMRequest
{
  [infallible]
  readonly attribute ArchiveReader reader;

  // In case of a getFilenames() request, the result is an array of DOMString
  // In case of a getFile() request, the result is a DOM File
}

[Constructor(Blob blob)]
interface ArchiveReader
{
  ArchiveRequest getFilenames();
  ArchiveRequest getFile(DOMString filename);
};
&lt;/pre&gt;

&lt;p&gt;Ok, maybe this is not clear enough&amp;#8230; an example is better: &lt;a href="http://people.mozilla.com/~amarchesini/code/archivereader_example.html"&gt;archivereader_example.html&lt;/a&gt; (keep in mind that this is a new API and it is just landed in the latest &lt;a href="http://nightly.mozilla.org/"&gt;firefox nightly build&lt;/a&gt; so probably it won&amp;#8217;t work with your browser).&lt;/p&gt;

&lt;p&gt;The use of this API is extremely simple:
* Create a new &lt;strong&gt;ArchiveReader&lt;/strong&gt; starting from a &lt;a href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-Blob"&gt;DOM blob&lt;/a&gt; or a &lt;a href="http://dev.w3.org/2006/webapi/FileAPI/#dfn-file"&gt;DOM file&lt;/a&gt;. 
* Use &lt;strong&gt;getFile()&lt;/strong&gt; or &lt;strong&gt;getFilenames()&lt;/strong&gt;. The return value of these two methods is an &lt;strong&gt;ArchiveRequest&lt;/strong&gt; object.&lt;/p&gt;

&lt;p&gt;Note: This API is completely asynchronous.&lt;/p&gt;

&lt;pre&gt;
var blob = ...;
var reader = ArchiveReader(blob);

// how to extract the list of files contained in the archive:
var h = reader.getFilenames();
h.onerror = function() { ... }
h.onsuccess = function() {
  for (var i = 0; i &amp;lt; this.result.length; ++i) {
    something(this.result[i]); // this.result[i] is a DOMString
  }
}

// how to extract a specific file:
var hf = reader.getFile('image.png');
hf.onerror = function() { ... }
hf.onsuccess = function() {
  // this.result is a DOM File
  alert('Filename: ' + this.result.name + '\n' +
        'ContentType: ' + this.result.type + '\n' +
        'Size: ' + this.result.size);
}
&lt;/pre&gt;

&lt;p&gt;The result of a getFile() is a DOM File and it can be used in many ways: FileReader, ArchiveReader, window.URL, etc. Read the example to see how to show images and plain/text files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: this API is a draft. Any update will be posted on &lt;a href="https://wiki.mozilla.org/WebAPI/ArchiveAPI"&gt;https://wiki.mozilla.org/WebAPI/ArchiveAPI&lt;/a&gt;&lt;/p&gt;</description><link>http://143th.net/post/29712990244</link><guid>http://143th.net/post/29712990244</guid><pubDate>Sat, 18 Aug 2012 23:34:00 +0200</pubDate><category>mozilla</category><category>API</category></item><item><title>MXR, a command-line tool for mxr.mozilla.org</title><description>&lt;p&gt;My fist post is about a tool that I wrote last weekend. It&amp;#8217;s a command-line interface for &lt;a href="http://mxr.mozilla.org"&gt;MXR website&lt;/a&gt; (Mozilla Cross-Reference) written in Ruby. Here the code: &lt;a href="https://github.com/bakulf/mxr"&gt;https://github.com/bakulf/mxr&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I love MXR and I think it&amp;#8217;s an extremely important resource for all the mozillian&amp;#8217; developers.
It is a useful web application, however sometimes it&amp;#8217;s preferable to have a command-line interface when using a &lt;a href="https://github.com/bakulf/bterm"&gt;terminal&lt;/a&gt; and working on a piece of code.&lt;/p&gt;

&lt;p&gt;Here the list of features:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;it supports any feature of the MXR website: &lt;strong&gt;identify&lt;/strong&gt;, &lt;strong&gt;search&lt;/strong&gt;, &lt;strong&gt;file&lt;/strong&gt;, &lt;strong&gt;browse&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;it works in shell mode too.&lt;/li&gt;
&lt;li&gt;It colourizes the output (&lt;strong&gt;-c&lt;/strong&gt; option)&lt;/li&gt;
&lt;li&gt;It guesses the right operation to do (it means that you can write &amp;#8216;identify&amp;#8217; or &amp;#8216;ident&amp;#8217;, or &amp;#8216;ide&amp;#8217; or &amp;#8216;i&amp;#8217;)&lt;/li&gt;
&lt;li&gt;In shell mode it offers an easy way to browse the source code using the ID shown by the previous command. Example:&lt;/li&gt;
&lt;/ul&gt;&lt;pre&gt;
mxr&amp;gt; i nsIDOMFile
Result for: nsIDOMFile

File: (0) content/base/public/nsIDOMFile.idl
Line: (1) 65 -&amp;gt; interface nsIDOMFile : nsIDOMBlob   
    
File: (2) content/base/src/nsFormData.h
Line: (3) 14 -&amp;gt; class nsIDOMFile;  
...
mxr&amp;gt; b 1
&lt;/pre&gt;

&lt;p&gt;&amp;#8230;and the file nsIDOMFile.idl line 65 will be shown.&lt;/p&gt;

&lt;p&gt;That&amp;#8217;s it. It &lt;a href="http://codinghorror.typepad.com/.a/6a0120a85dcdae970b0128776ff992970c-pi"&gt;works on my machine&lt;/a&gt; and I&amp;#8217;m happy with it. Patches are appreciated :)&lt;/p&gt;</description><link>http://143th.net/post/28840505249</link><guid>http://143th.net/post/28840505249</guid><pubDate>Mon, 06 Aug 2012 18:04:00 +0200</pubDate><category>mozilla</category><category>ruby</category></item></channel></rss>
