<?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>Tim&#039;s Bandwagon &#187; PHP</title>
	<atom:link href="http://www.twisty.com/bandwagon/archives/categories/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.twisty.com/bandwagon</link>
	<description>Hitch your wagon to a chicken</description>
	<lastBuildDate>Sun, 06 Sep 2009 20:16:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>array_mode</title>
		<link>http://www.twisty.com/bandwagon/archives/2007/05/03/104903</link>
		<comments>http://www.twisty.com/bandwagon/archives/2007/05/03/104903#comments</comments>
		<pubDate>Thu, 03 May 2007 09:49:03 +0000</pubDate>
		<dc:creator>Tim Brayshaw</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.twisty.com/bandwagon/archives/2007/05/03/104903</guid>
		<description><![CDATA[If you&#8217;ve ever needed to get calculate a mode value in php, you&#8217;ll notice that there isn&#8217;t a native function to do so.

I couldn&#8217;t get the function in Pear&#8217;s Math_Statistics to work with non-numeric values, so here&#8217;s a function that does.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
&#60;?php
&#160;
/**
 * Calculates the frequently occuring value(s) in an array.
 *
 * @param  array [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever needed to get calculate a mode value in php, you&#8217;ll notice that there isn&#8217;t a native function to do so.</p>

<p>I couldn&#8217;t get the function in Pear&#8217;s <a href="http://pear.php.net/package/Math_Stats/" title="PEAR :: Package :: Math_Stats">Math_Statistics</a> to work with non-numeric values, so here&#8217;s a function that does.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Calculates the frequently occuring value(s) in an array.
 *
 * @param  array $data
 * @return array
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> array_mode<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        throw <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'First argument $data must be an array.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$frequencies</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_count_values</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Double-check that frequencies are sorted in reverse order,</span>
    <span style="color: #666666; font-style: italic;">// I think array_count_values actually returns in this format</span>
    <span style="color: #666666; font-style: italic;">// already, but the manual doesn't mention it.</span>
    <span style="color: #990000;">arsort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$frequencies</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$isFirst</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Yuk</span>
    <span style="color: #000088;">$mode</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$frequencies</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$thisValue</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$thisFrequency</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$isFirst</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$isFirst</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Wince</span>
            <span style="color: #000088;">$mode</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$thisValue</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$modeFrequency</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$thisFrequency</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$modeFrequency</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$thisFrequency</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$mode</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$thisValue</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$modeFrequency</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$thisFrequency</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$mode</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span>array_mode<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'c'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'d'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*
array(1) {
  [0]=&gt;
  string(1) &quot;a&quot;
}
*/</span>
&nbsp;
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span>array_mode<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'b'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'c'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*
array(2) {
  [0]=&gt;
  string(1) &quot;a&quot;
  [1]=&gt;
  string(1) &quot;b&quot;
}
*/</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.twisty.com/bandwagon/archives/2007/05/03/104903/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preview Markdown Documents in BBEdit</title>
		<link>http://www.twisty.com/bandwagon/archives/2005/10/31/195241</link>
		<comments>http://www.twisty.com/bandwagon/archives/2005/10/31/195241#comments</comments>
		<pubDate>Mon, 31 Oct 2005 18:52:41 +0000</pubDate>
		<dc:creator>Tim Brayshaw</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Markup and CSS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.twisty.com/bandwagon/?p=241</guid>
		<description><![CDATA[A quickie: here&#8217;s a way of directly previewing Markdown documents in the BBEdit preview window using PHP. (Inspired by this Python method that does the same thing).


Make a template file (you&#8217;ll probably want to add some styles to this).
~/Sites/markdown-preview/template.html


1
2
3
4
5
6
7
8
9
10
11
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.1//EN&#34;
        &#34;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62;
&#60;head&#62;
	&#60;meta http-equiv=&#34;content-type&#34; content=&#34;text/html; [...]]]></description>
			<content:encoded><![CDATA[<p>A quickie: here&#8217;s a way of directly previewing <a href="http://daringfireball.net/projects/markdown/">Markdown</a> documents in the <a href="http://www.barebones.com/products/bbedit/">BBEdit</a> preview window using <a href="http://www.php.net/">PHP</a>. (Inspired by this <a href="http://blog.mostrom.pp.se/?p=63" title="Preview Markdown documents using BBEdit">Python method</a> that does the same thing).</p>

<ol>
<li><p>Make a template file (you&#8217;ll probably want to add some styles to this).</p>
<p><em>~/Sites/markdown-preview/template.html</em></p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot;</span>
<span style="color: #00bbdd;">        &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content-type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Markdown Preview<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
##markdown##
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></td></tr></table></div>


</li>
<li><p>Make the php file, and follow the instructions in the PHP comments.</p>
<p><em>~/Sites/markdown-preview/index.php</em></p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Download these and put them somewhere in your php path:
 *
 *     &lt;a href=&quot;http://www.michelf.com/projects/php-markdown/&quot;&gt;http://www.michelf.com/projects/php-markdown/&lt;/a&gt;
 *     &lt;a href=&quot;http://www.michelf.com/projects/php-smartypants/&quot;&gt;http://www.michelf.com/projects/php-smartypants/&lt;/a&gt;
 */</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'markdown.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">'smartypants.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * You'll need to change this:
 */</span>
<span style="color: #000088;">$markdownDocsDir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">isset</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'MARKDOWN_DOCS_DIR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'MARKDOWN_DOCS_DIR'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'/Users/username/Documents'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * You'll need to set up BBEdit to use something like this as the Preview Server URL:
 *
 *     http://localhost/markdown-preview/?file=/
 */</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$markdownDocsDir</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$formatted</span> <span style="color: #339933;">=</span> SmartyPants<span style="color: #009900;">&#40;</span>Markdown<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Display the formatted text via a simple template.
 */</span>
<span style="color: #000088;">$templateFile</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'./template.html'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$templateText</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_exists</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$templateFile</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">file_get_contents</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$templateFile</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;##markdown##&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">str_replace</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'##markdown##'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$formatted</span><span style="color: #339933;">,</span> <span style="color: #000088;">$templateText</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.twisty.com/bandwagon/archives/2005/10/31/195241/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Geeky Sunday Afternoon Tinkering</title>
		<link>http://www.twisty.com/bandwagon/archives/2005/04/26/204036</link>
		<comments>http://www.twisty.com/bandwagon/archives/2005/04/26/204036#comments</comments>
		<pubDate>Tue, 26 Apr 2005 19:40:36 +0000</pubDate>
		<dc:creator>Tim Brayshaw</dc:creator>
				<category><![CDATA[GTD]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Personal Publishing]]></category>

		<guid isPermaLink="false">http://trunk.www.twisty.coronationroad/bandwagon/?p=230</guid>
		<description><![CDATA[Tinkering project #1 &#8211; Get the dates of posts and comments to display with an ordinal suffix for the day of the month.

I wanted to display the dates of posts and comments using numbers for the day of the month like 1st, 2nd, 3rd, 4th. It wasn&#8217;t too tricky, but required a bit of tinkering.

Now, [...]]]></description>
			<content:encoded><![CDATA[<h3>Tinkering project #1 &ndash; Get the dates of posts and comments to display with an ordinal suffix for the day of the month.</h3>

<p>I wanted to display the dates of posts and comments using numbers for the day of the month like 1st, 2nd, 3rd, 4th. It wasn&#8217;t too tricky, but required a bit of tinkering.</p>

<p>Now, I&rsquo;ve got a convoluted setup for this blog, but essentially it uses <a href="http://www.sixapart.com/movabletype/">Movable Type</a> for the admin and back-end, and the pages are displayed using <a href="http://smarty.php.net/">Smarty</a>, a <a href="http://www.php.net/"><acronym title="recursive acronym for PHP: Hypertext Preprocessor">PHP</acronym></a> template engine. Smarty has a <a href="http://smarty.php.net/manual/en/language.modifier.date.format.php">date formatting modifier</a> that works just fine (a wrapper PHP&rsquo;s <code><a href="http://www.php.net/manual/en/function.strftime.php">strftime</a></code> function), but unfortunately <code>strftime</code> doesn&rsquo;t support ordinal suffixes, whereas PHP&rsquo;s <code><a href="http://www.php.net/manual/en/function.date.php">date</a></code> function does.</p>

<p></p><p>So, I made a <a href="http://smarty.incutio.com/?page=SmartyPlugins">Smarty plugin</a> that acts as a wrapper to the <code>date</code> function, you can get it here: <a href="http://www.twisty.com/misc/smarty/modifier.php_date_format.php.txt">modifier.php<em>date</em>format.php.txt</a>. The template syntax is <code>{$<var>variable</var>|php<em>date</em>format:'<var>jS F</var>'}</code> (replace the <code><var>jS F</var></code> bit with any of the format characters used by PHP&rsquo;s <code><a href="http://www.php.net/manual/en/function.date.php">date</a></code> function).</p>

<h3>Tinkering project #2 &ndash; Put a GUI on my CD Wallet Label Generator.</h3>

<p>I&rsquo;ve recently been using <a href="http://www.cdfinder.de/">CDFinder</a> to catalog the backups and archives I&rsquo;ve got on CD-ROM and DVD. I work making websites and CD-ROMs so over the years I&rsquo;ve amassed quite a collection!</p>

<p>I&rsquo;ve been giving each cataloged CD an index number (as a CDFinder comment), then filing the CD under that index number. I couldn&#8217;t find a suitable utility for printing lots of sequential index labels, so I knocked one together using PHP. (Yes, it did occur to me that I could just <em>write</em> them with a pen or pencil, but I wanted something neater and tidier &ndash; and more &ldquo;formal&rdquo;.)</p>

<p>Introducing <a href="http://www.twisty.com/misc/cdlabels/">Tim&rsquo;s Simple CD (or DVD) Sleeve Index Generator</a>. I use it for printing onto plain white paper CD wallets. It&rsquo;s pretty much tailored for my individual needs, but it&rsquo;s slightly configurable, so maybe someone else will find it useful too!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twisty.com/bandwagon/archives/2005/04/26/204036/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>folder2dot</title>
		<link>http://www.twisty.com/bandwagon/archives/2004/09/26/191539</link>
		<comments>http://www.twisty.com/bandwagon/archives/2004/09/26/191539#comments</comments>
		<pubDate>Sun, 26 Sep 2004 18:15:39 +0000</pubDate>
		<dc:creator>Tim Brayshaw</dc:creator>
				<category><![CDATA[IA]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://trunk.www.twisty.coronationroad/bandwagon/?p=213</guid>
		<description><![CDATA[I&#8217;ve spent some of this morning packaging a PHP script I wrote a few months ago into a little Mac OS X application. It was at risk of going stale, so thought I&#8217;d let it out into the open for a bit of air. It&#8217;s called folder2dot. When you drop a folder onto it in [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent some of this morning packaging a <acronym title='recursive acronym for "PHP: Hypertext Preprocessor"'>PHP</acronym> script I wrote a few months ago into a little Mac OS X application. It was at risk of going stale, so thought I&#8217;d let it out into the open for a bit of air. It&#8217;s called <a href="http://www.twisty.com/misc/folder2dot/">folder2dot</a>. When you drop a folder onto it in the Finder it creates a &#8216;dot&#8217; file that represents the item&#8217;s contents and sub-contents.</p>

<p>You can then render the &#8216;dot&#8217; file with the <a href="http://www.research.att.com/sw/tools/graphviz/">Graphviz graph drawing tools</a> (I recommend the <a href="http://www.pixelglow.com/graphviz/">Macintosh port of Graphviz</a>) and you get a diagram of the dropped item&#8217;s contents and sub-contents. You might be able to open the &#8216;dot&#8217; file using <a href="http://www.omnigroup.com/applications/omnigraffle/">Omnigraffle</a> (it supports a subset of the DOT language &mdash; I haven&#8217;t tried it yet!).</p>

<p>I found it handy to visualise the inventory of the files in a website I was redeveloping; it produces fairly plain output that is probably most useful as a starting-point.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twisty.com/bandwagon/archives/2004/09/26/191539/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Talking PHP</title>
		<link>http://www.twisty.com/bandwagon/archives/2003/04/04/150451</link>
		<comments>http://www.twisty.com/bandwagon/archives/2003/04/04/150451#comments</comments>
		<pubDate>Fri, 04 Apr 2003 14:04:51 +0000</pubDate>
		<dc:creator>Tim Brayshaw</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://trunk.www.twisty.coronationroad/bandwagon/?p=139</guid>
		<description><![CDATA[I just figured out how to trigger speech from PHP on MacOS X. I&#8217;m finding it handy for debugging, but it has opened up a whole new world of stupid possibilities.


if &#40;$condition&#41; &#123;
    say&#40;&#34;Hello&#34;&#41;;
&#125;
&#160;
function say&#40;$something&#41;
&#123;
    exec&#40;&#34;osascript -e 'say &#34;$something&#34;'&#34;&#41;;
&#125;

]]></description>
			<content:encoded><![CDATA[<p>I just figured out how to trigger speech from <acronym title="PHP: Hypertext Preprocessor">PHP</acronym> on MacOS X. I&#8217;m finding it handy for debugging, but it has opened up a whole new world of stupid possibilities.</p>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$condition</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    say<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hello&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> say<span style="color: #009900;">&#40;</span><span style="color: #000088;">$something</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;osascript -e 'say &quot;</span><span style="color: #000088;">$something</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.twisty.com/bandwagon/archives/2003/04/04/150451/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Movable Type and PHP Smarty Templates</title>
		<link>http://www.twisty.com/bandwagon/archives/2002/11/08/012139</link>
		<comments>http://www.twisty.com/bandwagon/archives/2002/11/08/012139#comments</comments>
		<pubDate>Fri, 08 Nov 2002 00:21:39 +0000</pubDate>
		<dc:creator>Tim Brayshaw</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Personal Publishing]]></category>

		<guid isPermaLink="false">http://trunk.www.twisty.coronationroad/bandwagon/?p=72</guid>
		<description><![CDATA[Smart templating with Movable Type shows how to link MT with Smarty. (I&#8217;m running these pages through Smarty, but in a rather less 
elegant way than Brad outlines.)
]]></description>
			<content:encoded><![CDATA[<p><a title="Smart templating with Movable Type" href="http://www.bradchoate.com/past/001041.php">Smart templating with Movable Type</a> shows how to link <a href="http://www.moveabletype.org/">MT</a> with <a href="http://smarty.php.net/">Smarty</a>. (I&#8217;m running these pages through Smarty, but in a rather less 
elegant way than Brad outlines.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twisty.com/bandwagon/archives/2002/11/08/012139/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
