<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>A mind less ordinary &#187; PHP</title>
	<atom:link href="http://www.dmi.me.uk/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dmi.me.uk/blog</link>
	<description></description>
	<lastBuildDate>Wed, 23 Nov 2011 16:01:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>
		<item>
		<title>Creating a presentation with LaTeX and powerdot</title>
		<link>http://www.dmi.me.uk/blog/2010/11/08/creating-a-presentation-with-latex-and-powerdot/</link>
		<comments>http://www.dmi.me.uk/blog/2010/11/08/creating-a-presentation-with-latex-and-powerdot/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 12:52:59 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[HOWTOs]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Talks]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[powerdot]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[talk]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[useful]]></category>

		<guid isPermaLink="false">http://www.dmi.me.uk/blog/?p=254</guid>
		<description><![CDATA[A few days ago, I gave a talk at PHP London about using OAuth with PHP. I started out building it in OpenOffice, but quickly found the process annoying, especially considering that I wanted to export to PDF with progressive disclosure on some slides. After putting the skeleton of the talk together, I decided to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.phplondon.org/wiki/November_4th_2010" target="_blank">A few days ago</a>, I gave a talk at <a href="http://www.phplondon.org/" target="_blank">PHP London</a> about <a href="http://slidesha.re/a31GKM" target="_blank">using OAuth with PHP</a>. I started out building it in OpenOffice, but quickly found the process annoying, especially considering that I wanted to export to PDF with progressive disclosure on some slides. After putting the skeleton of the talk together, I decided to move to something else instead.</p>
<p>I've had some experience with the <a href="http://www.latex-project.org/" target="_blank">LaTeX</a> document typesetting system before, having used it quite a lot during university for <a title="Insight semantic file system" href="http://www.dmi.me.uk/code/insight/" target="_blank">my final project</a>'s <a title="Insight final report" href="http://www.dmi.me.uk/code/insight/final-report.pdf" target="_blank">reports</a> and presentation. I used the <code class="codecolorer text default"><span class="text">beamer</span></code> package before, but this time I found its styles too restrictive. The three major presentation packages that I'm aware of are <a title="The prosper package" href="http://ctan.org/tex-archive/macros/latex/contrib/prosper/" target="_blank"><code class="codecolorer text default"><span class="text">prosper</span></code></a> (which I believe is quite old now), <a title="The beamer package" href="http://ctan.org/tex-archive/macros/latex/contrib/beamer/" target="_blank"><code class="codecolorer text default"><span class="text">beamer</span></code></a>, and <a title="The powerdot package" href="http://ctan.org/tex-archive/macros/latex/contrib/powerdot/" target="_blank"><code class="codecolorer text default"><span class="text">powerdot</span></code></a>. After some investigation (looking primarily at features and visual styles), I settled for <code class="codecolorer text default"><span class="text">powerdot</span></code>. I will explain the basics of putting a presentation together in the rest of this post, but be warned: it assumes some basic familiarity with LaTeX, and I don't explain everything!<br />
<span id="more-254"></span></p>
<h2>Starting out</h2>
<p>The first steps when creating a slideshow are different to a regular document. In standard LaTeX, you open the document and just start writing, adding part, chapter and section headings as necessary. Creating a presentation is necessarily different. Here is a skeleton presentation:</p>
<pre>
<div class="codecolorer-container latex twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="latex codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #E02020; ">\</span><span style="color: #800000;">documentclass</span><span style="color: #E02020; ">[</span><span style="color: #C08020; font-weight: normal;">style=paintings</span><span style="color: #E02020; ">]{</span><span style="color: #2020C0; font-weight: normal;">powerdot</span><span style="color: #E02020; ">}</span><br />
<span style="color: #2C922C; font-style: italic;">% Presentation metadata</span><br />
<span style="color: #E02020; ">\</span><span style="color: #800000;">title</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">My First Powerdot Presentation<span style="color: #E02020; ">}</span><br />
<span style="color: #E02020; ">\</span><span style="color: #800000;">author</span><span style="color: #E02020; ">{</span>Joe Bloggs<span style="color: #E02020; ">}</span><br />
<span style="color: #E02020; ">\</span><span style="color: #800000;">date</span><span style="color: #E02020; ">{</span>8th November 2010<span style="color: #E02020; ">}</span><br />
<br />
<span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span><br />
<br />
&nbsp; <span style="color: #2C922C; font-style: italic;">% title slide</span><br />
&nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">maketitle</span><br />
<br />
&nbsp; <span style="color: #2C922C; font-style: italic;">% section: title takes up full slide</span><br />
&nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">section</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;">First section</span><span style="color: #E02020; ">}</span><br />
<br />
&nbsp; <span style="color: #2C922C; font-style: italic;">% text slide:</span><br />
&nbsp; <span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">slide</span><span style="color: #E02020; ">}{</span>Slide Title<span style="color: #E02020; ">}</span><br />
&nbsp; &nbsp; <span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">itemize</span><span style="color: #E02020; ">}</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> This is an item<br />
&nbsp; &nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> This is also an item<br />
&nbsp; &nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> Finally, a third item in my list<br />
&nbsp; &nbsp; <span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">itemize</span><span style="color: #E02020; ">}</span><br />
&nbsp; <span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">slide</span><span style="color: #E02020; ">}</span><br />
<br />
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">document</span></span><span style="color: #E02020; ">}</span></div></div>
</pre>
<p>Doesn't look too bad, right? The presentation is contained within the <code class="codecolorer text default"><span class="text">document</span></code>, and each slide is contained within a <code class="codecolorer text default"><span class="text">slide</span></code> environment. The <code class="codecolorer latex default"><span class="latex"><span style="color: #E02020; ">\</span><span style="color: #800000;">section</span></span></code> command now builds a standalone slide, as does the initial <code class="codecolorer latex default"><span class="latex"><span style="color: #E02020; ">\</span><span style="color: #800000;">maketitle</span></span></code>.</p>
<p>Almost anything that you can include in a normal document can be used on a slide, including tables and images, and tricks like using <code class="codecolorer latex default"><span class="latex"><span style="color: #E02020; ">\</span><span style="color: #800000;">vspace</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\stretch</span>{1}</span><span style="color: #E02020; ">}</span></span></code> at the beginning and end of the slide to vertically centre the content.</p>
<h2>Progressive disclosure</h2>
<p>Powerdot allows you to show only parts of a slide to your audience at a time, to emphasise each point (for example), or to better illustrate the flow through a diagram. This can be accomplished in two ways: the simple <code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\pause</span></span></code> command, or the more complex and more powerful <code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\onslide</span></span></code>.</p>
<p>The simple <code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\pause</span></span></code> command takes no arguments, and simply stops anything in the slide after that command from appearing, as if content display had been "paused" at that point. It is important to note that everything following the command is typeset, in order to work out the space it would have taken up. This ensures that your slide content doesn't shift around as you go through.</p>
<pre>
<div class="codecolorer-container latex twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="latex codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">slide</span><span style="color: #E02020; ">}{</span>Progressive Disclosure<span style="color: #E02020; ">}</span><br />
  <span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">itemize</span><span style="color: #E02020; ">}</span><br />
&nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> This is my first item<br />
&nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> This is the second item, after which we wait <span style="color: #800000; font-weight: normal;">\pause</span><br />
&nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> The third item appears on the page following the second <span style="color: #800000; font-weight: normal;">\pause</span><br />
&nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> And this fourth and final item appears on the page after the third<br />
&nbsp; <span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">itemize</span><span style="color: #E02020; ">}</span><br />
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">slide</span></span><span style="color: #E02020; ">}</span></div></div>
</pre>
<p>Note that the command can be used multiple times, and it will work just as you might expect. If you want to do something more complex (such as displaying things out of order, displaying something over multiple frames, or scoping a change to a subset of the frames) you will need to use <code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\onslide</span></span></code>.</p>
<p>This command is much more powerful, and takes two arguments: the frames on which the contents should be displayed, and the contents themselves. The example above could be rewritten:</p>
<pre>
<div class="codecolorer-container latex twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="latex codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">slide</span><span style="color: #E02020; ">}{</span>Progressive Disclosure<span style="color: #E02020; ">}</span><br />
  <span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">itemize</span><span style="color: #E02020; ">}</span><br />
&nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> This is my first item<br />
&nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> This is the second item, after which we wait<br />
&nbsp; &nbsp; <span style="color: #800000; font-weight: normal;">\onslide</span><span style="color: #E02020; ">{</span>2-<span style="color: #E02020; ">}{\</span><span style="color: #800000;">item</span> The third item appears on the page following the second<span style="color: #E02020; ">}</span><br />
&nbsp; &nbsp; <span style="color: #800000; font-weight: normal;">\onslide</span><span style="color: #E02020; ">{</span>3-<span style="color: #E02020; ">}{\</span><span style="color: #800000;">item</span> And this fourth and final item appears on the page after the third<span style="color: #E02020; ">}</span><br />
&nbsp; <span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">itemize</span><span style="color: #E02020; ">}</span><br />
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">slide</span></span><span style="color: #E02020; ">}</span></div></div>
</pre>
<p>But we could also (in theory) choose to do something more bizarre:</p>
<pre>
<div class="codecolorer-container latex twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="latex codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">slide</span><span style="color: #E02020; ">}{</span>Progressive Disclosure<span style="color: #E02020; ">}</span><br />
  <span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">itemize</span><span style="color: #E02020; ">}</span><br />
&nbsp; &nbsp; <span style="color: #800000; font-weight: normal;">\onslide</span><span style="color: #E02020; ">{</span>4-<span style="color: #E02020; ">}{\</span><span style="color: #800000;">item</span> This is my first item, and the last to appear<span style="color: #E02020; ">}</span><br />
&nbsp; &nbsp; <span style="color: #800000; font-weight: normal;">\onslide</span><span style="color: #E02020; ">{</span>3-<span style="color: #E02020; ">}{\</span><span style="color: #800000;">item</span> This is the second item, although technically the third<span style="color: #E02020; ">}</span><br />
&nbsp; &nbsp; <span style="color: #800000; font-weight: normal;">\onslide</span><span style="color: #E02020; ">{</span>2-<span style="color: #E02020; ">}{\</span><span style="color: #800000;">item</span> The third item appears on the page following the fourth<span style="color: #E02020; ">}</span><br />
&nbsp; &nbsp; <span style="color: #E02020; ">\</span><span style="color: #800000;">item</span> This fourth and final item is actually the first that is visible<br />
&nbsp; <span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">itemize</span><span style="color: #E02020; ">}</span><br />
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">slide</span></span><span style="color: #E02020; ">}</span></div></div>
</pre>
<p>The <code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\onslide</span></span></code> command has three variations. The first version, as shown above, allocates space for items that have not yet been displayed. If you add a star to the command before its arguments (<code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\onslide*</span></span></code>) then no space will be allocated. In the example above, this means that the new bullet points would appear to push the existing items downwards. If you add a plus to the command (<code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\onslide</span>+</span></code>) then the contents will always be typeset, but a different colour will be used for the item on the specified slide(s).</p>
<p>I have found <code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\onslide*</span></span></code> to be particularly useful for progressive disclosure of diagrams, where not displaying an item at all can be very important.</p>
<h2>Graphics and diagrams</h2>
<p>It is important to remember that LaTeX itself will only accept graphics in EPS format via the <code class="codecolorer latex default"><span class="latex"><span style="color: #E02020; ">\</span><span style="color: #800000;">includegraphics</span></span></code> command from the <code class="codecolorer text default"><span class="text">graphicx</span></code> package. pdfTeX will allow other formats if used directly (including PNG) but something like <code class="codecolorer text default"><span class="text">pstricks</span></code> may then become unusable. For my presentation, I used a combination of <code class="codecolorer text default"><span class="text">pstricks</span></code> diagrams and included EPS images.</p>
<p>Building diagrams in <code class="codecolorer text default"><span class="text">pstricks</span></code> gave me a major advantage that I had not foreseen: the ability to define and then re-use a picture. I used this to good effect with the diagram of the OAuth "dance", showing the data flow between the User, Consumer, and Provider. When it came to the code samples for the implementation, I kept a miniature of this diagram on each slide to remind the viewer which stages of the dance were covered by the code on the current slide. This would not have been possible to do with OpenOffice (as far as I'm aware), and it saved me a great deal of time when I made changes to the original diagram.</p>
<p>If you have never used <code class="codecolorer text default"><span class="text">pstricks</span></code>, then I highly recommend it. Although it may seem weird to specify co-ordinates in a text file rather than drawing the image graphically, it is extremely powerful and I found that I soon got used to it. It is worth remembering that some programs, like Inkscape, can actually save a vector image as a set of <code class="codecolorer text default"><span class="text">pstricks</span></code> macros.</p>
<h2>Code samples</h2>
<p>Something that's often important when building a technical presentation is including one or more code samples. It's usually nice if they are syntax-highlighted in one way or another, to make it easier to read at a glance. By the way, it is generally advised that code samples in a presentation should be dark-coloured text on a light background rather than the other way round.</p>
<p>When it comes to using code samples in <code class="codecolorer text default"><span class="text">powerdot</span></code> presentations, there are two things to be aware of. Firstly, choosing the typesetting package. I have always used the <code class="codecolorer text default"><span class="text">listings</span></code> package for code samples. It has support for a large number of languages (as well as defining your own), and it is very configurable. You can even define short-cut environments for re-using options if you are working on a multiple-language presentation, for example.</p>
<p>The second thing to remember when adding listings to the presentation is that you need to inform the <code class="codecolorer text default"><span class="text">powerdot</span></code> package that a slide has special "verbatim" content. This is done with an optional argument to the slide, <code class="codecolorer text default"><span class="text">method</span></code>. This has three possible values (<code class="codecolorer text default"><span class="text">normal</span></code>, <code class="codecolorer text default"><span class="text">direct</span></code>, and <code class="codecolorer text default"><span class="text">file</span></code>), but I have only found the first two to work reliably.</p>
<p>If the slide contains verbatim content, you must use either the <code class="codecolorer text default"><span class="text">direct</span></code> or <code class="codecolorer text default"><span class="text">file</span></code> rendering method, otherwise you will get an error. The <code class="codecolorer text default"><span class="text">file</span></code> method can easily get confused (in my experience) and so I used <code class="codecolorer text default"><span class="text">direct</span></code>. The downside is that you cannot use the <code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\pause</span></span></code> or <code class="codecolorer latex default"><span class="latex"><span style="color: #800000; font-weight: normal;">\onslide</span></span></code> commands in a <code class="codecolorer text default"><span class="text">direct</span></code>-rendered slide; they will be silently ignored.</p>
<pre>
<div class="codecolorer-container latex twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="latex codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #2020C0; font-weight: normal;"><span style="color: #0000D0; font-weight: normal;">slide</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">method=direct</span><span style="color: #E02020; ">]{</span>Hello World in C<span style="color: #E02020; ">}</span><br />
&nbsp; <span style="color: #C00000; font-weight: normal;">\begin</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">lstlisting</span><span style="color: #E02020; ">}[</span><span style="color: #C08020; font-weight: normal;">language=c,gobble=4</span><span style="color: #E02020; ">]</span><br />
&nbsp; &nbsp; #include &lt;stdio.h&gt;<br />
<br />
&nbsp; &nbsp; int main(int c, char **v) <span style="color: #E02020; ">{</span><br />
&nbsp; &nbsp; &nbsp; fprintf(stdout, &quot;Hello, world!<span style="color: #800000; font-weight: normal;">\n</span>&quot;);<br />
&nbsp; &nbsp; &nbsp; return 0;<br />
&nbsp; &nbsp; <span style="color: #E02020; ">}</span><br />
&nbsp; <span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">lstlisting</span><span style="color: #E02020; ">}</span><br />
<span style="color: #C00000; font-weight: normal;">\end</span><span style="color: #E02020; ">{</span><span style="color: #0000D0; font-weight: normal;">slide</span></span><span style="color: #E02020; ">}</span></div></div>
</pre>
<h2>Choosing and customising your style</h2>
<p>The visual style of your presentation can make a difference to how it is received. Dark text on a very light background is usually considered to be the most readable. The <code class="codecolorer text default"><span class="text">powerdot</span></code> package has <a title="Powerdot documentation" href="http://www.ctan.org/tex-archive/macros/latex/contrib/powerdot/docs/powerdot.pdf" target="_blank">a number of built-in styles</a> (pp. 21-25), and I eventually settled on a modified version of <code class="codecolorer text default"><span class="text">paintings</span></code> with the <code class="codecolorer text default"><span class="text">Charon</span></code> palette. Creating your own style is not difficult, and you have a large amount of control over how it looks. I won't go into it here, as it is already well covered by the <a title="Powerdot manual" href="http://www.ctan.org/tex-archive/macros/latex/contrib/powerdot/docs/powerdot.pdf" target="_blank">manual</a>.</p>
<h2>And finally...</h2>
<p>This is all very much a work in progress. This post was based upon my first experience of writing a presentation in LaTeX with <code class="codecolorer text default"><span class="text">powerdot</span></code>. As time goes on, I hope to build upon and standardise a visual style for both personal and company presentations. I am also prepared to send the LaTeX sources of my OAuth presentation to anyone who is interested, so please let me know either in the comments below or contact me by email or Twitter.</p>
<p>For me, the biggest advantage of LaTeX is that content comes first -- it's much easier to write a presentation without obsessing over how it looks until the very end. The better-defined your visual style, the less you have to worry about the design, and the more time you can spend making your presentation great!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmi.me.uk/blog/2010/11/08/creating-a-presentation-with-latex-and-powerdot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Modules for Apache and PHP</title>
		<link>http://www.dmi.me.uk/blog/2008/08/13/modules-for-apache-and-php/</link>
		<comments>http://www.dmi.me.uk/blog/2008/08/13/modules-for-apache-and-php/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 20:26:54 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[modules]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.dmi.me.uk/blog/?p=74</guid>
		<description><![CDATA[The number of projects I have in mind just keeps growing... I really need to get something together to organise them, and remember them! But here are two more to add to the list: an Apache module for dynamic configuration generation and a PHP framework inside an extension. Read on for a monster post with [...]]]></description>
			<content:encoded><![CDATA[<p>The number of projects I have in mind just keeps growing... I really need to get something together to organise them, and remember them! But here are two more to add to the list: an Apache module for dynamic configuration generation and a PHP framework inside an extension. Read on for a monster post with more information...</p>
<p><span id="more-74"></span></p>
<h2>Apache module</h2>
<p>The first thing I have in mind is to create an Apache 2.2 module that uses the APR (Apache Portable Runtime) to make configuration file templating easy.</p>
<p>On my server, there are a lot of very similar Apache configuration files. At the moment, they are semi-automatically generated by running a Perl script that reads the configuration from a database and then creates the output files as required. This is all well and good, but changing anything requires running the Perl script, regenerating all of the configuration files, then prodding Apache to reload its configuration. There has to be a better way, especially one that doesn't require elevated permissions like that.</p>
<p>Enter my proposed solution: <tt>mod_sqltemplate</tt>. This module will add a few extra settings and (at least) two extra sections to the standard Apache configuration. The propsed features are:</p>
<ul>
<li><tt>SQLTemplate_DBDriver «driver»</tt> – sets the APR driver to be used</li>
<li><tt>SQLTemplate_DBOpts «option-string»</tt> – options for the driver (e.g. database name, username, password...)</li>
<li><tt>SQLTemplate_Caching «on|off»</tt> – enable/disable configuration caching</li>
<li><tt>SQLTemplate_CacheDir «path»</tt> – directory in which to save cached configurations</li>
<li><tt>&lt;SQLRepeat «query»&gt;</tt> – new section, as described below</li>
<li><tt>&lt;SQLCatSet «sep» «query»&gt;</tt> – new section, as described below</li>
</ul>
<h3>SQLRepeat</h3>
<p>The <tt>SQLRepeat</tt> section is probably going to be the most-used new directive. It provides templating functionality similar to <a title="mod_macro by Fabien Coelho" href="http://cri.ensmp.fr/~coelho/mod_macro/" target="_blank"><tt>mod_macro</tt></a>, although the template variables are taken from the column names of the query rather than being explicitly specified. The section will then be repeated for each row of the resultset, substitutions occurring as required.</p>
<p>Perhaps an example would help:</p>
<pre lang="apache">&lt;SQLRepeat "SELECT id,hostname,domain FROM apache_hosts"&gt;
&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/${hostname}.${domain}
  ServerName ${hostname}.${domain}
  # ...
&lt;/VirtualHost&gt;
&lt;/SQLRepeat&gt;</pre>
<p>For this example, I've avoided the configuration directives for clarity, assuming they are specified elsewhere. Supposing the database table contains simply:</p>
<table border="0">
<tbody>
<tr>
<th>ID</th>
<th>hostname</th>
<th>domain</th>
</tr>
<tr>
<td>1</td>
<td>www</td>
<td>example.com</td>
</tr>
<tr>
<td>3</td>
<td>test</td>
<td>example.com</td>
</tr>
<tr>
<td>12</td>
<td>yourhost</td>
<td>somewhere.local</td>
</tr>
</tbody>
</table>
<p>Then this will expand to be equivalent to:</p>
<pre lang="apache">&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/www.example.com
  ServerName www.example.com
  # ...
&lt;/VirtualHost&gt;
&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/test.example.com
  ServerName test.example.com
  # ...
&lt;/VirtualHost&gt;
&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/yourhost.somewhere.local
  ServerName yourhost.somewhere.local
  # ...
&lt;/VirtualHost&gt;</pre>
<p>And so on. These sections can be nested, so if you wanted to store a list of aliases as well:</p>
<table border="0">
<tbody>
<tr>
<th>ID</th>
<th>hostid</th>
<th>alias</th>
<th>target</th>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>/icons</td>
<td>/var/www/_share/icons</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>/example</td>
<td>/var/www/_share/foo</td>
</tr>
<tr>
<td>5</td>
<td>12</td>
<td>/bar</td>
<td>/var/www/_share/foo</td>
</tr>
</tbody>
</table>
<p>You could use something like this:</p>
<pre lang="apache">&lt;SQLRepeat "SELECT id,hostname,domain FROM apache_hosts"&gt;
&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/${hostname}.${domain}
  ServerName ${hostname}.${domain}
  # ...
  &lt;SQLRepeat "SELECT alias,target FROM apache_aliases WHERE hostid=?" ${id}&gt;
    Alias "${alias}" "${target}"
  &lt;/SQLRepeat&gt;
&lt;/VirtualHost&gt;
&lt;/SQLRepeat&gt;</pre>
<p>which would then expand to:</p>
<pre lang="apache">&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/www.example.com
  ServerName www.example.com
  # ...
    Alias "/icons" "/var/www/_share/icons"
    Alias "/example" "/var/www/_share/foo"
&lt;/VirtualHost&gt;
&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/test.example.com
  ServerName test.example.com
  # ...
&lt;/VirtualHost&gt;
&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/yourhost.somewhere.local
  ServerName yourhost.somewhere.local
  # ...
    Alias "/bar" "/var/www/_share/foo"
&lt;/VirtualHost&gt;</pre>
<p>So far, so good. Something to note is that the variable names above did not conflict. If we had included "id" in the list of columns for the inner <tt>SQLRepeat</tt>, then included <tt>${id}</tt>, the module should use the innermost scope. Disambiguation should be obtained by table alias prefixing (e.g. <tt>${apache_hosts.id}</tt> or <tt>${apache_aliases.id}</tt>). Full variable names should always be specified for clarity. This also shows that if the query returns no results, the repeating section is not included, as you would expect. Also note that queries that use variable substitution should use the prepared statement format, with variables specified afterwards. Variables will be included directly, so anything that might contain spaces must be quoted.</p>
<p>However, there are some directives like <tt>ServerAlias</tt> that must be specified once with a list of space-separated values. Enter <tt>SQLCatSet</tt>...</p>
<h3>SQLCatSet</h3>
<p>This acts in a similar way to <tt>SQLRepeat</tt>, but it concatenates all of the results for each field before substituting, and it includes its content at most once. If there are no results for the query, then it will not include its content. For example, with a server aliases table like:</p>
<table border="0">
<tbody>
<tr>
<th>ID</th>
<th>hostid</th>
<th>alias</th>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td>test2.example.com</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
<td>test.example.net</td>
</tr>
<tr>
<td>5</td>
<td>12</td>
<td>*.somewhere.local</td>
</tr>
</tbody>
</table>
<p>You could use something like this:</p>
<pre lang="apache">&lt;SQLRepeat "SELECT id,hostname,domain FROM apache_hosts"&gt;
&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/${hostname}.${domain}
  ServerName ${hostname}.${domain}
  &lt;SQLCatSet " " "SELECT alias FROM apache_server_aliases WHERE hostid=?" ${id}&gt;
    ServerAlias ${alias}
  &lt;/SQLCatSet&gt;
  # ...
  &lt;SQLRepeat "SELECT alias,target FROM apache_aliases WHERE hostid=?" ${id}&gt;
    Alias "${alias}" "${target}"
  &lt;/SQLRepeat&gt;
&lt;/VirtualHost&gt;
&lt;/SQLRepeat&gt;</pre>
<p>which would then expand to:</p>
<pre lang="apache">&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/www.example.com
  ServerName www.example.com
  # ...
    Alias "/icons" "/var/www/_share/icons"
    Alias "/example" "/var/www/_share/foo"
&lt;/VirtualHost&gt;
&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/test.example.com
  ServerName test.example.com
    ServerAlias test2.example.com test.example.net
  # ...
&lt;/VirtualHost&gt;
&lt;VirtualHost *:80&gt;
  DocumentRoot /var/www/yourhost.somewhere.local
  ServerName yourhost.somewhere.local
    ServerAlias *.somewhere.local
  # ...
    Alias "/bar" "/var/www/_share/foo"
&lt;/VirtualHost&gt;</pre>
<p>This would seem to cover the major functionality needed for automatically generating configurations in a really flexible way, although I'm sure more will probably be needed at some point... like <tt>SQLIf</tt>, perhaps.</p>
<h2>PHP Framework</h2>
<p>It occurs to me that having a framework's code in PHP itself could mean that it is quite slow. It would be interesting to put together a framework in C and embedded as a module, to see if there are any memory/speed improvements possible. It might just be a case of implementing an ORM (Object Relational Model) system to begin with. Obviously, this idea is nowhere near as fully-formed!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmi.me.uk/blog/2008/08/13/modules-for-apache-and-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>
	</item>
		<item>
		<title>Overflowing with ideas</title>
		<link>http://www.dmi.me.uk/blog/2008/04/29/overflowing-with-ideas/</link>
		<comments>http://www.dmi.me.uk/blog/2008/04/29/overflowing-with-ideas/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 16:44:07 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[OpenIntegrate]]></category>
		<category><![CDATA[Partis]]></category>
		<category><![CDATA[PHP RAD system]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Braindump]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[intercommunication]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[proposals]]></category>
		<category><![CDATA[RAD]]></category>
		<category><![CDATA[web integration]]></category>

		<guid isPermaLink="false">http://www.dmi.me.uk/blog/?p=50</guid>
		<description><![CDATA[I've found myself overflowing with ideas as I try to focus on revision, so I thought I might as well scribble some of them down, if only to get them out of my head! To name the prominent few: More on Partis and its future A web service integration API proposal A PHP system to [...]]]></description>
			<content:encoded><![CDATA[<p>I've found myself overflowing with ideas as I try to focus on revision, so I thought I might as well scribble some of them down, if only to get them out of my head! To name the prominent few:</p>
<ul>
<li>More on Partis and its future</li>
<li>A web service integration API proposal</li>
<li>A PHP system to make it easy to plug together a load of code modules for rapid development</li>
<li>Not to mention some others which are too fleeting or too vague to pin down yet</li>
</ul>
<p><span id="more-50"></span></p>
<h2>Partis</h2>
<p><a title="Partis website" href="http://www.partis-project.net/" target="_blank">Partis</a> is the name of a project I had originally planned to put together many years ago when I started university (back in 2004!).</p>
<p>The basic idea was to create a P2P system that worked internally on networks using IP multicast for peer discovery, which also allowed browsing and cross-network searches. It would provide bandwidth limitations, both in terms of speed and amount, as well as dynamic limits (e.g. 500KB/s for the first 300MB downloaded, then 50KB/s thereafter).</p>
<p>While I think this is still a good idea for places like the halls networks (where we were limited to 5GB bandwidth per 24 hours) I have decided on a better direction for the project, which is something almost completely different: distributed backup.</p>
<p>I don't want to talk about Partis too much in this post, as I want to discuss other things too, but I will note down some of my ideas and things that have come out of discussion with others.</p>
<p>Changing Partis to a distributed backup solution came from a fairly selfish beginning, as have many of my ideas. If I want to put a system together because I'll find it very useful (and perhaps indispensible) then perhaps other people will think the same. When I was getting ready to begin my final year project, I wanted to be paranoid about my work. I wanted to guard against losing it in any conceivable way:</p>
<ul>
<li>Hard drive or computer dying or becoming corrupted or destroyed</li>
<li>Losing a USB stick</li>
<li>Accidental deletion/overwriting</li>
<li>Malicious tampering</li>
<li>Theft</li>
<li>External server failure (e.g. Department of Computing or my own server), although highly unlikely</li>
</ul>
<p>So after considering all these options, I thought it would be great to create a distributed P2P-style backup solution. Sadly I haven't had the time to do this, but the basic idea for myself was to use the fact that many of the computers in the Department have an empty partition that is about 20GB in size. If I could use that space to store my data and redundantly distribute it across multiple machines (to account for failures/reformats/reinstalls, computer being off or in Windows or otherwise inaccessible, etc) then I would feel a bit safer. And of course I could use some spare space on my housemates' computers, and maybe my home computer, and my server, and some other friends around the country or even the world...</p>
<p>The data would have to be encrypted, of course, as I wouldn't want just anyone reading it, and there would have to be checksums to guard against modification or corruption. I quickly realised that this project was something that I wouldn't have the time to undertake in parallel to my Masters project, and that it might have made a viable alternative. Then of course, there's the possibility of storing versioned copies of files, and the question of how to distribute everything, and so forth.</p>
<p>Then it hit me that other people would find this useful. Surely most students would want to have a gigabyte or more of redundant, safe storage? Then this creates and solves the problem of finding enough space at the same time. As a potential business model, for example, people could have 1GB of free storage by offering 3-5GB of their own disk for usage by the network.</p>
<p>There would be different storage tiers based on host reliability (uptime/online time/connection speed/etc) and so on. It would perhaps be possible to charge a premium for upper-tier storage (i.e. things you'd need to be able to recover ASAP) as opposed to lower-tier storage (data that you want safe but you don't need immediate access to, e.g. family photos), with varying prices depending on the service you offer to others. The better the service you offer (the more you put in), the better you get (the more you get out). Of course, those who don't want to contribute their resources to the network (or can't do so) would be able to pay for some centralised storage.</p>
<p>It's not just individuals who could use this system, however. Think about companies with large numbers of desktop machines in geographically distinct locations. Bump up the redundancy factor and it could be licensed as an alternative off-site backup solution. Archived data could be distributed across employees' desktop computers, using a percentage of the disk space that would otherwise just be sitting idle. For a fee.</p>
<p>Of course, there are a large number of things to consider and tweak, such as how to deal with encryption, and the inevitability of people losing their keys. My first thoughts on this are to have a two-layer system, although I'm not sure this is possible. The user has a passphrase-protected key that can decrypt a secondary key which is actually centrally stored and used to encrypt/decrypt their files. Then if users lose their passphrase, their data isn't lost - another key held in central reserve that requires a combination of personal details to unlock can be used to decrypt the secondary key and create a replacement personal keypair.</p>
<p>That's probably enough about Partis for now!</p>
<p><strong>Update (2008-04-29 18:25):</strong> <a href="http://www.danlester.com/" target="_blank">Dan Lester</a> (who uses the same WP theme - what are the chances?) has drawn my attention to <a href="http://www.zoogmo.com">Zoogmo</a> which is similar on the surface, but is Windows-only and based around the idea of sharing with friends rather than the Partis network. Also, they don't yet appear to have different tiers. They do have a suitable "Web 2.0" name though. Something to look into and keep an eye on though. Are any ideas original any more?</p>
<h2>Web service integration</h2>
<p>Something that came to my attention the other day when reading <a href="http://fishbowl.pastiche.org/">Charles Miller's blog</a> was the fragmentation of data across the web. There are few central authentication schemes (such as OpenID) and little support for them. There is no standard for integrating the services offered by the multitude of different sites. This isn't helped by the lack of incentive for sites to bring their offerings together, but I believe it could be really useful. I then read <a title="The Fishbowl: Function Follows Form" href="http://fishbowl.pastiche.org/2007/05/16/function_follows_form" target="_blank">various</a> <a title="ZefHemel.com: WebFS" href="http://www.zefhemel.com/archives/2007/03/04/webfs" target="_blank">blog</a> <a title="TechFold: Time For An Internet Filesystem?" href="http://techfold.com/2007/04/18/time-for-an-internet-file-system-ifs/">posts</a> on this subject and decided that I would like to hammer out the beginnings of a web interaction/integration API. With help and assistance from other people, of course!</p>
<p>More on this another time. All I will say for now is a potential name: <strong>OpenIntegrate</strong>.</p>
<h2>Pluggable PHP system</h2>
<p>While in the shower the other day (an excellent place for ideas to appear, it seems), I decided that what I really want to create is a library of PHP code that I can just plug together for various tasks. It would have to know a bit about database layout, so that I didn't really have to think about it in advance. The more I thought about it, the more developed the idea became. This system would be a set of PHP files and a preprocessor, so that modules can have optional dependencies and hence conditional code generation/inclusion in a fast way, as well as automatically creating/updating the database in order to work.</p>
<p>For example, I was recently thinking about how persistent logins work, and how nice it would be to just write a component once that I can just add to a generic user authentication component. A user authentication component requires (at minimum) a <strong>username</strong> and <strong>password</strong> field in a <strong>users</strong> table of a database. When coupled with a persistent login cookie system, however, either the <strong>users</strong> table has to be updated to include a <strong>persistent_token</strong> field (and maybe a <strong>series_id</strong>, see <a href="http://jaspan.com/improved_persistent_login_cookie_best_practice" target="_blank">here</a>) or a new tables is required if you want to allow login to be remembered from multiple places.</p>
<p>It would be really nice if the PHP could take care of these database modifications by itself, and automatically integrate with the user login module, so that I don't have to worry about it. That way, I can just put a load of files together, run something similar to <kbd>rake</kbd>/<kbd>bake</kbd> on them, and end up with an SQL file that will contain the required database schema and also include/exclude bits of the PHP code based on the available modules, perhaps commenting/uncommenting blocks based on available modules, etc. This would prevent a number of checks for optionally available functionality. Each module would then contain a comment header, perhaps something like:</p>
<pre>/*# PROVIDES: userauth
 *# REQUIRES:
 *# SUPPORTS: persistlogin
 *# DEFAULT_DEF: TBL_USER="users"
 *# DB_REQUIRE: [ TBL_USER, [ username: varchar50, password: char32 ] ]
 */</pre>
<p>and then:</p>
<pre>/*# PROVIDES: persistlogin
 *# REQUIRES: userauth
 *# SUPPORTS: persistlogin
 *# DB_REQUIRE: [ TBL_USER, [ persistent_token: char32, series_id: char32 ] ]
 */</pre>
<p>... and then make a sensible minimum required database structure out of them. Of course, much more than this would be required, and the format described above is very nasty, but that was just my first thoughts. You could then have conditional compilation:</p>
<pre lang="php">/*# IF HAS_MODULE("persistlogin")
  // code to check for persistent login cookie
  if ($_COOKIE['persist_login']) { }
  elseif (/* check DB ... */) {
 *# ELSEIF #*/
  if (/* check DB ... */) {
/*# ENDIF #*/
    // log them in
  } else {
    // ...
  }</pre>
<p>or:</p>
<pre lang="php">/*# IF HAS_MODULE("persistlogin") #*/
  // code to check for persistent login cookie
  if ($_COOKIE['persist_login']) { }
  elseif (/* check DB ... */) {
/*# ELSEIF #*
  if (/* check DB ... */) {
 *# ENDIF #*/
    // log them in
  } else {
    // ...
  }</pre>
<p>depending on whether the "persistlogin" module is available at the time the preprocessor is run.</p>
<p>I thought about calling it GHOTI (<a title="Wikipedia: Ghoti" href="http://en.wikipedia.org/wiki/Ghoti" target="_blank">prounounced</a> "fish") because I like quirky words, but couldn't immediately come up with a backronym. G- H- Offering Tight Integration? Maybe I'll come up with something from Latin instead. Or call it RADPHP or PHP-RAD. Who knows?</p>
<p>Anyway, that's probably enough of my random ideas for now. More to come after exams, I don't doubt! First one is tomorrow at 14:30. Sigh.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dmi.me.uk/blog/2008/04/29/overflowing-with-ideas/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by-nc-nd/3.0/</creativeCommons:license>
	</item>
	</channel>
</rss>

