<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Michael Yoshitaka ERLEWINE (mitcho)</title>
    <description></description>
    <link>http://mitcho.com/</link>
    <atom:link href="http://mitcho.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Thu, 29 Oct 2026 23:39:08 +0200</pubDate>
    <lastBuildDate>Thu, 29 Oct 2026 23:39:08 +0200</lastBuildDate>
    <generator>Jekyll v4.4.1</generator>
    
      <item>
        <title>Stamping PDFs in bulk</title>
        <description>&lt;p&gt;I recently put &lt;a href=&quot;https://lingconf.com/glowinasia2017/program/&quot;&gt;the program and abstracts&lt;/a&gt; online for the &lt;a href=&quot;https://lingconf.com/glowinasia2017/&quot;&gt;GLOW in Asia&lt;/a&gt; conference that we’re hosting in Singapore next February. In my experience, conference abstract PDFs easily come up on web searches and you want it to be immediately obvious whose work it is. Some conferences ask for updated abstracts with author names, but I didn’t want to deal with that. I instead chose to programmatically “stamp” each abstract PDF with the author names. Here are my notes on how I did that.&lt;/p&gt;

&lt;h2 id=&quot;adding-text-to-a-single-pdf&quot;&gt;Adding text to a single PDF&lt;/h2&gt;

&lt;p&gt;First, I had to figure out how to add some text to a PDF from the command line. I followed &lt;a href=&quot;http://www.commandlinefu.com/commands/view/9984&quot;&gt;these useful instructions&lt;/a&gt;. For me, this involved installing the &lt;code&gt;enscript&lt;/code&gt; utility (which I did using Homebrew: &lt;code&gt;brew install enscript&lt;/code&gt;), which can create simple PostScript from plain text, and &lt;a href=&quot;https://www.pdflabs.com/tools/pdftk-server/&quot;&gt;PDFtk server&lt;/a&gt;, which is a neat command line package for manipulating PDFs. The PDFtk website doesn’t link to the latest build but I found some discussion which helpfully posted &lt;a href=&quot;https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg&quot;&gt;the link to the latest build&lt;/a&gt; which installed cleanly on Sierra.&lt;/p&gt;

&lt;p&gt;With these installed, you can add a line of text to the top of an existing PDF as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;echo &quot;text to add&quot; | enscript -B -f Helvetica12 -o- | ps2pdf - | pdftk in.pdf stamp - output out.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;where &lt;code&gt;in.pdf&lt;/code&gt; is the original PDF and &lt;code&gt;out.pdf&lt;/code&gt; is what will be written. I played around briefly with font options, but Helvetica 12 looked fine for my purposes. You’ll notice that I’ve done nothing to specify &lt;em&gt;where&lt;/em&gt; the text should be stamped on the PDF. While this can probably be controlled (probably by learning some PostScript), the default output was good enough so I went with it.&lt;/p&gt;

&lt;p&gt;(I’m not thrilled about relying on this free but closed-source PDFtk tool, and perhaps that step will stop working with future OS updates… If you know of another way to stamp PDFs from the command line, please do share!)&lt;/p&gt;

&lt;p&gt;Once I figured this part out, now I just needed to write a quick script to automate the process of applying this to the dozens of PDFs that I wanted to put online.&lt;/p&gt;

&lt;h2 id=&quot;programmatically-adding-text-to-multiple-pdfs&quot;&gt;Programmatically adding text to multiple PDFs&lt;/h2&gt;

&lt;p&gt;What you get from EasyChair is a folder full of PDFs which are (or should be) anonymous and are organized by EasyChair ID.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;easychair.png&quot; alt=&quot;original PDFs&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I created a csv file with three columns:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;EasyChair ID number (to find the right abstract PDF)&lt;/li&gt;
  &lt;li&gt;Desired filename (lowercased family names with hyphens, using &lt;em&gt;-etal&lt;/em&gt; for more than two authors)&lt;/li&gt;
  &lt;li&gt;Author names&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I easily pulled columns 1 and 3 from the EasyChair website and quickly added in the second column. All of these fields are in plain text. Here’s what that looked like:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;ids.png&quot; alt=&quot;a csv with id information&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I wrote &lt;a href=&quot;https://gist.github.com/mitcho/26f3376da07b65e1872227176574ceda&quot;&gt;&lt;strong&gt;this python script&lt;/strong&gt;&lt;/a&gt; which takes such a csv file, goes to find the appropriate PDF from the folder full of EasyChair abstracts, stamps the author names and “GLOW in Asia XI” on it, and saves it into another folder with the desired file name. In a matter of seconds, I had a folder full of de-anonymized abstracts, which I then put online:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;result.png&quot; alt=&quot;the resulting files&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;the-results&quot;&gt;The results&lt;/h2&gt;

&lt;p&gt;You can see the resulting PDFs by looking at some of the abstracts on the &lt;a href=&quot;https://lingconf.com/glowinasia2017/program/&quot;&gt;the GLOW in Asia program&lt;/a&gt;. The results aren’t beautiful — for some abstracts, the placement of the text isn’t very pretty, and it definitely has a “robotically stamped” quality — but it did save me a heck of a lot of time.&lt;/p&gt;
</description>
        <pubDate>Sat, 19 Nov 2016 00:00:00 +0200</pubDate>
        <link>http://mitcho.com/blog/how-to/stamp-pdfs/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/how-to/stamp-pdfs/</guid>
        
        <category>pdf</category>
        
        <category>code</category>
        
        
        <category>how-to</category>
        
      </item>
    
      <item>
        <title>Generating individual figure images in LaTeX</title>
        <description>&lt;p&gt;I’m excited that &lt;a href=&quot;http://ling.auf.net/lingbuzz/002806&quot;&gt;my paper with Isaac Gould on Japanese relative clauses&lt;/a&gt; will appear soon in &lt;a href=&quot;http://www.glossa-journal.org/&quot;&gt;&lt;em&gt;Glossa&lt;/em&gt;&lt;/a&gt;. Isaac and I wrote this paper in Word, although I composed all the trees and some diagrams in LaTeX (about two dozen). Here’s what my file looked like, where I typeset these diagrams. I then simply copied and pasted rectangular selections of this PDF into Word.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;trees.png&quot; alt=&quot;original diagrams PDF&quot; /&gt;&lt;/p&gt;

&lt;p&gt;As we prepared the manuscript for typesetting, though, I felt like I should make proper, high quality images for these trees and diagrams. Here for my own future reference is how I did this.&lt;/p&gt;

&lt;h2 id=&quot;setting-the-diagrams-in-fira-sans&quot;&gt;Setting the diagrams in Fira Sans&lt;/h2&gt;

&lt;p&gt;My diagrams for the paper were all in one LaTeX file. The &lt;em&gt;Glossa&lt;/em&gt; style sheet asks that diagrams be set in Arial or &lt;a href=&quot;https://en.wikipedia.org/wiki/Fira_Sans&quot;&gt;Fira Sans&lt;/a&gt;, the latter being Mozilla’s &lt;a href=&quot;https://en.wikipedia.org/wiki/FF_Meta&quot;&gt;FF Meta&lt;/a&gt;-inspired open-source font, which is the sans-serif used for abstracts and titles in &lt;em&gt;Glossa&lt;/em&gt; papers. (By the way, &lt;em&gt;Glossa&lt;/em&gt; sets its body text in &lt;a href=&quot;https://en.wikipedia.org/wiki/Charis_SIL&quot;&gt;Charis SIL&lt;/a&gt;.) I started by getting my diagrams set in Fira Sans, which was easy in my setup:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Download &lt;a href=&quot;https://github.com/mozilla/Fira&quot;&gt;Fira Sans&lt;/a&gt; and install it on my Mac. Double-clicking on the &lt;code&gt;otf&lt;/code&gt; files will let you install them.&lt;/li&gt;
  &lt;li&gt;Add the following lines to the preamble. This requires that the file be compiled using XeLaTeX, the unicode-native LaTeX engine that can use system fonts. I generally always use XeLaTeX and &lt;code&gt;mathspec&lt;/code&gt;, so this was easy.
    &lt;pre&gt;&lt;code class=&quot;language-latex&quot;&gt;\usepackage{mathspec}
\setallmainfonts{Fira Sans}
&lt;/code&gt;&lt;/pre&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;putting-a-diagram-on-each-page-with-preview&quot;&gt;Putting a diagram on each page with &lt;code&gt;preview&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;Next, I wanted to get my diagrams file to output just one diagram per page. I could of course set &lt;code&gt;\pagestyle{empty}&lt;/code&gt; and add page breaks, but I chose to use the &lt;a href=&quot;http://ftp.math.purdue.edu/mirrors/ctan.org/macros/latex/contrib/preview/preview.pdf&quot;&gt;&lt;code&gt;preview&lt;/code&gt; LaTeX package&lt;/a&gt; which is designed for this purpose. First, I added the following to my preamble. The &lt;code&gt;xetex&lt;/code&gt; option is of course because I’m compiling using XeLaTeX.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-latex&quot;&gt;\usepackage[xetex,active,tightpage]{preview}
\PreviewBorder=40pt\relax
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I then wrapped each logical diagram in its own &lt;code&gt;preview&lt;/code&gt; environment. Here’s an example:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-latex&quot;&gt;\begin{preview}
\Tree [.TP Ayaka [ peeled [.DP [.D every ] [.NP apple ] ] ] ]
\end{preview}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The advantage of using &lt;code&gt;preview&lt;/code&gt; is that, when compiled in &lt;code&gt;active&lt;/code&gt; mode, all other information printed outside of these &lt;code&gt;preview&lt;/code&gt; environments are simply not printed. The result at this stage is a single PDF with one diagram on each page. Notice how each diagram has a margin; the &lt;code&gt;\PreviewBorder&lt;/code&gt; command above requested that these margins be at least 40 points on each side. Notice also that the margins for the second diagram are confused by my use of TikZ for drawing the arrow; these individual pages will later get cropped so this isn’t a problem.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;individual.png&quot; alt=&quot;PDF with individual diagrams&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;pulling-out-each-diagram-into-its-own-image-file&quot;&gt;Pulling out each diagram into its own image file&lt;/h2&gt;

&lt;p&gt;Finally, I used the ImageMagick &lt;code&gt;convert&lt;/code&gt; command to split up the PDF into individual image files. (I installed ImageMagick on my Mac using &lt;a href=&quot;http://brew.sh/&quot;&gt;HomeBrew&lt;/a&gt;: &lt;code&gt;brew install imagemagick&lt;/code&gt; .) Here’s the command I ran, in the same folder as the output file, &lt;code&gt;trees.pdf&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-latex&quot;&gt;convert -density 900 -trim -resample 300 trees.pdf figure.png
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The result of this command is a sequence of &lt;code&gt;figure-0.png&lt;/code&gt;, &lt;code&gt;figure-1.png&lt;/code&gt;,… files being generated, one per page of the &lt;code&gt;trees.pdf&lt;/code&gt; file. Here’s the first file:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;figure-0.png&quot; alt=&quot;figure-0&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This image might look large here because it’s rendered in 300 points per inch (ppi), which is a standard print density that &lt;em&gt;Glossa&lt;/em&gt; requests rasterized images to be in. &lt;code&gt;convert&lt;/code&gt; rendered this page on a transparent background and then cropped its margins (the &lt;code&gt;-trim&lt;/code&gt; option). We then referenced each figure by name in our Word file and sent it in to &lt;em&gt;Glossa&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Notice that my &lt;code&gt;convert&lt;/code&gt; command renders each page in 900ppi and then downsamples this to 300ppi. That’s because I first tried &lt;code&gt;convert -density 300&lt;/code&gt; directly, and it resulted in some jagged edges. This will be even more visible if you have diagrams with finer details. Rendering at 900ppi and then downsampling to 300ppi has the effect of &lt;a href=&quot;https://en.wikipedia.org/wiki/Spatial_anti-aliasing&quot;&gt;anti-aliasing&lt;/a&gt;.&lt;/p&gt;

</description>
        <pubDate>Sat, 01 Oct 2016 00:00:00 +0300</pubDate>
        <link>http://mitcho.com/blog/how-to/latex-figure-images/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/how-to/latex-figure-images/</guid>
        
        <category>latex</category>
        
        <category>code</category>
        
        
        <category>how-to</category>
        
      </item>
    
      <item>
        <title>On floating, raising, and &lt;em&gt;being&lt;/em&gt;</title>
        <description>&lt;p&gt;The distribution of &lt;em&gt;floating quantifiers&lt;/em&gt; (FQs) has formed an important diagnostic for intermediate subject positions. Sportiche (1988) proposes that FQs are generated together with the subject and can then be &lt;em&gt;stranded&lt;/em&gt; when the subject is moved. However, it is not the case that FQs can occupy any position that we expect the subject to have passed through. For example, FQs are not allowed immediately after the auxiliary &lt;em&gt;being&lt;/em&gt; in a progressive passive sentence (see Harwood, 2011; Bošković, 2013; and references therein):&lt;/p&gt;

&lt;p&gt;(1)	We could (✓all) have (✓all) been (✓all) being (&lt;strong&gt;*all&lt;/strong&gt;) punished (*all) for our crimes (*all).	(based on Harwood, 2011)&lt;/p&gt;

&lt;p&gt;Previous work has proposed to account for this pattern by requiring that FQs adjoin to the subject only after a certain point in the derivation. For example, for Bošković (2004), FQs cannot be adjoined to an argument in its theta-position; for Harwood (2011), an FQ cannot be adjoined until the end of the construction of a phase. Once the FQ has adjoined to the subject, it can be stranded in any higher position that the subject moves through. These approaches therefore predict a bifurcation, where FQs can appear above a certain point, but not below it.&lt;/p&gt;

&lt;p&gt;Not discussed in this context, however, are cases of passives of ECM verbs, which function as subject-raising predicates. In these cases, FQs are rejected after &lt;em&gt;being&lt;/em&gt; in the higher clause, but &lt;em&gt;are allowed in the lower nonfinite embedding&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;(2)	The students are (✓all) being (&lt;strong&gt;*all&lt;/strong&gt;) {expected/predicted} to (&lt;strong&gt;✓all&lt;/strong&gt;) finish their dissertations in time.&lt;/p&gt;

&lt;p&gt;One complication affecting examples such as (2) is that some speakers judge progressives of ECM passives and raising predicates more generally as marked. However, naturally occurring examples show that such constructions are possible and that they are indeed raising constructions, as diagnosed by idiom chunk interpretation:&lt;/p&gt;

&lt;p&gt;(3)	“And of course the shit could hit the fan at any time - but the shit is being predicted to hit the fan constantly and has been for years.” (naturally occurring example from http://www.davidicke.com/forum/showthread.php?p=1060803118)&lt;/p&gt;

&lt;p&gt;Example (2) is an important data point for analyses of FQ. The distribution of FQ in (2) is unexpected under a view where, once an FQ is merged, it can be stranded in any higher intermediate position. The inability of FQs to follow &lt;em&gt;being&lt;/em&gt; in (1–2) therefore must be due to an independent ban on FQ in this post-&lt;em&gt;being&lt;/em&gt; position. Assuming the basic stranding approach to FQ (Sportiche, 1988), we learn that this position is special in that either (a) the subject does not land in an intermediate position immediately following &lt;em&gt;being&lt;/em&gt; or (b) FQs are not allowed to be stranded there.&lt;/p&gt;

&lt;h3 id=&quot;references&quot;&gt;References:&lt;/h3&gt;

&lt;p&gt;Bošković, Željko. 2004. Be careful where you float your quantifiers. Natural Language and Linguistic Theory 22. 681–742.&lt;/p&gt;

&lt;p&gt;Bošković, Željko. 2013. Now I’m a phase, now I’m not a phase: On the variability of phases with extraction and ellipsis. Linguistic Inquiry 45:1.&lt;/p&gt;

&lt;p&gt;Harwood, Will. 2011. There are several positions available: English intermediate subject positions. Proceedings of ConSOLE XIX.&lt;/p&gt;

&lt;p&gt;Sportiche, Dominique. 1988. A theory of floating quantifiers and its corollaries for constituent structure. Linguistic Inquiry 19. 425–449.&lt;/p&gt;
</description>
        <pubDate>Sat, 07 Feb 2015 00:00:00 +0200</pubDate>
        <link>http://mitcho.com/blog/floating-raising-being/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/floating-raising-being/</guid>
        
        <category>linguistics</category>
        
        <category>quantifier float</category>
        
        
        <category>squib</category>
        
      </item>
    
      <item>
        <title>Stanley Kubrick on linguistic fieldwork</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;I have found that when you finally come down to the day &lt;del datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;the scene is going to be shot&lt;/del&gt; &lt;ins datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;of the elicitation&lt;/ins&gt; and you arrive on the location with the &lt;del datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;actors&lt;/del&gt; &lt;ins datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;speakers&lt;/ins&gt;, having had the experience of already seeing some &lt;del datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;scenes shot&lt;/del&gt; &lt;ins datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;data&lt;/ins&gt;, somehow it’s always different. You find out that you have not really explored the &lt;del datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;scene&lt;/del&gt; &lt;ins datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;language&lt;/ins&gt; to its fullest extent. You may have been thinking about it incorrectly, or you may simply not have discovered one of the variations which now in context with everything else that you have &lt;del datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;shot&lt;/del&gt; &lt;ins datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;elicited&lt;/ins&gt; is simply better than anything you had previously thought of. The reality of the final moment, &lt;del datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;just before shooting&lt;/del&gt;, is so powerful that all previous analysis must yield before the impressions you receive under these circumstances, and unless you use this feedback to your positive advantage, unless you adjust to it, adapt to it and accept the sometimes terrifying weaknesses it can expose, you can never realize the most out of your &lt;del datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;film&lt;/del&gt; &lt;ins datetime=&quot;2013-07-30T02:45:45+00:00&quot;&gt;fieldwork&lt;/ins&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;— &lt;a href=&quot;http://strangewood.tumblr.com/post/56523427247/how-much-planning-do-you-do-before-you-start-to&quot;&gt;Stanley Kubrick&lt;/a&gt;&lt;/p&gt;

</description>
        <pubDate>Mon, 29 Jul 2013 00:00:00 +0300</pubDate>
        <link>http://mitcho.com/blog/observation/kubrick-on-fieldwork/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/observation/kubrick-on-fieldwork/</guid>
        
        <category>fieldwork</category>
        
        <category>quote</category>
        
        <category>Stanley Kubrick</category>
        
        
        <category>observation</category>
        
      </item>
    
      <item>
        <title>The new Apple campus and the Pentagon compared</title>
        <description>&lt;p&gt;&lt;span style=&quot;font-size:18px&quot;&gt;&lt;a href=&quot;http://maps.google.com/maps?f=q&amp;#038;source=s_q&amp;#038;hl=en&amp;#038;geocode=&amp;#038;sll=37.332563,-122.00901&amp;#038;sspn=0.01167,0.02178&amp;#038;g=infinite+loop,+cupertino&amp;#038;ie=UTF8&amp;#038;hq=&amp;#038;ll=37.332443,-122.009246&amp;#038;spn=0.01167,0.02178&amp;#038;t=h&amp;#038;z=16&quot;&gt;&lt;img style=&quot;vertical-align:middle;&quot; src=&quot;/static/uploads/2011/06/cupertino-300x271.png&quot; alt=&quot;&quot; title=&quot;cupertino&quot; width=&quot;150&quot; height=&quot;136&quot; class=&quot;alignnone size-medium wp-image-4505&quot; /&gt;&lt;/a&gt; + &lt;a href=&quot;http://maps.google.com/maps?f=q&amp;#038;source=s_q&amp;#038;hl=en&amp;#038;geocode=&amp;#038;q=Pentagon,+Arlington,+VA&amp;#038;aq=0&amp;#038;sll=37.332443,-122.009246&amp;#038;sspn=0.01167,0.02178&amp;#038;ie=UTF8&amp;#038;hq=Pentagon,+Arlington,+VA&amp;#038;ll=38.870604,-77.055724&amp;#038;spn=0.011427,0.02178&amp;#038;t=h&amp;#038;z=16&quot;&gt;&lt;img style=&quot;vertical-align:middle;&quot; src=&quot;/static/uploads/2011/06/Screen-shot-2011-06-08-at-11.02.19-AM-300x279.png&quot; alt=&quot;&quot; title=&quot;Screen shot 2011-06-08 at 11.02.19 AM&quot; width=&quot;150&quot; height=&quot;140&quot; class=&quot;alignnone size-medium wp-image-4503&quot; /&gt;&lt;/a&gt; + &lt;a href=&quot;http://www.9to5mac.com/71080/steve-jobs-presents-ideas-for-new-apple-super-campus-to-cupertino-city-council/&quot;&gt;&lt;img style=&quot;vertical-align:middle;&quot; src=&quot;/static/uploads/2011/06/before-after-apple-campus-hp-203x300.jpg&quot; alt=&quot;&quot; title=&quot;before-after-apple-campus-hp&quot; width=&quot;150&quot; height=&quot;226&quot; class=&quot;alignnone size-medium wp-image-4504&quot; /&gt;&lt;/a&gt; =&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/static/uploads/2011/06/merged.jpg&quot; alt=&quot;&quot; title=&quot;Apple campus + Pentagon&quot; width=&quot;650&quot; height=&quot;588&quot; class=&quot;alignnone size-full wp-image-4508&quot; /&gt;&lt;/p&gt;

&lt;p&gt;That is all.&lt;/p&gt;
</description>
        <pubDate>Wed, 08 Jun 2011 00:00:00 +0300</pubDate>
        <link>http://mitcho.com/blog/observation/apple-campus-pentagon/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/observation/apple-campus-pentagon/</guid>
        
        <category>Apple</category>
        
        <category>Cupertino</category>
        
        <category>Google Maps</category>
        
        <category>map</category>
        
        <category>Pentagon</category>
        
        
        <category>observation</category>
        
      </item>
    
      <item>
        <title>Checking mochitest test coverage</title>
        <description>&lt;p&gt;&lt;a href=&quot;http://www.mozilla.org/firefox?WT.mc_id=aff_en08&amp;amp;WT.mc_ev=click&quot; style=&quot;float: right;margin-left:10px;&quot;&gt;&lt;img border=&quot;0&quot; alt=&quot;Firefox Download Button&quot; src=&quot;http://www.mozilla.org/contribute/buttons/120x240arrow_b.png&quot; /&gt;&lt;/a&gt;One of the last bugs for Firefox Panorama was &lt;a href=&quot;https://bugzilla.mozilla.org/show_bug.cgi?id=625818&quot;&gt;bug 625818: “Check Panorama mochitest test suite coverage”&lt;/a&gt;. Our automated tests ensure that we do not regress on existing functionality, but it’s only as good as its coverage: how much of the Panorama code base is actually being “hit” through the process of running the test suite.&lt;/p&gt;

&lt;p&gt;Panorama went through a pretty rapid development cycle, making it into &lt;a href=&quot;http://firefox.com&quot;&gt;Firefox 4&lt;/a&gt; which was &lt;a href=&quot;http://blog.mozilla.com/blog/2011/03/22/mozilla-launches-firefox-4-and-delivers-a-fast-sleek-and-customizable-browsing-experience-to-more-than-400-million-users-worldwide-2/&quot;&gt;released today&lt;/a&gt; (yay!). Moreover, for a while we were developing outside of mozilla-central, without the regular “patches require tests” requirement. This makes checking its test coverage particularly important.&lt;/p&gt;

&lt;p&gt;Check out the final result, the &lt;a href=&quot;http://mitcho.com/code/panorama-coverage/&quot;&gt;Panorama test coverage report&lt;/a&gt;. The good news: our code coverage is 86%! (Some notes on what improvements can be made are in &lt;a href=&quot;https://bugzilla.mozilla.org/show_bug.cgi?id=625818&quot;&gt;the bug&lt;/a&gt;.)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://mitcho.com/code/panorama-coverage/&quot;&gt;&lt;img src=&quot;/static/uploads/2011/03/Screen-shot-2011-03-22-at-6.59.26-PM.png&quot; alt=&quot;code coverage report&quot; border=&quot;0&quot; width=&quot;600&quot; height=&quot;260&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;PhiliKON had previously worked on hooking into the &lt;a href=&quot;https://developer.mozilla.org/en/Code_snippets/JavaScript_Debugger_Service&quot;&gt;JS Debugger service&lt;/a&gt;’s &lt;code&gt;interruptHook&lt;/code&gt; to test &lt;a href=&quot;https://developer.mozilla.org/en/Writing_xpcshell-based_unit_tests&quot;&gt;&lt;code&gt;xpcshell&lt;/code&gt; tests&lt;/a&gt;. I modified this code to run instead in the &lt;a href=&quot;https://developer.mozilla.org/en/Browser_chrome_tests&quot;&gt;Mochitest browser chrome tests&lt;/a&gt;. This code can be found &lt;a href=&quot;https://bugzilla.mozilla.org/show_bug.cgi?id=625818&quot;&gt;on the bug&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With this patch applied, I invoked the test suite with the following code: &lt;code&gt;TEST_PATH=browser/base/content/tests/tabview COVERAGE_FILTER=&quot;*tabview*&quot; COVERAGE=true make -C obj-ff-dbg mochitest-browser-chrome&lt;/code&gt; . That’s a regular &lt;code&gt;mochitest-browser-chrome&lt;/code&gt; invocation with the &lt;code&gt;COVERAGE=true&lt;/code&gt; flag which turns on code coverage checking, and &lt;code&gt;COVERAGE_FILTER=*tabview*&lt;/code&gt; which filters out results from files which don’t have “tabview” in their paths. This creates a file called &lt;code&gt;coverage.json&lt;/code&gt; in the working directory &lt;em&gt;of the test suite&lt;/em&gt;, meaning, for me, &lt;code&gt;obj-ff-dbg/_tests/testing/mochitest/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This JSON file is a multidimensional array, with file paths and then line numbers as keys. The file paths here, as best as possible, have been converted into local filesystem paths. PhiliKON built a script which produces beautiful reports based on this output.&lt;/p&gt;

&lt;p&gt;A word of warning: running with this JSD &lt;code&gt;interruptHook&lt;/code&gt; is ridiculously slow. A number of tests for Panorama are timing-dependent (drag-drop tests, for example), making some of them fail, but that’s okay… as long as it completed not via a timeout, it actually did run through all the code. In order to get this to run through everything with some degree of control, I split up the mochitest tabview suite in to a few chunks. I then took the multiple resulting &lt;code&gt;coverage.json&lt;/code&gt; files and passed them into another script, in &lt;code&gt;tools/coverage/aggregate.py&lt;/code&gt;, which takes multiple JSON results like this and puts them together into a single JSON file. I then passed this aggregate JSON file to PhiliKON’s wonderful report script and—voila—the &lt;a href=&quot;http://mitcho.com/code/panorama-coverage/&quot;&gt;Panorama test coverage report&lt;/a&gt;! Easy as pie.&lt;/p&gt;

</description>
        <pubDate>Tue, 22 Mar 2011 00:00:00 +0200</pubDate>
        <link>http://mitcho.com/blog/projects/checking-mochitest-test-coverage/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/projects/checking-mochitest-test-coverage/</guid>
        
        <category>Firefox</category>
        
        <category>JavaScript</category>
        
        <category>mochitest</category>
        
        <category>Mozilla Planet</category>
        
        <category>Panorama</category>
        
        
        <category>how to</category>
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>Happy Halloween!</title>
        <description>&lt;p&gt;Happy Halloween from the Firefox Panorama team!&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;lightbox[halloween]&quot; class=&quot;images&quot; style=&quot;height:240px;width:159px;&quot; href=&quot;http://farm5.static.flickr.com/4010/5126512526_a133bd89a8_b.jpg&quot;&gt;&lt;img style=&quot;height:240px;width:159px;&quot; src=&quot;http://farm5.static.flickr.com/4010/5126512526_a133bd89a8_m.jpg&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;lightbox[halloween]&quot; class=&quot;images&quot; href=&quot;http://farm2.static.flickr.com/1247/5126517016_51405f43ea_b.jpg&quot;&gt;&lt;img src=&quot;http://farm2.static.flickr.com/1247/5126517016_51405f43ea_m.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We carved some pumpkins a couple days ago in my department. I carved the Panorama logo above, but also one of the &lt;a href=&quot;http://mitcho.com/blog/tag/stata-center/&quot;&gt;Stata Center&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;lightbox[halloween]&quot; class=&quot;images&quot; href=&quot;http://farm2.static.flickr.com/1054/5126516580_758677e4ab_b.jpg&quot;&gt;&lt;img src=&quot;http://farm2.static.flickr.com/1054/5126516580_758677e4ab_m.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;More Jack-O-Lantern photos, including great ones of Chomsky and Norvin Richards, are &lt;a href=&quot;http://www.flickr.com/photos/themitcho/sets/72157625267289968/&quot;&gt;up on Flickr&lt;/a&gt;.&lt;/p&gt;

</description>
        <pubDate>Fri, 29 Oct 2010 00:00:00 +0300</pubDate>
        <link>http://mitcho.com/blog/projects/happy-halloween/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/projects/happy-halloween/</guid>
        
        <category>Firefox</category>
        
        <category>Halloween</category>
        
        <category>Mozilla Planet</category>
        
        <category>Panorama</category>
        
        <category>Stata Center</category>
        
        
        <category>life</category>
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>Every website has a purpose</title>
        <description>&lt;p&gt;Every website has a purpose. Maybe you want people to buy a product, donate to your cause, download your app, or subscribe to your mailing list. How can you confidently modify your site to make it more effective with respect to this goal?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A/B testing&lt;/strong&gt; is a process by which multiple variants of a website are presented to different users randomly and statistical tools are used to see whether any variant is more &lt;em&gt;effective&lt;/em&gt;, according to an overall goal metric such as conversions or revenue.&lt;/p&gt;

&lt;p&gt;While various A/B testing products—many free—exist, none are made from the ground up to work within the WordPress ecosystem. I believe a solution made particularly for WordPress could make A/B testing so much easier and more straightforward, and that such a solution could be greatly beneficial to the platform as a whole.&lt;/p&gt;

&lt;p&gt;I’m happy to announce my new project, code-named &lt;strong&gt;ShrimpTest&lt;/strong&gt;,&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; which is directly aimed at filling this void. I’ll be working on this project this summer together with the fantastic folks at &lt;a href=&quot;http://automattic.com&quot;&gt;Automattic&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The best way to keep up with development is on the project’s development blog, &lt;a href=&quot;http://shrimptest.wordpress.com/&quot;&gt;the ShrimpTest P2&lt;/a&gt;. Most updates will most likely be much shorter than this initial post. &lt;img src=&quot;http://mitcho.com/blog/wp-includes/images/smilies/icon_wink.gif&quot; alt=&quot;;)&quot; class=&quot;wp-smiley&quot; /&gt; You can get less frequent, milestone-like updates by &lt;a href=&quot;http://twitter.com/shrimptest&quot;&gt;following ShrimpTest on twitter&lt;/a&gt;. Development will be &lt;a href=&quot;http://plugins.svn.wordpress.org/shrimptest/&quot;&gt;open&lt;/a&gt; so feel free to check it out (haha) and submit patches as well. As I go along, I’ll also look forward to your feedback.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot;&gt;

      &lt;p&gt;Five dollars to the first person to correctly guess why I’m calling it ShrimpTest. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Wed, 02 Jun 2010 00:00:00 +0300</pubDate>
        <link>http://mitcho.com/blog/projects/every-website-has-a-purpose/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/projects/every-website-has-a-purpose/</guid>
        
        <category>A/B testing</category>
        
        <category>Automattic</category>
        
        <category>code</category>
        
        <category>plugin</category>
        
        <category>ShrimpTest</category>
        
        <category>WordPress</category>
        
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>Better Linguist List RSS Feeds</title>
        <description>&lt;p&gt;&lt;a href=&quot;/static/uploads/2010/04/linguistlist.png&quot;&gt;&lt;img src=&quot;/static/uploads/2010/04/linguistlist.png&quot; alt=&quot;&quot; title=&quot;linguistlist&quot; width=&quot;268&quot; height=&quot;99&quot; class=&quot;alignright size-full wp-image-3556&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everyone I know in linguistics uses the &lt;a href=&quot;http://linguistlist.org/&quot;&gt;LINGUIST List&lt;/a&gt; website to a greater or lesser degree. Linguist List began as a mailing list in the 90’s, with book, job, and dissertation announcements, call-for-papers, and general academic discussions.&lt;/p&gt;

&lt;p&gt;Nowadays many people follow the various announcements on Linguist List using an RSS feed reader such as &lt;a href=&quot;http://google.com/reader&quot;&gt;Google Reader&lt;/a&gt; or my personal favorite &lt;a href=&quot;http://netnewswireapp.com/&quot;&gt;NetNewsWire&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Unfortunately, the Linguist List RSS feeds (at least recently) don’t include the full text of the articles and have a few other quirks as well. It’s often hard to judge based on the title whether it’s really something I’m interested or not, so I’ve spent a lot of time frustratedly opening any possibly interesting-looking entry in a separate NetNewsWire tab. Today I decided enough was enough: I just wrote a script which parses each of the Linguist List RSS feeds, finds the actual descriptions and interleaves them.&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; It’s working remarkably well so far:&lt;/p&gt;

&lt;!--more--&gt;

&lt;p&gt;&lt;a rel=&quot;imagebox&quot; href=&quot;/static/uploads/2010/04/Screen-shot-2010-04-26-at-6.41.07-PM.png&quot;&gt;&lt;img src=&quot;/static/uploads/2010/04/Screen-shot-2010-04-26-at-6.41.07-PM.png&quot; alt=&quot;&quot; title=&quot;Screen shot 2010-04-26 at 6.41.07 PM&quot; width=&quot;650&quot; height=&quot;365&quot; class=&quot;alignright size-full wp-image-3557&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are all the RSS links for all of you to subscribe to. I plan on keeping this up and maintained for the foreseeable future (or, until Linguist List improves their own RSS feeds!) so feel free to subscribe to it. Please do let me know if you run into any issues or have a suggestion. &lt;img src=&quot;http://mitcho.com/blog/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt;&lt;/p&gt;

&lt;table&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListMostRecent&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Most recent issues&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListMostRecent&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListMostRecent?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListAll&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; All (announcements)&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListAll&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListAll?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListBooks&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Book announcements&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListBooks&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListBooks?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListCalls&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Call for papers&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListCalls&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListCalls?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListConfs&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Conference announcements&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListConfs&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListConfs?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListDisc&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Discussions&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListDisc&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListDisc?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListDiss&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Dissertation announcements&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListDiss&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListDiss?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListFYI&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; FYI&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListFYI&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListFYI?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListJobs&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Job announcements&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListJobs&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListJobs?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListMedia&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Topics in the Media&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListMedia&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListMedia?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListQs&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Queries&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListQs&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListQs?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListReview&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Book reviews&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListReview&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListReview?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListSoftware&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Software announcements&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListSoftware&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListSoftware?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListSum&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Summaries of Query Responses&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListSum&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListSum?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListSupport&quot; type=&quot;application/rss+xml&quot;&gt;&lt;img src=&quot;http://feedburner.google.com/fb/lib/images/icons/feed-icon-12x12-orange.gif&quot; /&gt; Support for Students&lt;/a&gt;
    &lt;/td&gt;
    
    &lt;td&gt;
      &lt;a href=&quot;http://feeds.feedburner.com/LinguistListSupport&quot;&gt;&lt;img src=&quot;http://feeds.feedburner.com/~fc/LinguistListSupport?bg=99CCFF&amp;#038;fg=444444&amp;#038;anim=0&quot; height=&quot;26&quot; width=&quot;88&quot; style=&quot;border:0&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;You can find descriptions of the content of each of these feeds &lt;a href=&quot;http://linguistlist.org/issues/rss/topics.cfm&quot;&gt;on Linguist List’s RSS feeds page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.feedburner.com&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://www.feedburner.com/fb/images/pub/i_heart_fb.gif&quot; alt=&quot;Powered by FeedBurner&quot; style=&quot;border:0&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Perhaps in the future I’ll do a “how to” post as well with the code I use to make this happen. I’ll note that it’s just 70 lines of PHP (including whitespace) and could no doubt be tightened up. &lt;img src=&quot;http://mitcho.com/blog/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot;&gt;

      &lt;p&gt;Veteran Linguist List RSS subscribers will also note that I’m adding the full title to the entry title for the Conferences and Calls lists as well. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 26 Apr 2010 00:00:00 +0300</pubDate>
        <link>http://mitcho.com/blog/projects/better-linguist-list-rss-feeds/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/projects/better-linguist-list-rss-feeds/</guid>
        
        <category>annoyances</category>
        
        <category>code</category>
        
        <category>Linguist List</category>
        
        <category>linguistics</category>
        
        <category>RSS</category>
        
        
        <category>projects</category>
        
      </item>
    
      <item>
        <title>Beginning development with Jetpack SDK 0.2</title>
        <description>&lt;p&gt;&lt;em&gt;This article is a translation of a &lt;a href=&quot;http://www.xuldev.org/blog/?p=513&quot;&gt;recent article in Japanese&lt;/a&gt; by fellow Jetpack Ambassador &lt;a href=&quot;http://www.xuldev.org/blog/&quot;&gt;Gomita&lt;/a&gt; which was published &lt;a href=&quot;http://mozillalabs.com/jetpack/2010/04/13/develop-with-jetpack-sdk-0-2/&quot;&gt;on the Mozilla Labs Jetpack blog&lt;/a&gt;. I’m cross-posting it here for posterity.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Mozilla Labs recently released &lt;a href=&quot;http://mozillalabs.com/jetpack/2010/03/26/announcing-jetpack-sdk-0-2/&quot;&gt;version 0.2&lt;/a&gt; of the Jetpack SDK, which fixes some issues of the 0.1 release such as a glitch regarding development with Windows. SDK 0.2 doesn’t include the planned APIs for rapid development of new browser functionality, but you can still play with SDK 0.2 to get a flavor for development with the Jetpack SDK.&lt;/p&gt;

&lt;p&gt;In this article we begin by setting up an SDK 0.2 development environment and explain the steps required to develop a simple, practical add-on using SDK 0.2. The instructions here are for Windows, but the basic steps are the same in every platform.&lt;/p&gt;

&lt;!--more--&gt;

&lt;h3 id=&quot;installing-python&quot;&gt;Installing Python&lt;/h3&gt;

&lt;p&gt;The first step to using the Jetpack SDK is to install Python. How to install Python depends on your OS, but in Windows you can choose the “Python 2.6.5 Windows installer” from the &lt;a href=&quot;http://www.python.org/download/&quot;&gt;Python&lt;/a&gt; site and follow the installation wizard. Here, I’ll use &lt;code&gt;C:\Python26\&lt;/code&gt; as the installation path.&lt;/p&gt;

&lt;p&gt;After the install, you can activate the &lt;code&gt;python&lt;/code&gt; command in your command line by adding &lt;code&gt;C:\Python26&lt;/code&gt; to the Windows &lt;code&gt;Path&lt;/code&gt; preference. (If there is already another value, delimit with a semicolon: “;”.) Run the command “cmd” from the Start menu to start the command prompt and run &lt;code&gt;python -V&lt;/code&gt; to confirm the Python version, &lt;code&gt;Python 2.6.2&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;C:\&amp;gt;python -V
Python 2.6.2
&lt;/pre&gt;
&lt;p&gt;Note, the&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jetpack.mozillalabs.com/sdk/0.2/docs/#guide/getting-started&quot;&gt;Jetpack SDK Docs&lt;/a&gt; state that Python 2.5+ is required, but there seem to be some incompatibilities with Python 3.0.1 at this time. In addition, in my experience the SDK worked fine without the “Python for Windows extensions.”&lt;/p&gt;

&lt;h3 id=&quot;setting-up-the-jetpack-sdk&quot;&gt;Setting up the Jetpack SDK&lt;/h3&gt;

&lt;p&gt;Next, we set up the Jetpack SDK. Download the Jetpack SDK 0.2 package from the &lt;a href=&quot;https://jetpack.mozillalabs.com/&quot;&gt;Jetpack site&lt;/a&gt;, unzip it, and place it somewhere convenient. Here, I used &lt;code&gt;C:\jetpack-sdk-0.2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To use the Jetpack SDK, it must be “activated.” From the command prompt, go to the Jetpack SDK folder and run &lt;code&gt;bin\activate&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;C:\jetpack-sdk-0.2&amp;amp;gt;bin\activate&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Welcome to the Jetpack SDK. Run &amp;#39;cfx docs&amp;#39; for assistance.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;(C:\jetpack-sdk-0.2) C:\jetpack-sdk-0.2&amp;amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Next, run &lt;code&gt;cfx docs&lt;/code&gt; to open the SDK documentation in the browser. The SDK documentation starts a local server on port 8888.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;(C:\jetpack-sdk-0.2) C:\jetpack-sdk-0.2&amp;amp;gt;cfx docs&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;One moment.&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Opening web browser to http://127.0.0.1:8888.&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;the-package-directory-structure&quot;&gt;The package directory structure&lt;/h3&gt;

&lt;p&gt;Addons built with the Jetpack SDK are called “packages.” Let’s try building a simple “hello world”-style package, but first let’s see what the final directory structure of this package will look like:&lt;/p&gt;

&lt;table style=&quot;height: 279px; margin: 0pt 0pt 10px 80px;&quot; width=&quot;450&quot;&gt;
  &lt;tr&gt;
    &lt;th&gt;
      &lt;span style=&quot;float: left;&quot;&gt;directory/file&lt;/span&gt;
    &lt;/th&gt;
    
    &lt;th&gt;
      &lt;span style=&quot;float: left;&quot;&gt;Note&lt;/span&gt;
    &lt;/th&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;img style=&quot;float: left; margin: 4px 5px;&quot; src=&quot;http://www.xuldev.org/common/folder.png&quot; alt=&quot;フォルダ&quot; width=&quot;16&quot; height=&quot;16&quot; /&gt;jetpack-sdk-0.2
    &lt;/td&gt;
    
    &lt;td&gt;
      the Jetpack SDK folder
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;img style=&quot;float: left; margin: 4px 5px; margin-left:21px;&quot; src=&quot;http://www.xuldev.org/common/folder.png&quot; alt=&quot;フォルダ&quot; width=&quot;16&quot; height=&quot;16&quot; /&gt;packages
    &lt;/td&gt;
    
    &lt;td&gt;
      the main packages folder
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;img style=&quot;float: left; margin: 4px 5px; margin-left:37px;&quot; src=&quot;http://www.xuldev.org/common/folder.png&quot; alt=&quot;フォルダ&quot; width=&quot;16&quot; height=&quot;16&quot; /&gt;hello-world
    &lt;/td&gt;
    
    &lt;td&gt;
      package root
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;img style=&quot;float: left; margin: 4px 5px; margin-left:53px;&quot; src=&quot;http://www.xuldev.org/common/file.png&quot; alt=&quot;ファイル&quot; width=&quot;16&quot; height=&quot;16&quot; /&gt;package.json
    &lt;/td&gt;
    
    &lt;td&gt;
      package manifest file
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;img style=&quot;float: left; margin: 4px 5px; margin-left:53px;&quot; src=&quot;http://www.xuldev.org/common/file.png&quot; alt=&quot;ファイル&quot; width=&quot;16&quot; height=&quot;16&quot; /&gt;README.md
    &lt;/td&gt;
    
    &lt;td&gt;
      package documentation
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;img style=&quot;float: left; margin: 4px 5px; margin-left:53px;&quot; src=&quot;http://www.xuldev.org/common/folder.png&quot; alt=&quot;フォルダ&quot; width=&quot;16&quot; height=&quot;16&quot; /&gt;lib
    &lt;/td&gt;
    
    &lt;td&gt;
      the package code directory
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;img style=&quot;float: left; margin: 4px 5px; margin-left:69px;&quot; src=&quot;http://www.xuldev.org/common/file.png&quot; alt=&quot;ファイル&quot; width=&quot;16&quot; height=&quot;16&quot; /&gt;main.js
    &lt;/td&gt;
    
    &lt;td&gt;
      main program code
    &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td&gt;
      &lt;img style=&quot;float: left; margin: 4px 5px; margin-left:69px;&quot; src=&quot;http://www.xuldev.org/common/file.png&quot; alt=&quot;ファイル&quot; width=&quot;16&quot; height=&quot;16&quot; /&gt;simple-dialog.js
    &lt;/td&gt;
    
    &lt;td&gt;
      a custom code library
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;The package’s root directory is placed in the “packages” directory in the Jetpack SDK folder, and includes the &lt;code&gt;package.json&lt;/code&gt; manifest file and the &lt;code&gt;README.md&lt;/code&gt; documentation file. The &lt;code&gt;lib&lt;/code&gt; folder includes the package’s main program code and any custom libraries used by our addon.&lt;/p&gt;

&lt;h3 id=&quot;creating-the-package&quot;&gt;Creating the package&lt;/h3&gt;

&lt;p&gt;We begin by creating the &lt;code&gt;hello-world&lt;/code&gt; directory in &lt;code&gt;C:\jetpack-sdk-0.2\packages&lt;/code&gt; . Next the manifest file &lt;code&gt;package.json&lt;/code&gt; is created. The manifest file includes metadata about our package in JSON format. If you’ve ever created a XUL-style addon before, you can think of this as similar to the &lt;code&gt;install.rdf&lt;/code&gt; file. Here, I used the following as the manifest:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-json&quot; data-lang=&quot;json&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;quot;id&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;helloworld@xuldev.org&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;quot;version&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;0.1&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;quot;description&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;This is my first package.&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;quot;author&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;Gomita &amp;amp;lt;gomita@xuldev.org&amp;amp;gt;&amp;quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The &lt;code&gt;id&lt;/code&gt; property is used as a unique ID for all addons including Jetpack packages and is often formatted as an email address. This corresponds to XUL-based addons’ &lt;code&gt;&amp;amp;lt;em:id&amp;amp;gt;&lt;/code&gt; tag.&lt;/p&gt;

&lt;p&gt;Next, reload the SDK documentation in the browser and confirm that “hello-world” shows up under “Package Reference.”&lt;/p&gt;

&lt;h3 id=&quot;writing-the-main-code&quot;&gt;Writing the main code&lt;/h3&gt;

&lt;p&gt;The next step is to add some working code to the hello-world package. Create a &lt;code&gt;lib&lt;/code&gt; folder under the package root and create a &lt;code&gt;main.js&lt;/code&gt; under &lt;code&gt;lib&lt;/code&gt; with the following code:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Hello, World!&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;The main program code is always loaded as a module called &lt;code&gt;main&lt;/code&gt;. This &lt;code&gt;main&lt;/code&gt; property is made accessible from outside code using the &lt;a href=&quot;http://commonjs.org/&quot;&gt;CommonJS&lt;/a&gt;-style code &lt;code&gt;exports.main = ...&lt;/code&gt;. &lt;code&gt;console.log&lt;/code&gt; is a global function made available by Jetpack and the SDK prints the string to the command prompt.&lt;/p&gt;

&lt;p&gt;It’s worth noting that, in the current Jetpack SDK, calling “&lt;code&gt;console.log(&quot;こんにちは&quot;);&lt;/code&gt;” doesn’t yield the expected Japanese output. In the future such output will be handled through the planned &lt;a href=&quot;https://wiki.mozilla.org/Labs/Jetpack/Reboot/JEP/113&quot;&gt;localization API&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;testing-our-package&quot;&gt;Testing our package&lt;/h3&gt;

&lt;p&gt;With some simple code in our &lt;code&gt;main&lt;/code&gt; function, it’s time to try this code out. To test this code, we run &lt;code&gt;cfx run -a firefox&lt;/code&gt; in the command prompt. By running &lt;code&gt;cfx run&lt;/code&gt; with the &lt;code&gt;-a firefox&lt;/code&gt; option, we load our package into a brand new Firefox profile and launch Firefox.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;(C:\jetpack-sdk-0.2) C:\jetpack-sdk-0.2&amp;gt;cd packages\hello-world&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;(C:\jetpack-sdk-0.2) C:\jetpack-sdk-0.2\packages\hello-world&amp;gt;cfx run -a firefox&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;info: Hello, World!&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;OK&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Total time: 1.531000 seconds&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Program terminated unsuccessfully.&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;After Firefox loads, confirm that the command prompt reads &lt;code&gt;info: Hello, World!&lt;/code&gt; When you quit Firefox, the testing will end.&lt;/p&gt;

&lt;h3 id=&quot;using-a-standard-library&quot;&gt;Using a standard library&lt;/h3&gt;

&lt;p&gt;Now we’ll edit our code to invoke the timer library which is one of the Jetpack SDK’s standard libraries. The timer library is a module which abstracts various timer-related functionality, similar to the DOM’s &lt;code&gt;window.setTimeout&lt;/code&gt;, &lt;code&gt;window.clearTimeout&lt;/code&gt;. Details on this library are available in the &lt;a href=&quot;https://jetpack.mozillalabs.com/sdk/0.2/docs/#module/jetpack-core/timer&quot;&gt;SDK documentation&lt;/a&gt;. Moreover, although not in the documentation, &lt;code&gt;timer.setInterval&lt;/code&gt; and &lt;code&gt;timer.clearInterval&lt;/code&gt; also work in this version.&lt;/p&gt;

&lt;p&gt;To use this library in our main program code, we first must invoke this library with the CommonJS require function. We modify the &lt;code&gt;main.js&lt;/code&gt; file as follows:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;timer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;timer&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;timer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;setInterval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;toLocaleTimeString&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;After this change, run &lt;code&gt;cfx run -a firefox&lt;/code&gt; in the command prompt to test it. Check to make sure that the current time is being printed to the command prompt once a second:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;(C:\jetpack-sdk-0.2) C:\jetpack-sdk-0.2\packages\hello-world&amp;amp;gt;cfx run -a firefox&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;info: 10:37:21&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;info: 10:37:22&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;info: 10:37:23&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;info: 10:37:24&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;info: 10:37:25&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;creating-a-custom-library&quot;&gt;Creating a custom library&lt;/h3&gt;

&lt;p&gt;Next we’ll create a custom library to add some functionality not currently included in the Jetpack standard library. Implementing advanced functionality in add-ons, like filesystem access, involves using &lt;a href=&quot;https://developer.mozilla.org/en/XPCOM&quot;&gt;XPCOM&lt;/a&gt; components. Jetpack encourages seprarating the use of XPCOM components into separate modules which are then used by the main program code. The Jetpack SDK doesn’t currently disallow direct XPCOM access within Jetpack add-on code, but such a restriction is forthcoming. Modularizing XPCOM code into separate libraries now allow you to easily migrate to equivalent standard libraries in the future.&lt;/p&gt;

&lt;p&gt;Let’s create a &lt;code&gt;simple-dialog&lt;/code&gt; library to display a modal dialog much like &lt;code&gt;window.alert&lt;/code&gt; does. The Jetpack code’s runtime environment doesn’t include access to the regular &lt;code&gt;window&lt;/code&gt; or &lt;code&gt;document&lt;/code&gt; objects, so just calling &lt;code&gt;window.alert&lt;/code&gt; doesn’t work. To create an alert from this context, we use the &lt;code&gt;&amp;amp;lt;a href=&quot;https://developer.mozilla.org/en/nsIPromptService&quot;&amp;amp;gt;nsIPromptService&amp;amp;lt;/a&amp;amp;gt;&lt;/code&gt; XPCOM component. In our package’s &lt;code&gt;lib&lt;/code&gt; folder, create a &lt;code&gt;simple-dialog.js&lt;/code&gt; file. Just like our main program code, we implement this library as a CommonJS module using &lt;code&gt;exports.&amp;amp;lt;em&amp;amp;gt;methodname&amp;amp;lt;/em&amp;amp;gt; = function(...){...}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The simple-dialog library will have these two methods:&lt;/p&gt;

&lt;table style=&quot;margin: 0 0 10px 80px;&quot;&gt;
  
  &lt;tr&gt;
    &lt;th&gt;
      &lt;span style=&quot;float: left;&quot;&gt;Method&lt;/span&gt;
    &lt;/th&gt;
    
    
    &lt;th&gt;
      &lt;span style=&quot;float: left;&quot;&gt;Note&lt;/span&gt;
    &lt;/th&gt;
    
  &lt;/tr&gt;
  
  
  &lt;tr&gt;
    &lt;td&gt;
      `alert(&amp;lt;em&amp;gt;text&amp;lt;/em&amp;gt;)`
    &lt;/td&gt;
    
    
    &lt;td&gt;
      Displays an alert dialog with the string in &lt;em&gt;text&lt;/em&gt; and an OK button. Equivalent to the DOM&amp;#8217;s `window.alert`.
    &lt;/td&gt;
    
  &lt;/tr&gt;
  
  
  &lt;tr&gt;
    &lt;td&gt;
      `confirmYesNo(&amp;lt;em&amp;gt;text&amp;lt;/em&amp;gt;)`
    &lt;/td&gt;
    
    
    &lt;td&gt;
      Displays a confirmation dialog with the string in &lt;em&gt;text&lt;/em&gt; and Yes and No buttons. The method returns `true` if the user presses &amp;#8220;yes&amp;#8221; and `false` if &amp;#8220;no.&amp;#8221;
    &lt;/td&gt;
    
  &lt;/tr&gt;
  
  
&lt;/table&gt;

&lt;p&gt;Here is the code for &lt;code&gt;simple-dialog.js&lt;/code&gt;:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;promptSvc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Cc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;@mozilla.org/embedcomp/prompt-service;1&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;
                &lt;span class=&quot;nx&quot;&gt;getService&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Ci&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nsIPromptService&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;promptSvc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;[Jetpack]&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;confirmYesNo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;promptSvc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;confirmEx&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;[Jetpack]&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;promptSvc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;STD_YES_NO_BUTTONS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;pos&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Lines 1-2 are for calling &lt;code&gt;nsIPromptService&lt;/code&gt;. Note that &lt;code&gt;Cc&lt;/code&gt;, &lt;code&gt;Ci&lt;/code&gt; are aliases for &lt;code&gt;Components.classes&lt;/code&gt; and &lt;code&gt;Components.interfaces&lt;/code&gt;, respectively, and are made available by Jetpack as global variables. Lines 4-6 implement the alert method for showing alert dialogs using &lt;code&gt;nsIPromptService&lt;/code&gt;’s &lt;code&gt;alert&lt;/code&gt; method. Lines 8-14 implement &lt;code&gt;simple-dialog&lt;/code&gt;’s &lt;code&gt;confirmYesNo&lt;/code&gt; method using &lt;code&gt;nsIPromptService&lt;/code&gt;’s &lt;code&gt;confirmEx&lt;/code&gt; method to display the dialog with yes and no buttons. &lt;code&gt;nsIPromptservice&lt;/code&gt;’s &lt;code&gt;confirmEx&lt;/code&gt; method returns 0 if the user presses “yes” and 1 if “no”, so we modify this value and return it.&lt;/p&gt;

&lt;h3 id=&quot;using-our-custom-library&quot;&gt;Using our custom library&lt;/h3&gt;

&lt;p&gt;Let’s call this new custom library from our main program code and verify that it works. Here’s our updated &lt;code&gt;main.js&lt;/code&gt; file:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;simpleDialog&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;simple-dialog&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;adult&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;simpleDialog&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;confirmYesNo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Are you over 18 years old?&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;adult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;simpleDialog&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Welcome!&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;nx&quot;&gt;simpleDialog&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Good bye!&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Run &lt;code&gt;cfx run -a firefox&lt;/code&gt; and confirm that a confirmation dialog is displayed. Pressing “yes” and “no” should give you the appropriate alert dialogs as well.&lt;/p&gt;

&lt;h3 id=&quot;implementing-a-network-status-observer&quot;&gt;Implementing a network status observer&lt;/h3&gt;

&lt;p&gt;Now let’s use this hello-world package as a foundation for a more practical add-on. Using the &lt;code&gt;&amp;amp;lt;a href=&quot;https://jetpack.mozillalabs.com/sdk/0.2/docs/#module/jetpack-core/observer-service&quot;&amp;amp;gt;observer-service&amp;amp;lt;/a&amp;amp;gt;&lt;/code&gt; module included with the Jetpack SDK, we can monitor Firefox’s online/offline network status changes.&lt;/p&gt;

&lt;p&gt;Firefox internally broadcasts various application events to observers via the &lt;code&gt;&amp;amp;lt;a href=&quot;https://developer.mozilla.org/ja/NsIObserverService&quot;&amp;amp;gt;nsIObserverService&amp;amp;lt;/a&amp;amp;gt;&lt;/code&gt; XPCOM component. When Firefox goes offline, a &lt;code&gt;network:offline-status-changed&lt;/code&gt; notification is broadcast. To subscribe this notification and act on it, we use the &lt;code&gt;observer-service&lt;/code&gt; library’s &lt;code&gt;add&lt;/code&gt; method. &lt;code&gt;add&lt;/code&gt;’s first argument is the name of the notification we want to subscribe to and the second argument is a callback function. The callback function is given two arguments, of which the second is a string equal to either “online” or “offline.” In our add-on, we’ll check this value and display an appropriate alert using &lt;code&gt;simple-dialog&lt;/code&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;simpleDialog&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;simple-dialog&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;observer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;observer-service&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;exports&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;main&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;callbacks&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;observer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;network:offline-status-changed&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;sbj&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;online&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;simpleDialog&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Firefox is now online.&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;data&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;offline&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;nx&quot;&gt;simpleDialog&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;Firefox is now offline.&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Launch Firefox by running &lt;code&gt;cfx run -a firefox&lt;/code&gt; and then choose “File” &amp;gt; “Work Offline” and you should get a notification:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://mozillalabs.com/jetpack/files/2010/04/offline-en.png&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-270&quot; title=&quot;offline-en&quot; src=&quot;http://mozillalabs.com/jetpack/files/2010/04/offline-en-300x225.png&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;225&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;adding-documentation&quot;&gt;Adding documentation&lt;/h3&gt;

&lt;p&gt;If you add documentation to a package, you can view it by clicking that package in the SDK Documentation. To add documentation, create a &lt;code&gt;README.md&lt;/code&gt; file in the package root directory. &lt;code&gt;README.md&lt;/code&gt; is written in Markdown format which looks like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;This is my *first* package.
* foo
* bar
* baz
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now if you load the SDK documentation using &lt;code&gt;cfx docs&lt;/code&gt; and click on the “hello-world” link, you’ll see this documentation together with the package metadata.&lt;/p&gt;

&lt;h3 id=&quot;exporting-an-install-package&quot;&gt;Exporting an install package&lt;/h3&gt;

&lt;p&gt;Jetpack add-ons which are created in this way can then be exported into Firefox-standard XPI files. To export an XPI, go to the package’s root directory in the command prompt and run &lt;code&gt;cfx xpi&lt;/code&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-console&quot; data-lang=&quot;console&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;go&quot;&gt;(C:\jetpack-sdk-0.2) C:\jetpack-sdk-0.2\packages\hello-world&amp;amp;gt;cfx xpi&lt;/span&gt;
&lt;span class=&quot;go&quot;&gt;Exporting extension to hello-world.xpi.&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This creates an XPI file called &lt;code&gt;hello-world.xpi&lt;/code&gt;. Opening this file in any Firefox profile will let you install it using the regular add-on install mechanism.&lt;/p&gt;

</description>
        <pubDate>Wed, 14 Apr 2010 00:00:00 +0300</pubDate>
        <link>http://mitcho.com/blog/how-to/develop-with-jetpack-sdk-0-2/</link>
        <guid isPermaLink="true">http://mitcho.com/blog/how-to/develop-with-jetpack-sdk-0-2/</guid>
        
        <category>Jetpack</category>
        
        <category>Jetpack SDK</category>
        
        <category>Mozilla Labs</category>
        
        <category>Mozilla Planet</category>
        
        <category>Windows</category>
        
        
        <category>how to</category>
        
      </item>
    
  </channel>
</rss>
