<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.dexy.it</title>
	<atom:link href="http://blog.dexy.it/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.dexy.it</link>
	<description>make &#124; docs &#124; sexy</description>
	<lastBuildDate>Wed, 14 Mar 2012 19:24:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Happy Pi Day</title>
		<link>http://blog.dexy.it/522</link>
		<comments>http://blog.dexy.it/522#comments</comments>
		<pubDate>Wed, 14 Mar 2012 16:12:38 +0000</pubDate>
		<dc:creator>ana</dc:creator>
				<category><![CDATA[Fun]]></category>

		<guid isPermaLink="false">http://blog.dexy.it/?p=522</guid>
		<description><![CDATA[It was pretty late last night when I finished my post about blogging with WordPress and Dexy, so I didn&#8217;t even notice it had turned into &#960; day. This morning of course twitter reminded me, and in particular this caught my eye: Can anyone draw me a plot of &#8730;[6(1 + 1/2^2 + 1/3^2 + ...]]></description>
				<content:encoded><![CDATA[<p>It was pretty late last night when I finished my post about blogging with WordPress and Dexy, so I didn&#8217;t even notice it had turned into <a href="http://en.wikipedia.org/wiki/Pi_Day">&pi; day</a>. This morning of course twitter reminded me, and in particular this caught my eye:</p>
<blockquote class="twitter-tweet"><p>Can anyone draw me a plot of &radic;[6(1 + 1/2^2 + 1/3^2 + 1/4^2...)] &rarr;&pi;? Excel is not only ok, it&#8217;s recommended. Should bounce around and close in.</p>
<p>&mdash; Matt Parker (@standupmaths) <a href="https://twitter.com/standupmaths/status/179934335120572416" data-datetime="2012-03-14T14:17:43+00:00">March 14, 2012</a></p></blockquote>
<p><script src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p><span id="more-522"></span></p>
<p>Lots of people have done cool graphs using spreadsheets. Here&#8217;s a google spreadsheets version:</p>
<blockquote class="twitter-tweet"><p>Here&#8217;s a nice spreadsheet simulating &radic;[6(1 + 1/2^2 + 1/3^2 + 1/4^2...)] &rarr;&pi; <a href="https://twitter.com/search/%2523piday">#piday</a> RT @<a href="https://twitter.com/si_kelly">si_kelly</a>: @<a href="https://twitter.com/standupmaths">standupmaths</a> <a href="https://t.co/dsMoS679" title="https://docs.google.com/spreadsheet/ccc?key=0AhTWpGoiXjKQdGJVd3E5WXNZVTI4U1Z3a0F6ZWNoREE#gid=0">docs.google.com/spreadsheet/cc&#8230;</a></p>
<p>&mdash; Matt Parker (@standupmaths) <a href="https://twitter.com/standupmaths/status/179973838233272320" data-datetime="2012-03-14T16:54:41+00:00">March 14, 2012</a></p></blockquote>
<p><script src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p>As Matt says, Excel is recommended here because it&#8217;s very easy to set up the formulas and graph them. It makes it very intuitive. But, I&#8217;m going to try this out using Python just because I feel like playing with some math today and spreadsheets are pretty awkward on my little netbook.</p>
<p>Here&#8217;s the formula, made a little easier to read thanks to LaTeX and MathJax:</p>
<div id="converges-to-pi">$$\sqrt{6\left(1+\frac{1}{2^2}+\frac{1}{3^2}+\frac{1}{4^2}\dots\right)}$$</div>
<p>Here&#8217;s my first implementation:</p>
<div class="highlight">
<pre><a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-1"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">sum_fractions</span> <span class="o">=</span> <span class="mf">0.0</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-2"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">values</span> <span class="o">=</span> <span class="p">[]</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-3"></a><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">20</span><span class="p">):</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-4"></a><span class="gp">... </span>    <span class="n">sum_fractions</span> <span class="o">+=</span> <span class="mf">1.0</span><span class="o">/</span><span class="p">(</span><span class="n">i</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-5"></a><span class="gp">... </span>    <span class="n">value</span> <span class="o">=</span> <span class="n">numpy</span><span class="o">.</span><span class="n">sqrt</span><span class="p">((</span><span class="mf">6.0</span> <span class="o">*</span> <span class="n">sum_fractions</span><span class="p">))</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-6"></a><span class="gp">... </span>    <span class="n">values</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-7"></a><span class="gp">... </span>    <span class="k">print</span> <span class="s">&quot;After adding 1/</span><span class="si">%s</span><span class="s">^2 value is </span><span class="si">%0.10f</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-8"></a><span class="gp">...</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-9"></a><span class="go">After adding 1/1^2 value is 2.4494897428</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-10"></a><span class="go">After adding 1/2^2 value is 2.7386127875</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-11"></a><span class="go">After adding 1/3^2 value is 2.8577380332</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-12"></a><span class="go">After adding 1/4^2 value is 2.9226129861</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-13"></a><span class="go">After adding 1/5^2 value is 2.9633877010</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-14"></a><span class="go">After adding 1/6^2 value is 2.9913764947</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-15"></a><span class="go">After adding 1/7^2 value is 3.0117739478</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-16"></a><span class="go">After adding 1/8^2 value is 3.0272978567</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-17"></a><span class="go">After adding 1/9^2 value is 3.0395075896</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-18"></a><span class="go">After adding 1/10^2 value is 3.0493616360</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-19"></a><span class="go">After adding 1/11^2 value is 3.0574815067</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-20"></a><span class="go">After adding 1/12^2 value is 3.0642878178</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-21"></a><span class="go">After adding 1/13^2 value is 3.0700753719</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-22"></a><span class="go">After adding 1/14^2 value is 3.0750569156</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-23"></a><span class="go">After adding 1/15^2 value is 3.0793898260</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-24"></a><span class="go">After adding 1/16^2 value is 3.0831930203</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-25"></a><span class="go">After adding 1/17^2 value is 3.0865580258</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-26"></a><span class="go">After adding 1/18^2 value is 3.0895564350</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-27"></a><span class="go">After adding 1/19^2 value is 3.0922450523</span>
</pre>
</div>
<p>We&#8217;ve stored the first 20 values in an array, so let&#8217;s graph them:</p>
<div class="highlight">
<pre><a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-1"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">pyplot</span><span class="o">.</span><span class="n">axhline</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">pi</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s">&#39;r&#39;</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-2"></a><span class="go">&lt;matplotlib.lines.Line2D object at 0xa2bb8ac&gt;</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-3"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">pyplot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">20</span><span class="p">),</span> <span class="n">values</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s">&#39;b&#39;</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-4"></a><span class="go">[&lt;matplotlib.lines.Line2D object at 0xa21938c&gt;]</span>
</pre>
</div>
<p><img alt="graph of approximation of pi using sum of inverse squares" src="https://s3.amazonaws.com/blogdexyit-2012-03/2012--03--pi-day--pi.png" /></p>
<p>Not bad, but we&#8217;ll want to go a little farther out. Also, a fun addition to this was also posted:</p>
<blockquote class="twitter-tweet" data-in-reply-to="179934335120572416"><p>@<a href="https://twitter.com/standupmaths">standupmaths</a> A guess: did you want the alternating odd inverses summing to 4/&pi;*? In case you did: <a href="http://t.co/9dbG0KYK" title="http://twitter.com/outofthenorm2/status/179942642627522560/photo/1">twitter.com/outofthenorm2/&#8230;</a></p>
<p>&mdash; out of the norm (@outofthenorm2) <a href="https://twitter.com/outofthenorm2/status/179942642627522560" data-datetime="2012-03-14T14:50:44+00:00">March 14, 2012</a></p></blockquote>
<p><script src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p>*Oops, @outofthenorm2 meant to say &pi;/4</p>
<p>So, let&#8217;s try this again defining some functions:</p>
<div class="highlight">
<pre><a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-1"></a><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">sqrt_six_times_sum_inv_squares</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-2"></a><span class="gp">... </span>    <span class="k">return</span> <span class="n">numpy</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="mf">6.0</span><span class="o">*</span><span class="nb">sum</span><span class="p">(</span><span class="mf">1.0</span><span class="o">/</span><span class="n">k</span><span class="o">**</span><span class="mi">2</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="n">n</span><span class="p">)))</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-3"></a><span class="gp">... </span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-4"></a><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">four_times_sum_inv_odds</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-5"></a><span class="gp">... </span>    <span class="k">return</span> <span class="mf">4.0</span><span class="o">*</span><span class="nb">sum</span><span class="p">(((</span><span class="o">-</span><span class="mf">1.0</span><span class="p">)</span><span class="o">**</span><span class="p">(</span><span class="n">k</span><span class="o">+</span><span class="mi">1</span><span class="p">))</span><span class="o">/</span><span class="p">(</span><span class="mi">2</span><span class="o">*</span><span class="n">k</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="n">n</span><span class="p">))</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-6"></a><span class="gp">... </span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-7"></a><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">):</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-8"></a><span class="gp">... </span>    <span class="n">value</span> <span class="o">=</span> <span class="n">sqrt_six_times_sum_inv_squares</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-9"></a><span class="gp">... </span>    <span class="k">print</span> <span class="s">&quot;At step </span><span class="si">%s</span><span class="s"> value is </span><span class="si">%0.10f</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-10"></a><span class="gp">...</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-11"></a><span class="go">At step 1 value is 0.0000000000</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-12"></a><span class="go">At step 2 value is 2.4494897428</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-13"></a><span class="go">At step 3 value is 2.7386127875</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-14"></a><span class="go">At step 4 value is 2.8577380332</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-15"></a><span class="go">At step 5 value is 2.9226129861</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-16"></a><span class="go">At step 6 value is 2.9633877010</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-17"></a><span class="go">At step 7 value is 2.9913764947</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-18"></a><span class="go">At step 8 value is 3.0117739478</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-19"></a><span class="go">At step 9 value is 3.0272978567</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-20"></a><span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">):</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-21"></a><span class="gp">... </span>    <span class="n">value</span> <span class="o">=</span> <span class="n">four_times_sum_inv_odds</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-22"></a><span class="gp">... </span>    <span class="k">print</span> <span class="s">&quot;At step </span><span class="si">%s</span><span class="s"> value is </span><span class="si">%0.10f</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-23"></a><span class="gp">...</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-24"></a><span class="go">At step 1 value is 0.0000000000</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-25"></a><span class="go">At step 2 value is 4.0000000000</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-26"></a><span class="go">At step 3 value is 2.6666666667</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-27"></a><span class="go">At step 4 value is 3.4666666667</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-28"></a><span class="go">At step 5 value is 2.8952380952</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-29"></a><span class="go">At step 6 value is 3.3396825397</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-30"></a><span class="go">At step 7 value is 2.9760461760</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-31"></a><span class="go">At step 8 value is 3.2837384837</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-32"></a><span class="go">At step 9 value is 3.0170718171</span>
</pre>
</div>
<p>Now we can graph it:</p>
<div class="highlight">
<pre><a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-1"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">pyplot</span><span class="o">.</span><span class="n">clf</span><span class="p">()</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-2"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">N</span> <span class="o">=</span> <span class="mi">30</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-3"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">xs</span> <span class="o">=</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="n">N</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-4"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">pyplot</span><span class="o">.</span><span class="n">axhline</span><span class="p">(</span><span class="n">numpy</span><span class="o">.</span><span class="n">pi</span><span class="p">,</span> <span class="n">linewidth</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s">&#39;r&#39;</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-5"></a><span class="go">&lt;matplotlib.lines.Line2D object at 0xa38060c&gt;</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-6"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">pyplot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xs</span><span class="p">,</span> <span class="p">[</span><span class="n">sqrt_six_times_sum_inv_squares</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">xs</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s">&#39;b&#39;</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-7"></a><span class="go">[&lt;matplotlib.lines.Line2D object at 0xa1a92cc&gt;]</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-8"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">pyplot</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">xs</span><span class="p">,</span> <span class="p">[</span><span class="n">four_times_sum_inv_odds</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">xs</span><span class="p">],</span> <span class="n">color</span><span class="o">=</span><span class="s">&#39;g&#39;</span><span class="p">)</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-9"></a><span class="go">[&lt;matplotlib.lines.Line2D object at 0xa38096c&gt;]</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-10"></a><span class="gp">&gt;&gt;&gt; </span><span class="n">pyplot</span><span class="o">.</span><span class="n">axis</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="n">N</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">4</span><span class="p">])</span>
<a name="2012-03-pi-day-code.py-fn-idio-pycon-pyg-11"></a><span class="go">[0, 30, 2, 4]</span>
</pre>
</div>
<p><img alt="graph of approximation of pi using sum of inverse squares and Gregory-Leibniz series" src="https://s3.amazonaws.com/blogdexyit-2012-03/2012--03--pi-day--pi2.png" /></p>
<p>There&#8217;s more information about approximating pi on <a href="http://en.wikipedia.org/wiki/Approximations_of_%CF%80">this wikipedia page</a>. You can get the source code for this blog post and play around with it <a href="https://github.com/ananelson/dexy-blog/tree/master/2012/03/pi-day">on github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dexy.it/522/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blogging with WordPress and Dexy</title>
		<link>http://blog.dexy.it/518</link>
		<comments>http://blog.dexy.it/518#comments</comments>
		<pubDate>Wed, 14 Mar 2012 01:00:58 +0000</pubDate>
		<dc:creator>ana</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.dexy.it/?p=518</guid>
		<description><![CDATA[For a developer, trying to blog about code is a frustrating process. WYSIWYG content editors mangle code and whitespace. Tools like gist and other code-snippet displays can help, but they also distance your code from your writing. With Dexy, we can write blog posts that incorporate code just where we want it, in the format ...]]></description>
				<content:encoded><![CDATA[<p>For a developer, trying to blog about code is a frustrating process. WYSIWYG content editors mangle code and whitespace. Tools like gist and other code-snippet displays can help, but they also distance your code from your writing. With Dexy, we can write blog posts that incorporate code just where we want it, in the format we want it, and with confidence that the code we are writing is correct and easy to modify as we go.</p>
<p>In this tutorial we&#8217;ll walk through creating and then modifying a WordPress blog post. All the features mentioned in this blog post are available in Dexy 0.5.7. In order to post content to WordPress we will use its XMLRPC API, so before you try this yourself make sure you have enabled this option; it is disabled by default.</p>
<p><span id="more-518"></span></p>
<p>We&#8217;ll start in an empty directory. We need to configure our directory to know where our WordPress installation is, and to provide our username and password. Fortunately Dexy&#8217;s new filter commands make this really easy. The <code>create_keyfile</code> command from the WordPress filter will create the configuration file we need to store our credentials:</p>
<div class="highlight">
<pre><span class="gp">$</span> dexy <span class="nb">help</span> -on fcmd
<span class="go">====================</span>
<span class="go">Help for &#39;dexy fcmd&#39;</span>
<span class="go">====================</span>
<span class="go">   Run a command defined in a dexy filter.</span>
<span class="go">   Arguments:</span>
<span class="go">      alias - The alias of the filter which defines the custom command,</span>
<span class="go">       [required] e.g. &#39;dexy fcmd --alias &lt;value&gt;&#39;</span>
<span class="go">      cmd - The name of the command to run,</span>
<span class="go">       [required] e.g. &#39;dexy fcmd --cmd &lt;value&gt;&#39;</span>
<span class="go">      help - If true, just print docstring rather than running command</span>
<span class="go">       [optional, defaults to &#39;False&#39;] e.g. &#39;dexy fcmd --help False&#39;</span>
<span class="go">   Keyword Arguments:</span>
<span class="go">      Additional arguments to be passed to the command</span>
<span class="gp">$</span> dexy fcmd -alias wp -cmd create_keyfile -help
<span class="go">   Creates a key file for WordPress in the local directory.</span>
</pre>
</div>
<p>We could also call the <code>create_keyfile</code> filter command on the ApiFilter classs (the parent class of WordPressFilter), and this would create a keyfile in the user&#8217;s home directory that we could use to store all our API credentials:</p>
<div class="highlight">
<pre><span class="gp">$</span> dexy fcmd -alias apis -cmd create_keyfile -help
<span class="go">   Creates a key file in location specified by MASTER_API_KEY_FILE.</span>
</pre>
</div>
<p>The user-wide approach is usually more convenient, since you can run your dexy scripts from anywhere and only need to have your credentials in one place. On the other hand, per-project config is useful if you need to override the defaults to post to a different blog or if you prefer to keep the credentials closer to where you will be using them.</p>
<p>Now we&#8217;ll call the filter command:</p>
<div class="highlight">
<pre><span class="gp">$</span> dexy fcmd -alias wp -cmd create_keyfile
<span class="gp">$</span> ls -l .dexyapis
<span class="go">-rw-r--r-- 1 ana ana 108 2012-03-14 01:06 .dexyapis</span>
</pre>
</div>
<p>This has created a JSON file named .dexyapis which looks like this:</p>
<pre>
{
    "wordpress": {
        "password": "TODO", 
        "url": "TODO", 
        "username": "TODO"
    }
}
</pre>
<p>You should replace the TODO items with the values appropriate for your website. The url required is the base url for your blog. Here is the config file that I used to create this example:</p>
<pre>
{
    "wordpress" : {
        "url" : "http://dexydemo.wordpress.com",
        "username" : "$WP_USERNAME",
        "password" : "$WP_PASSWORD"
    }
}

</pre>
<p>You&#8217;ll notice that I didn&#8217;t actually type my username and password into the .dexyapis file. You can type your actual username and password, or if you have environment variables set up to store your useranme and password then you can put references to environment variables by starting with a $, and the ApiFilter will fetch these for you. The advantage of using environment variables is that you can commit your <code>.dexyapis</code> file to your project repository without committing sensitive information.</p>
<p>Let&#8217;s test this out to make sure it&#8217;s working before we actually start writing our blog post. Let&#8217;s get a list of all the filter commands that are provided by the WordPressFilter:</p>
<div class="highlight">
<pre><span class="gp">$</span> dexy fcmds -alias wp
<span class="go">Filter commands defined in WordPressFilter...</span>
<span class="go">create_keyfile</span>
<span class="go">list_categories</span>
<span class="go">list_methods</span>
</pre>
</div>
<p>The <code>list_categories</code> filter command will print out the categories that are defined in your blog. It has to authenticate and visit the correct URL to do this, so it&#8217;s a good test (especially if you have custom categories set up):</p>
<div class="highlight">
<pre><span class="gp">$</span> dexy fcmd -alias wp -cmd list_categories -help
<span class="go">   List available blog post categories.</span>
<span class="gp">$</span> dexy fcmd -alias wp -cmd list_categories
<span class="go">categoryName</span>
<span class="go">Dexy</span>
<span class="go">Uncategorized</span>
</pre>
</div>
<p>Ok, now that we have that working let&#8217;s move on to an actual blog post. To start with, let&#8217;s just try to post a simple static HTML file like this:</p>
<div class="highlight">
<pre><a name="ex1-index.html-pyg-1"></a>My new blog post! yay!
</pre>
</div>
<p>We also need to create a configuration file named <code>wordpress.json</code> to hold some simple metadata about our blog post.</p>
<pre>
{
    "title" : "My First Automated Blog Post"
}

</pre>
<p>Here is the <code>.dexy</code> configuration file we need:</p>
<div class="highlight">
<pre><a name="ex1-dexy-ppjson-pyg-1"></a><span class="p">{</span>
<a name="ex1-dexy-ppjson-pyg-2"></a>    <span class="s2">&quot;index.html|wp&quot;</span><span class="o">:</span> <span class="p">{</span>
<a name="ex1-dexy-ppjson-pyg-3"></a>        <span class="s2">&quot;inputs&quot;</span><span class="o">:</span> <span class="p">[</span>
<a name="ex1-dexy-ppjson-pyg-4"></a>            <span class="s2">&quot;wordpress.json&quot;</span>
<a name="ex1-dexy-ppjson-pyg-5"></a>        <span class="p">]</span>
<a name="ex1-dexy-ppjson-pyg-6"></a>    <span class="p">}</span>
<a name="ex1-dexy-ppjson-pyg-7"></a><span class="p">}</span>
</pre>
</div>
<p>The WordPress filter alias is just <code>wp</code> (you can see the filter reference <a href="http://dexy.it/docs/filters/wp">here</a>). We specify <code>wordpress.json</code> as an input so that if there are any changes to that file, Dexy will upload our blog post to wordpress again. You could omit this and just <code>touch</code> your blog post file to trigger an upload.</p>
<p>And that&#8217;s all we need to do to create our first blog post! Because this is a new dexy project, we need to run dexy setup:</p>
<div class="highlight">
<pre><span class="gp">$</span> dexy setup
<span class="go">Ok, we&#39;ve created directories called logs and artifacts.</span>
<span class="go">You are now ready to run dexy! If you have problems,</span>
<span class="go">please check the log file at logs/dexy.log for clues.</span>
<span class="go">Online help is available from dexy.it/help</span>
</pre>
</div>
<p>And then we can run dexy:</p>
<div class="highlight">
<pre><span class="gp">$</span> dexy -loglevel DEBUG
<span class="go">batch id is 1</span>
<span class="go">sorting 2 documents into run order, there are 1 total dependencies</span>
<span class="go">ratio of dependencies to documents is 0.5</span>
<span class="go">running Output</span>
<span class="go">running LongOutput</span>
<span class="go">running Run</span>
<span class="go">running Source</span>
<span class="go">source files saved in logs/batch-source-00001</span>
</pre>
</div>
<p>If this has completed successfully, then our <code>wordpress.json</code> has changed. It now looks like this:</p>
<pre>
{
    "postid": "163", 
    "publish": false, 
    "title": "My First Automated Blog Post"
}
</pre>
<p>The <code>postid</code> has been filled in. This is very important since next time we run this filter, we don&#8217;t want to create another blog post, we want to update this same blog post. You can fill in the postid yourself if you already have created a draft post via your WordPress admin interface. Also notice that there is a key called <code>publish</code> with a value of false. By default, we create draft blog posts, so they aren&#8217;t visible to the public yet. But, you can get a preview if you are logged in. Here&#8217;s our preview:</p>
<p><img alt="screenshot of draft blog post" src="https://s3.amazonaws.com/dexyit/screencap1.png" /></p>
<p>Let&#8217;s go ahead and publish this before we move on to creating a more interesting example. To make this visible, just change the value of <code>publish</code> from <code>false</code> to <code>true</code>, and run dexy again.</p>
<p><img alt="screenshot of published blog post" src="https://s3.amazonaws.com/dexyit/screencap2.png" /></p>
<p>Now this is published and anyone can read it.</p>
<p>Where things really get interesting is when we start making use of Dexy to create blog post content that includes code examples and results, so let&#8217;s do an example of that next.</p>
<p>One thing I&#8217;m not going to cover in this post, but will cover in detail very soon, is how to include dexy-generated images in your blog post. The <a href="http://dexy.it/docs/filters/wp/">WordPress filter</a> will actually already upload images for you to WordPress, but there is a snag. The <code>overwrite</code> option in the WordPress API is broken, so each time Dexy thinks your image has changed, another copy will be uploaded to WordPress. This clutters up your Media Library very quickly. (See <a href="http://core.trac.wordpress.org/ticket/17604">this bug report</a> for more information.) My approach is to use Amazon S3 for image hosting, and there is a <code>boto</code> filter in Dexy which will upload images to S3 and return the URL, which I can then use to reference the image. That&#8217;s how I am displaying the dexy-generated screenshots in this blog post. I&#8217;m also working on adding filters for other image and hosting services. There will be a comprehensive blog post on this topic soon, so watch this space (and if you are in a position to do anything to help that WordPress bug get fixed, please do).</p>
<p>When we include code snippets and examples, we probably want to include syntax highlighting. The approach I find easiest is to use pygments within Dexy to apply syntax highlighting, and then to have a pygments stylesheet as part of my blog CSS. If you can&#8217;t modify the CSS for your blog, then you can still use pygments with the <code>"noclasses" : true</code> option, and this will embed the styles directly.</p>
<p>If you would like to use a different syntax highlighting system, and are having trouble getting it to work, then please <a href="http://dexy.tenderapp.com">open a support ticket</a>.</p>
<p>For this example, we will tell pygments to use inline styles rather than classes, so no modification to the CSS is required (which is good since I&#8217;m doing this demo using a free wordpress.com blog, so I can&#8217;t modify the CSS).</p>
<p>We will write a short blog post that shows parallel code written in Python and JavaScript, and executed using the python REPL and the rhino interpreter respectively. Pygments has support for python console transcripts, so we will have syntax highlighting on the Python output. However, there is not (yet) a comparable highlighter for JavaScript, so we will just show the raw output and surround it with &lt;pre&gt; tags.</p>
<p>We&#8217;ll use markdown rather than HTML, so we don&#8217;t have to type as much markup. Here is the source for our blog post:</p>
<div class="highlight">
<pre><a name="ex2-index.md-pyg-1"></a><span class="x">Let&#39;s look at defining and calling functions in Python and JavaScript.</span>
<a name="ex2-index.md-pyg-2"></a>
<a name="ex2-index.md-pyg-3"></a><span class="x">Here is an example of defining a function in Python:</span>
<a name="ex2-index.md-pyg-4"></a>
<a name="ex2-index.md-pyg-5"></a><span class="cp">{{</span> <span class="nv">d</span><span class="o">[</span><span class="s1">&#39;example.py|idio|pycon|pyg&#39;</span><span class="o">][</span><span class="s1">&#39;define-function&#39;</span><span class="o">]</span> <span class="cp">}}</span><span class="x"></span>
<a name="ex2-index.md-pyg-6"></a>
<a name="ex2-index.md-pyg-7"></a><span class="x">Here is how this function might be defined in JavaScript:</span>
<a name="ex2-index.md-pyg-8"></a>
<a name="ex2-index.md-pyg-9"></a><span class="x">&lt;pre&gt;</span>
<a name="ex2-index.md-pyg-10"></a><span class="cp">{{</span> <span class="nv">d</span><span class="o">[</span><span class="s1">&#39;example.js|idio|rhinoint&#39;</span><span class="o">][</span><span class="s1">&#39;define-function&#39;</span><span class="o">]</span> <span class="cp">}}</span><span class="x"></span>
<a name="ex2-index.md-pyg-11"></a><span class="x">&lt;/pre&gt;</span>
<a name="ex2-index.md-pyg-12"></a>
<a name="ex2-index.md-pyg-13"></a><span class="x">Now we&#39;ll call this function in each language:</span>
<a name="ex2-index.md-pyg-14"></a>
<a name="ex2-index.md-pyg-15"></a><span class="cp">{{</span> <span class="nv">d</span><span class="o">[</span><span class="s1">&#39;example.py|idio|pycon|pyg&#39;</span><span class="o">][</span><span class="s1">&#39;call-function-1&#39;</span><span class="o">]</span> <span class="cp">}}</span><span class="x"></span>
<a name="ex2-index.md-pyg-16"></a><span class="x">&lt;pre&gt;</span>
<a name="ex2-index.md-pyg-17"></a><span class="cp">{{</span> <span class="nv">d</span><span class="o">[</span><span class="s1">&#39;example.js|idio|rhinoint&#39;</span><span class="o">][</span><span class="s1">&#39;call-function-1&#39;</span><span class="o">]</span> <span class="cp">}}</span><span class="x"></span>
<a name="ex2-index.md-pyg-18"></a><span class="x">&lt;/pre&gt;</span>
<a name="ex2-index.md-pyg-19"></a>
<a name="ex2-index.md-pyg-20"></a><span class="x">And again, with different arguments:</span>
<a name="ex2-index.md-pyg-21"></a>
<a name="ex2-index.md-pyg-22"></a><span class="cp">{{</span> <span class="nv">d</span><span class="o">[</span><span class="s1">&#39;example.py|idio|pycon|pyg&#39;</span><span class="o">][</span><span class="s1">&#39;call-function-2&#39;</span><span class="o">]</span> <span class="cp">}}</span><span class="x"></span>
<a name="ex2-index.md-pyg-23"></a><span class="x">&lt;pre&gt;</span>
<a name="ex2-index.md-pyg-24"></a><span class="cp">{{</span> <span class="nv">d</span><span class="o">[</span><span class="s1">&#39;example.js|idio|rhinoint&#39;</span><span class="o">][</span><span class="s1">&#39;call-function-2&#39;</span><span class="o">]</span> <span class="cp">}}</span><span class="x"></span>
<a name="ex2-index.md-pyg-25"></a><span class="x">&lt;/pre&gt;</span>
</pre>
</div>
<p>We&#8217;ll apply the jinja and markdown filters first, then post to wordpress. We also have several inputs, including a python script and a JavaScript example. Here is the <code>.dexy</code> config:</p>
<div class="highlight">
<pre><a name="ex2-dexy-ppjson-pyg-1"></a><span class="p">{</span>
<a name="ex2-dexy-ppjson-pyg-2"></a>    <span class="s2">&quot;example.js|idio|rhinoint&quot;</span><span class="o">:</span> <span class="p">{},</span> 
<a name="ex2-dexy-ppjson-pyg-3"></a>    <span class="s2">&quot;example.py|idio|pycon|pyg&quot;</span><span class="o">:</span> <span class="p">{</span>
<a name="ex2-dexy-ppjson-pyg-4"></a>        <span class="s2">&quot;pygments&quot;</span><span class="o">:</span> <span class="p">{</span>
<a name="ex2-dexy-ppjson-pyg-5"></a>            <span class="s2">&quot;noclasses&quot;</span><span class="o">:</span> <span class="kc">true</span>
<a name="ex2-dexy-ppjson-pyg-6"></a>        <span class="p">}</span>
<a name="ex2-dexy-ppjson-pyg-7"></a>    <span class="p">},</span> 
<a name="ex2-dexy-ppjson-pyg-8"></a>    <span class="s2">&quot;index.md|jinja|markdown|wp&quot;</span><span class="o">:</span> <span class="p">{</span>
<a name="ex2-dexy-ppjson-pyg-9"></a>        <span class="s2">&quot;allinputs&quot;</span><span class="o">:</span> <span class="kc">true</span>
<a name="ex2-dexy-ppjson-pyg-10"></a>    <span class="p">},</span> 
<a name="ex2-dexy-ppjson-pyg-11"></a>    <span class="s2">&quot;wordpress.json&quot;</span><span class="o">:</span> <span class="p">{}</span>
<a name="ex2-dexy-ppjson-pyg-12"></a><span class="p">}</span>
</pre>
</div>
<p>We will also tweak our wordpress.json to change the title of our blog post, and assign it to a category:</p>
<pre>
{
    "categories": [
        "Dexy"
    ], 
    "postid": "163", 
    "publish": true, 
    "title": "My Fancier Automated Blog Post"
}
</pre>
<p>And, here&#8217;s the screenshot of our updated blog post:</p>
<p><img alt="screenshot of blog post with code examples" src="https://s3.amazonaws.com/dexyit/screencap3.png" /></p>
<p>If you are new to Dexy, then reviewing tutorials <a href="/docs/tutorials/0-hello-world">0</a> and <a href="/docs/tutorials/1-python">1</a> will help you understand how the HTML for that blog post was created.</p>
<p>That&#8217;s all for this tutorial! You can check out the source code of this blog post at <a href="https://github.com/ananelson/dexy-blog/tree/master/2012/03/blogging-with-wordpress">github</a>. If you have any questions please leave a comment, or if you need help getting this to work please open a <a href="http://dexy.tenderapp.com">support ticket</a>. You can also download an <a href="https://s3.amazonaws.com/dexyit/wordpress-template.tgz">example project directory</a> like the one described here to help you get started (although for learning it&#8217;s better to do it yourself).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dexy.it/518/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dexy 0.4.1</title>
		<link>http://blog.dexy.it/495</link>
		<comments>http://blog.dexy.it/495#comments</comments>
		<pubDate>Fri, 30 Sep 2011 02:00:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Releases]]></category>

		<guid isPermaLink="false">http://blog.dexy.it/?p=495</guid>
		<description><![CDATA[Dexy 0.4.1 is out. There were some major behind-the-scenes changes in Dexy 0.4.0 which came out earlier this week, so many that I&#8217;m not going to try to write them up now. In 0.4.1, notable new features are: Pygments stylesheets for HTML and LaTeX are now available within the Jinja filter. This means you don&#8217;t ...]]></description>
				<content:encoded><![CDATA[<p>Dexy 0.4.1 is out. There were some major behind-the-scenes changes in Dexy 0.4.0 which came out earlier this week, so many that I&#8217;m not going to try to write them up now. In 0.4.1, notable new features are:</p>
<ul>
<li>Pygments stylesheets for HTML and LaTeX are now available within the Jinja filter. This means you don&#8217;t have to make a separate stylesheet, you can insert the styles directly into your LaTeX document or HTML header (<a href="https://github.com/ananelson/dexy-templates/blob/master/latex-article-python/template/_header.tex">LaTeX example</a>). Or, you can use Dexy to generate a stylesheet so you always have the most up-to-date style definitions and can easily change them.</li>
<li>Virtual files are now more &#8216;virtual&#8217;. Previously if you wanted to create a .tgz or .zip archive from files dexy has generated, you needed to create a dummy empty file. Now you can just say &#8220;@archive.tgz|tgz&#8221; and a file with that name will be created for you (<a href="https://github.com/ananelson/dexy-templates/blob/master/latex-article-python/.dexy#L5">example</a>).</li>
<li>Filters have been added for PythonMagick and imlib2. I&#8217;ve run into some problems with PythonMagick, perhaps because I&#8217;ve had to install an older version, but the basic filters do work and they have been written so it&#8217;s easy to subclass the filter and just specify actions on the &#8216;image&#8217; object. The imlib2 filters follow a similar pattern. I&#8217;ll be using these to add a template gallery to the Dexy website soon, so expect a blog post with more detail.</li>
<li>Dexy now has basic support for accessing files in remote git repositories. If you have the GitPython package installed, then you can specify a repository URL and a path and Dexy will fetch this file for you. Fancy stuff like specifying a particular commit will be coming soon.</li>
<li>Now if you have an &#8216;allinputs&#8217; document in a subdirectory, this document will be available to any &#8216;allinputs&#8217; documents in parent directories. So, say, your website index page can have access to PDF pages in a subdirectory, without needing to list them explicitly as inputs.</li>
</ul>
<p>Something else to note is that Dexy development has moved over to Github, and the Bitbucket repositories are going to be decommissioned soon. More updates on this, new documentation and all other Dexy news coming soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dexy.it/495/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wolfram&#8217;s Computable Document Format and Dexy</title>
		<link>http://blog.dexy.it/493</link>
		<comments>http://blog.dexy.it/493#comments</comments>
		<pubDate>Thu, 21 Jul 2011 20:36:26 +0000</pubDate>
		<dc:creator>ana</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.dexy.it/?p=493</guid>
		<description><![CDATA[This morning, several people pointed me to Wolfram&#8217;s Computable Document Format asking whether it is a direct competitor to Dexy. In short, no. CDF documents created using Mathematica have some superficial resemblances to documents created using Dexy, but there are many significant differences. The Computable Document Format (CDF) is a document format with a published, ...]]></description>
				<content:encoded><![CDATA[<p>This morning, several people pointed me to Wolfram&#8217;s <a href="http://www.wolfram.com/cdf/">Computable Document Format</a> asking whether it is a direct competitor to <a href="http://dexy.it">Dexy</a>. In short, no. CDF documents created using Mathematica have some superficial resemblances to documents created using Dexy, but there are many significant differences.</p>
<p>The Computable Document Format (CDF) is a document format with a published, open specification (apparently, although I haven&#8217;t been able to actually find this specification as yet). Right now the only way to create CDF documents is by using Mathematica, and the only way to view CDF documents is by using Wolfram&#8217;s CDF viewer.</p>
<p>Here is a summary of some of the differences between Mathematica/CDF and Dexy:</p>
<p><strong>Free vs. Commercial</strong></p>
<p>The most obvious difference is that Dexy is free software. For now, in order to create CDF documents, you must have Mathematica. Even after paying your Mathematica license fee, you may need to pay more in order to distribute the CDF documents you create. It&#8217;s free to give away your CDF documents (your readers will have to put up with a Wolfram splash screen), but you can&#8217;t sell or even prevent others from republishing your blog posts without paying. Also &#8220;Enhanced capabilities, including import/export of external data, arbitrary input fields, dialog windows, and file saving&#8221; cost extra. Yep, this solution for &#8220;reproducibility&#8221; won&#8217;t let you export the data (unless Wolfram provides the data) unless you pay up.</p>
<p><strong>Choice of Output Formats</strong></p>
<p>Wolfram&#8217;s Computable Document Format is a document format. Dexy is a tool which lets you output in basically any document format which can be scripted or compiled. In the sense that you can publish CDF documents for viewing on the web (except, for now, on Linux), on the Desktop, and for iPad/mobile devices (these are &#8220;coming soon&#8221;), then CDF does give you some choice in output formats. However, all of these options require your user to download and install new software. Currently, this software is 231 MB in size. Big enough that I cannot download it at present as I am travelling.</p>
<p>Right now the only way to author CDF documents is to use Mathematica, and the only way to view CDF documents is to use Wolfram&#8217;s viewer. If there were an open source authoring tool to create CDF documents that did not depend on Mathematica code, well, then CDF would simply be another output option for Dexy.</p>
<p><strong>Reusability</strong></p>
<p>One of the things that differentiates Dexy from most other literate programming frameworks is the decoupling of code and documents. With Dexy, your code lives in code files which can be located anywhere, even in-situ in your project. You simply pull code into your document when and where you need it, via filters which transform it in various ways. This means you can write an example script and re-use this script in several places, say a blog post, a tutorial, a research paper and a book. You can just show code, actually run it, or both.</p>
<p>Mathematica-created CDFs use the traditional 1:1 paradigm of having you write your code within your document. So your code is embedded and can really only be used in that one place. This may be a little simpler and more intuitive, especially for non-programmers, but it seriously limits what you can do. (I&#8217;m sure there are workarounds but this defeats the purpose.)</p>
<p><strong>Interactivity</strong></p>
<p>The CDF format is highly interactive. You can tweak parameters and watch how this changes a graph. That is cool, and may be really useful for getting people interested in your data, but interactivity is not typically compatible with reproducibility.</p>
<p>A nice exception to this is an approach like <a href="http://www.commentspace.net/">http://www.commentspace.net/</a> where you can explore interactive data, snapshot it so others can see how you were viewing it, and comment.</p>
<p>Interactivity without a &#8220;save as source&#8221; option means that readers are simply consumers. A student interacting with your model using CDF can&#8217;t write a report about it, a customer can&#8217;t change some specifications and send you back a document with &#8220;I think this is more realistic&#8221;. They can take screenshots perhaps, but these are not reproducible.</p>
<p>Documents created using Dexy are static, not interactive (unless you use Dexy to feed data and source code to, say, a flash app where the results can be manipulated). However, in many circumstances this is preferable. With Dexy you can manipulate source code and see the results quickly, rather than instantly, and if you share your sources anyone can interact with your data and source at a deeper, more meaningful level than just playing around with rotating a 3D model, as fun as that might be. And if you use open source software, then people don&#8217;t have to pay <em>someone else</em> a license fee to engage with <em>your</em> content.</p>
<p><strong>Choice</strong></p>
<p>Languages supported by Mathematica: Mathematica</p>
<p>Languages/Systems supported by Dexy (so far)*: Python, R, Ruby, Java, PHP, Erlang, JavaScript, JRuby, Jython, Dot, C, C++, Clojure, Ragel</p>
<p>Formats supported by CDF: CDF</p>
<p>Formats supported by Dexy (so far)*: plain text, markdown, textile, HTML, LaTeX, Asciidoc</p>
<p>*If what you want isn&#8217;t listed, get in touch.</p>
<p><strong>Transparency</strong></p>
<p>When you document your scripts with Dexy, you can choose to document the source code underlying the implementations of the functions you call, assuming these are open source. Basing scientific computations on a closed-source interpreter means having to take Mathematica&#8217;s word for the correctness of its implementation, and having to reply on Mathematica&#8217;s documentation for the specifics of that implementation.</p>
<p><strong>It&#8217;s Not All Bad</strong></p>
<p>I have been very harsh here on Mathematica/CDF. That is not to say that it isn&#8217;t a highly streamlined and convenient package which I&#8217;m sure will provide a lot of value to business users. Open source projects can always use more inspiration on how to make data management and reporting a more seamless part of the process. However, for the sake of science and learning, a closed source pay-to-play engine with prohibitively large dependencies is going to make reproducibility and meaningful interactivity worse, not better.</p>
<p>I will absolutely agree that for a non-programmer, and probably even for most programmers, creating a document for the first time in Mathematica is probably a much faster and smoother process than doing the same in Dexy. Dexy does have a learning curve, although I am always working to make this as gentle as possible. For some people, this convenience will trump all other considerations. However for reproducibility, flexibility and control over your data and source code, these other considerations are very weighty indeed.</p>
<p>When we eventually get to look at the open specification for CDF, then it may be that this turns out to be a useful standalone document format which, once decoupled from Mathematica, could provide the benefits of interactivity to open source projects, and hopefully this would enable the development of features to promote iterative feedback and learning. This would depend on the standard itself and also the attitude of Wolfram towards CDF being a genuinely open standard. If this did happen, unfortunately Mathematica users would probably be left out as their licensing terms would preclude using these features.</p>
<p>Please note that due to the huge download size I was unable to actually run a CDF viewer, and while I have done my best to be accurate, it it possible that I have some details wrong (since I also have no way of running Mathematica). Please, please let me know in the comments if I have made any inaccurate statements about how Mathematica or CDF works.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dexy.it/493/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lights, Camera, Stack Trace</title>
		<link>http://blog.dexy.it/407</link>
		<comments>http://blog.dexy.it/407#comments</comments>
		<pubDate>Tue, 24 May 2011 23:07:20 +0000</pubDate>
		<dc:creator>ana</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.dexy.it/?p=407</guid>
		<description><![CDATA[I have been setting up a new computer (yay!) which means installing a bunch of software (boo!). It&#8217;s actually been a while, at least in software years, since I did this, so I&#8217;m enjoying some pleasant surprises (like Homebrew, and having no reason to need MySQL yet) along with the unpleasant bumps along the way. ...]]></description>
				<content:encoded><![CDATA[<p>I have been setting up a new computer (yay!) which means installing a bunch of software (boo!). It&#8217;s actually been a while, at least in software years, since I did this, so I&#8217;m enjoying some pleasant surprises (like Homebrew, and having no reason to need MySQL yet) along with the unpleasant bumps along the way.</p>
<p>I&#8217;ve also been chatting with several new and prospective Dexy users, and trying to get a feel for what issues people encounter when they try to install and run Dexy and start working through the tutorials. It&#8217;s great when I can provide just a few small tips to help people get started, but of course I have no idea how many other people run into those small little roadblocks and decide &#8220;oh, I don&#8217;t have time to troubleshoot this now, I&#8217;ll come back to this later&#8221; or even &#8220;that error looks scary, I&#8217;m never running this program again&#8221;. I do use feedback to refine tutorials and improve error messages, but I know I&#8217;m not seeing all the potential problems.</p>
<p>On the other side of this, I had an incredibly frustrating Sunday with a not-quite-polished web application, and a particularly frustrating afternoon today trying to figure out how to set up my EC2 environment for command line use. In both cases I really wanted to provide constructive feedback on my experiences so the app and documentation (respectively) could be improved, but by the time I had solved the issues in question I realized that (a) I really didn&#8217;t want to spend any more time on them and (b) I probably couldn&#8217;t remember and reconstruct all the issues I ran into, so it wouldn&#8217;t have been a terribly useful exercise for me to provide feedback, without a lot of work (GOTO a).</p>
<p>However, out of frustration came an idea. While last week I was toying with the idea of suggesting that prospective Dexy users arrange a time and Skype me when they are first attempting to use Dexy so I can provide real-time assistance, now I have refined this to the following idea which I am going to put into practice:</p>
<p>Whenever you are about to install or upgrade software, use new or recently upgraded software, or try to do something unfamiliar, or just any time your spidey senses are tingling, start a screen recorder. Preferably one that catches sound and, ideally, webcam video. Use the audio to explain what you are doing as you do it. When you are finished, if all has gone well, then you can just delete the recording. If all has not gone well, then you can watch the recording, note down the times at which important things happen, and email the developers with your documented tale of woe.</p>
<p>Will this be practical? I have no idea. Will this backfire with users not bothering to do as much troubleshooting as they otherwise might? Not sure about that either.</p>
<p>I know that I, as a developer, want to know about people having bad experiences with my software. Many of these experiences will have nothing to do with my software, but I still want to know about them.</p>
<p>I know that I, as a user, want to be able to express my frustration when things go wrong to the creators of software. I want to do this in a constructive way, but part of me also wants to convey the very real cost that poor design or poor documentation imposes. I also want to be able to easily illustrate ways in which software could be made more beneficial, and to be able to provide accurate and useful feedback when I encounter an issue.</p>
<p>So, I personally will be doing this screen recording experiment. And, if you are a Dexy user or are about to try Dexy, I encourage you to do it too. There&#8217;s no need to send me links to videos where everything went well (unless you&#8217;ve done something very cool with Dexy and want to tell me about it &#8211; then please do!) but I encourage you to send me links to videos that illustrate a problem or roadblock. Or, if you have suggestions for improving the tutorials or other documentation. Preferably with an explanatory email telling me what you were attempting to do (if it&#8217;s not clear from the voiceover), and I&#8217;d really appreciate timestamps where important things happen. I can&#8217;t promise to watch everything, but I will do what I can. And, please use this as a supplement to rather than replacement for the usual information you submit with a support request.</p>
<p>I have started a <a title="Screencasting Tools" href="http://blog.dexy.it/screencasting-tools">list of screen recording software</a> with an emphasis on free, multi-platform software. Please feel free to make additional suggestions in the comments. I suggest people do a trial run to ensure that the software doesn&#8217;t place an undue load on your machine, and that your console screen is actually readable (a text-based, searchable console transcript is probably a good idea anyway &#8211; <a href="http://www.gnu.org/software/screen/manual/html_node/Log.html#Log">easy</a> if you&#8217;re using GNU screen). A console transcript is also an option if you don&#8217;t want to record a video, and you can delete any sensitive content this way too.</p>
<p>If you upload your screencast to a hosted service, take note of their Ts and Cs in relation to the ownership of your upload. Take care that your screencasts don&#8217;t include any sensitive information like passwords or API keys, or any dodgy browser history that you don&#8217;t want the world to see. I certainly won&#8217;t rebroadcast anybody&#8217;s screencast without their explicit consent, or mention anybody by name [assuming recordings are in good faith, that is], but I will take note of the OS and software you are using in order to better tailor training materials, and I may discuss these in an anonymized way like &#8220;I notice a number of people who submitted screencasts to me weren&#8217;t using GNU Screen, let me tell you what a great utility this is.&#8221; If that bothers you, then, well, probably best not to send me anything since it will be hard for me to unsee. If you are happy for me to publish your screencast on the Dexy blog or elsewhere, then let me know and this will make things quicker for me in the event that I want to share some examples in future. If you give me suggestions for documentation improvements, I will assume that you want me to go ahead and make use of these.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dexy.it/407/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.780 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2013-05-19 18:25:31 -->
<!-- Compression = gzip -->