<?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>Adventures in Keyframes and Code</title>
	<atom:link href="http://www.keyframesandcode.com/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.keyframesandcode.com/code</link>
	<description>MaxScript, ActionScript, PHP &#38; JavaScript</description>
	<lastBuildDate>Thu, 11 Feb 2010 16:55:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Accurate screen-to-print sizing in Photoshop</title>
		<link>http://www.keyframesandcode.com/code/misc/accurate-screen-to-print-sizing-in-photoshop/</link>
		<comments>http://www.keyframesandcode.com/code/misc/accurate-screen-to-print-sizing-in-photoshop/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 14:30:19 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=231</guid>
		<description><![CDATA[I learnt how to set up Photoshop today so that the screen displays images at the exact same size they will print out, which is great for previewing how your work will look without endless printing and reprinting.
Here&#8217;s what you do:

Note the size of your screen height in pixels (mine is 1024)
Measure the physical height [...]]]></description>
			<content:encoded><![CDATA[<p>I learnt how to set up Photoshop today so that the screen displays images at the exact same size they will print out, which is great for previewing how your work will look without endless printing and reprinting.</p>
<p>Here&#8217;s what you do:</p>
<ol>
<li>Note the size of your screen height in pixels (mine is 1024)</li>
<li>Measure the physical height of the pixel-area of your screen using a ruler (mine measured 27.0 cm exactly)</li>
<li>Divide the number of pixels by the number of centimetres (1024 / 27 = 37.925)</li>
<li>Enter this number in the Screen Resolution box under Preferences &gt; Units &amp; Rulers:</li>
</ol>
<p><img src="http://www.keyframesandcode.com/code/wp-content/uploads/2010/02/units.png" width="583" height="343" /></p>
<p>Photoshop will now display your images at the correct size when you choose View &gt; Print Size.</p>
<p>However, it&#8217;s a bit of pain to have to go to the menu option each time, but an easy solution is to simply map View &gt; Print Size to the CTRL + ` (top left key):</p>
<p><img src="http://www.keyframesandcode.com/code/wp-content/uploads/2010/02/keyboard.png" alt="keyboard" width="583" height="418" /></p>
<p>Now, you can easily swap between 100% and Print Size by alternating between CTRL+1 and CTRL+`</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/misc/accurate-screen-to-print-sizing-in-photoshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable password autocomplete in Firefox</title>
		<link>http://www.keyframesandcode.com/code/development/html/disable-password-autocomplete-in-firefox/</link>
		<comments>http://www.keyframesandcode.com/code/development/html/disable-password-autocomplete-in-firefox/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 13:53:44 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=218</guid>
		<description><![CDATA[Firefox seems intent on autocompleting password fields, whether you want it to or not, which is not good for security if you&#8217;re building a web app with &#8220;old password / new password&#8221; functionality.
Luckily, I&#8217;ve found a way to trick it into not doing this.
Simply place a hidden password field, with no name, at the start [...]]]></description>
			<content:encoded><![CDATA[<p>Firefox seems intent on autocompleting password fields, whether you want it to or not, which is not good for security if you&#8217;re building a web app with &#8220;old password / new password&#8221; functionality.</p>
<p>Luckily, I&#8217;ve found a way to trick it into not doing this.</p>
<p>Simply place a hidden password field, with no name, at the start of your form:</p>
<pre>&lt;input type="password" style="display: none;"/&gt;</pre>
<p>This seems to trick firefox into thinking that this is the main password field, but as there&#8217;s no name it a) doesn&#8217;t get set and b) doesn&#8217;t get submitted.</p>
<p>Great <img src='http://www.keyframesandcode.com/code/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/html/disable-password-autocomplete-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Documentor &#8211; PHP to HTML to Redmine Wiki syntax converter</title>
		<link>http://www.keyframesandcode.com/code/development/php/documentor/</link>
		<comments>http://www.keyframesandcode.com/code/development/php/documentor/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 17:23:54 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=204</guid>
		<description><![CDATA[Overview

I&#8217;ve released what I think is a pretty robust version of Documentor, my PHP &#62; HTML &#62; Redmine documentation app.
These are some of the nice features to make it in:
PHP

Classes, methods and properties are now supported
Excellent JavaDoc &#38; commenting conversion
Automatic grouping of properties based on comments structure

HTML

Full or partial HTML generation, with semantic markup, anchors [...]]]></description>
			<content:encoded><![CDATA[<h3>Overview</h3>
<div id="CommentBody_22508" class="CommentBody">
<p>I&#8217;ve released what I think is a pretty robust version of <a href="/resources/php/redmine/documentor/">Documentor</a>, my PHP &gt; HTML &gt; Redmine documentation app.</p>
<p>These are some of the nice features to make it in:</p>
<p><strong>PHP</strong></p>
<ul>
<li>Classes, methods and properties are now supported</li>
<li>Excellent JavaDoc &amp; commenting conversion</li>
<li>Automatic grouping of properties based on comments structure</li>
</ul>
<p><strong>HTML</strong></p>
<ul>
<li>Full or partial HTML generation, with semantic markup, anchors and full CSS support</li>
<li>Multiple structural options</li>
<li>Generation of sample code</li>
</ul>
<p><strong>Wiki format</strong></p>
<ul>
<li>Automatic conversion of almost all supported tags, including simple tables</li>
<li>Automatic link generation for external and internal links</li>
</ul>
<p><strong>UI</strong></p>
<ul>
<li>Elegant and easy-to use AJAX interface which remembers your settings between sessions</li>
<li>Sample code example included to quickly test all the features</li>
<li>Live preview of HTML results</li>
</ul>
<h3>Check it out</h3>
<p>It&#8217;s now got its own project page, so you can file issues or suggestions there:</p>
<p><a href="http://dev.kohanaphp.com/projects/documentor/wiki/">http://dev.kohanaphp.com/projects/documentor/wiki/</a></p>
<p>And the application is here to tinker with:</p>
<p><a href="/resources/php/redmine/documentor/">http://www.keyframesandcode.com/resources/php/redmine/documentor/</a></p>
<p>I think it&#8217;s fairly bullet-proof, but please get in there and test the latest version, let me know what you like, and if you find any bugs.</p></div>
<p><a href="http://www.keyframesandcode.com/resources/php/redmine/documentor/">Check it out online and have a play</a> &#8211; I&#8217;ve tried to make it super easy, and there&#8217;s <strong>sample code</strong> you can use to get you started. Also, try copying and pasting some of the code Kohana classes in to see what happens!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/php/documentor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comment Headings</title>
		<link>http://www.keyframesandcode.com/code/development/comment-headings/</link>
		<comments>http://www.keyframesandcode.com/code/development/comment-headings/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 12:26:47 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/development/comment-headings-beta/</guid>
		<description><![CDATA[When navigating through large classes, it can be a real pain to find certain bits of code if you don&#8217;t have a good IDE. As I often work in Flash IDE and DreamWeaver IDE, I have to rely on comment blocks here and there, with lots of &#8211; - &#8211; - &#8211; - &#8211; - [...]]]></description>
			<content:encoded><![CDATA[<p>When navigating through large classes, it can be a real pain to find certain bits of code if you don&#8217;t have a good IDE. As I often work in Flash IDE and DreamWeaver IDE, I have to rely on comment blocks here and there, with lots of &#8211; - &#8211; - &#8211; - &#8211; - &#8211; - delimiters, etc. which is an OK start.</p>
<p>However, I saw the PaperVision 3D classes had moved on a step from this, and had rather nice blocks at the top of each script with their logo, made out of characters. Why not extend this idea and actually build a small Flash application to let me build dirty-great big words that I can use in my scripts for navigation purposes?</p>
<h3>Comment Headings</h3>
<p>Edit the text in the left-hand text box to update the text in the right, then click Copy Text to copy the headings directly to the clipboard so you can paste to your IDE.</p>
<p>Note:Comment Headings works only with mono-spaced fonts! Mac users &#8211; you might have to experiment to find the best one.</p>
<p><span style="color: #ff0000;"><strong>Firefox 3 users:</strong><span style="color: #ff0000;"> due to FF3&#8217;s mono-spaced font tracking, the characters below <em>may not display correctly</em>, but rest-assured that in the final downloadable utility, and your IDE, the headings will appear just fine.</span><strong><br />
</strong></span></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="670" height="660" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="bgcolor" value="#cccccc" /><param name="src" value="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/CommentHeadings.swf?url=http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/presets.xml" /><embed type="application/x-shockwave-flash" width="670" height="660" src="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/CommentHeadings.swf?url=http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/presets.xml" bgcolor="#cccccc"></embed></object></p>
<h3>Demonstration</h3>
<p>To demonstrate the differences between a comment-headered file and a normal file, compare the following two files, and see how much easier it is to skim through the one with larger comment headings.</p>
<ul>
<li>A file with <a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/example1.as.txt" target="_blank">comment headings</a>.</li>
<li>A file with <a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/example2.as.txt" target="_blank">normal text-based headings</a>.</li>
</ul>
<h3>Options</h3>
<p>The following options are available to customize your headings:</p>
<ul>
<li>Font &#8211; Choose from 12 available fonts of varying sizes and styles</li>
<li>Block &#8211; Various characters to create the block comments themselves</li>
<li>Comment &#8211; Various leading-comment styles to suit different languages</li>
<li>Delimiter &#8211; Various delimiter characters for the</li>
</ul>
<h3>Presets</h3>
<p>If you change programming languages / tasks regularly, you can save time by storing oft-used combinations as presets. For example:</p>
<ul>
<li>Input presets &#8211; Your most common heading text combinations</li>
<li>Output presets &#8211; Your most common settings for each language / editor / etc</li>
</ul>
<p>Presets can be quickly called up by selecting them from the dropdown lists, which automatically updates related dropdowns as well as the output text.</p>
<p>Both Input Templates and Output Settings are stored in an editable text file, <a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/presets.xml" target="_blank">presets.xml</a>, which is well-commented, allowing you to add or delete settings to suit your workflow.</p>
<p>To have the utility start with your chosen presets, for example having the MaxScript headings always open, just ensure its entry is first in the input list.</p>
<h3>Customization</h3>
<p>Once tinkering in the presets file, the following elements are configurable:</p>
<ul>
<li>Comments &#8211; Choose the leading comments (//, &#8211;, etc) according to programming language</li>
<li>Blocks &#8211; Choose which characters you want to physically build the words from</li>
<li>Delimiters &#8211; Choose which characters you want to use to delineate each comment block</li>
<li>Fonts &#8211; Choose from any of 12 fonts to be available</li>
</ul>
<h3>3dsmax users</h3>
<p>In order to display the full-block style of comments, you will need to set up the SCiTE editor to use the extended Unicode character set, and display code by default in a fixed width font. To do so, you will need to add the following lines to your User Preferences file:</p>
<pre>code.page = 65001
character.set = 204
font.base = font:Courier New,size:10
font.comment = font:Courier New,size:9
</pre>
<p>Obviously this is only applicable if you are using 3dsmax 2008 or above.</p>
<h3>Download</h3>
<ul>
<li><a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/CommentHeadings.exe.zip">Windows .exe version</a> for Windows users</li>
<li><a href="http://www.keyframesandcode.com/resources/flash/applications/Comment%20Headings/CommentHeadings.zip">Flash .swf version</a> for Mac users</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/comment-headings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kohana: Default controller for serving static pages</title>
		<link>http://www.keyframesandcode.com/code/development/php/kohana/kohana-default-controller-for-serving-static-pages/</link>
		<comments>http://www.keyframesandcode.com/code/development/php/kohana/kohana-default-controller-for-serving-static-pages/#comments</comments>
		<pubDate>Thu, 11 Sep 2008 14:28:03 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Kohana]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=199</guid>
		<description><![CDATA[A brief overview of the problem
A framework such as Kohana is really useful when serving lots of dynamic pages, as it allows you organise both your thoughts and your code into folders, creating order from what could potentially be chaos, at the expense of having to adhere to a structured way of working, in this [...]]]></description>
			<content:encoded><![CDATA[<h3>A brief overview of the problem</h3>
<p>A framework such as Kohana is really useful when serving lots of dynamic pages, as it allows you organise both your thoughts and your code into folders, creating order from what could potentially be chaos, at the expense of having to adhere to a structured way of working, in this case setting up controllers and  methods that are correctly mapped from URLs (routes).</p>
<p>Whilst this is necessary for dynamic pages that need access to models, helpers and such like, for static pages that literally just need to be output to the browser, it&#8217;s quite a lot of overhead, and your controllers can very quickly end up bloated with itty-bitty &#8220;view this page&#8221; methods.</p>
<p>What would be great would be some magic method to automatically handle static pages, without having to set up an actual controller and method, that way all you really need to create is the view file, and you leave your controllers folder nice and lean.</p>
<p><em>Note: this tutorial is for Kohana 2.2. I haven&#8217;t investigated how it will work with 2.3 and the routing yet. Please comment if you have something to add!</em></p>
<h3>The Fallback controller</h3>
<p>The solution is using a default or &#8220;fallback&#8221; controller that takes care of serving views from routes that don&#8217;t map to an existing controller and method.</p>
<p>Essentially, this new controller kicks in just after the routing has drawn a blank, locates the appropriate view file, then serves it &#8211; instead of serving a 404 page.</p>
<h3>Step-by-step</h3>
<p>Let&#8217;s a take a look at how this works in a step-by-step approach from Kohana&#8217;s perspective. Don&#8217;t worry &#8211; it&#8217;s actually pretty simple, I&#8217;ve just mapped it out specifically so you can see what&#8217;s happening every step of the way.</p>
<p><strong>Let&#8217;s start with a route</strong></p>
<ul>
<li>The user navigates to a route, lets say <strong>/about/company/history</strong></li>
<li>Kohana looks for
<ul>
<li>an <strong>about</strong> controller, with</li>
<li>a <strong>company</strong> method, and intends to supply it with</li>
<li>a <strong>history</strong> argument</li>
</ul>
</li>
</ul>
<p>Here&#8217;s the thing though, because we did&#8217;t want the hassle of setting up ALL our controllers with methods just to load views, our <strong>about</strong> controller doesn&#8217;t have a <strong>company</strong> method! So what is Kohana to do?</p>
<p><strong>Let&#8217;s load the Fallback Controller!</strong><br />
Well, normally, a 404 page would be served, but using the magic of <a href="http://docs.kohanaphp.com/general/hooks">hooks</a>, we&#8217;re going to give Kohana one last chance to do something before serving that horrid 404 page.</p>
<p>So:</p>
<ul>
<li>The <a href="http://docs.kohanaphp.com/general/events#system.post_routing">system.post_routing</a> hook kicks in, and due to the way we&#8217;ve set up the hook file</li>
<li>It loads our <strong>Fallback controller</strong>, which is designed to do something useful with the route before bombing out.</li>
</ul>
<p><strong>Let&#8217;s have the Fallback Controller do it&#8217;s stuff and find the view!</strong><br />
In this case, we want it to attempt to find a view, so:</p>
<ul>
<li>The Fallback controller builds a path from the arguments <strong>/about</strong> that will (hopefully) map to a view, in this case <strong>views/main/about.php</strong>, then</li>
<li>Attempts to find this view using <a href="http://docs.kohanaphp.com/core/kohana#finding_files">Kohana::find_file</a>, and
<ul>
<li>if found &#8211; <strong>loads the view!</strong></li>
<li>if not found &#8211; serves the 404 page</li>
</ul>
</li>
</ul>
<h3>Summary</h3>
<p>Pretty useful, huh? Basically all that happened is</p>
<ul>
<li>Kohana couldn&#8217;t find a controller, so loaded a Fallback controller</li>
<li>The fallback controller took the route and found a view</li>
<li>Kohana loads the view (or the 404 page if the view didn&#8217;t exist)</li>
</ul>
<p>OK, perhaps it&#8217;s time to look at some code</p>
<h3>Code</h3>
<p>You will need to create or edit code in 3 separate places:</p>
<ol>
<li>Enable hooks in your application&#8217;s configuration file</li>
<li>Create a hook file which tells Kohana what to do in the system.post_routing event</li>
<li>Create the actual Fallback Controller that will do the finding and loading of your view files</li>
</ol>
<p>.</p>
<p><strong>application/config/config.php</strong> &#8211; Enable hooks in the main config file&#8230;</p>
<pre>$config['enable_hooks'] = TRUE;</pre>
<p>.</p>
<p><strong>application/hooks/fallback_page.php</strong> &#8211; Add a hook file to the hooks directory&#8230;</p>
<pre>Event::add('system.post_routing' ,'call_fallback_page');

function call_fallback_page()
{
    if (Router::$controller === NULL)
    {
        Router::$controller = 'fallback_page';
        Router::$arguments = Router::$segments;
        Router::$controller_path = APPPATH.'controllers/fallback_page.php';
    }
}</pre>
<p>.</p>
<p><strong>application/controllers/fallback_page.php</strong> &#8211; Set up a controller to do the business</p>
<pre>class Fallback_Page_Controller extends Page_Controller // page controller is my standard page template
{

    public function __construct()
    {

    // the constructor can be omitted if you're not doing anything special,
    // as the parent constructor it is called automatically
        parent::__construct();
    }

    public function __call($function, $arguments)
    {

    // search for a view, and load it if it exists
    // it's up to you how you handle the mapping of arguments to folders here!
        $route =  implode('/', $arguments);
        if(Kohana::find_file('views/main', $route))
        {
            $this-&gt;template-&gt;content = new View('main/'.$route);
        }

    // display alternative content if not found
        else
        {
            $view = new View('common/404');
            $view-&gt;info = array($function, $arguments);
            $this-&gt;template-&gt;content = $view;
        }
    }

}</pre>
<h3>Conculsion</h3>
<p>So now you should be able to set up a bunch of views, but needn&#8217;t worry about building controllers for them if nothing exciting is happening.</p>
<p>The fallback controller will run, will attempt to find a matching view, and if found, will echo it the page. The main thing is &#8211; it keeps your controllers folder and classes nice and lean, and you only need to build controllers that actually DO any controlling!</p>
<p>Nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/php/kohana/kohana-default-controller-for-serving-static-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kohana &#8216;filesystem&#8217; Helper</title>
		<link>http://www.keyframesandcode.com/code/development/kohana-filesystem-helper/</link>
		<comments>http://www.keyframesandcode.com/code/development/kohana-filesystem-helper/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 12:49:24 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/?p=198</guid>
		<description><![CDATA[Kohana is just an excellent framework to work with, but one of my beefs is that the structure of its bundled libraries and helpers is a little haphazard, missing basic functions you&#8217;d expect to find in the core (so you can rely on them when writing modules) omitted!
For this reason, here&#8217;s my attempt at a [...]]]></description>
			<content:encoded><![CDATA[<p>Kohana is just an excellent framework to work with, but one of my beefs is that the structure of its bundled libraries and helpers is a little haphazard, missing basic functions you&#8217;d expect to find in the core (so you can rely on them when writing modules) omitted!</p>
<p>For this reason, here&#8217;s my attempt at a more integrated helper class. It&#8217;s somewhat of a Frankenstein&#8217;s monster with bits borrowed from Code Igniter, and my own code thrown in as well. Apart from this, it:</p>
<ul>
<li>Adds a few new methods</li>
<li>Improves on some existing methods</li>
<li>Combines the &#8216;download&#8217; helper functionality</li>
<li>Tidies up various method calls</li>
</ul>
<p>The methods are:</p>
<ul>
<li>map()</li>
<li>get_folders()</li>
<li>get_files()</li>
<li>delete_files()</li>
<li>read_file()</li>
<li>write_file()</li>
<li>make_path()</li>
<li>download()</li>
</ul>
<p>Download <a href="http://www.keyframesandcode.com/resources/php/kohana/helpers/filesystem.zip">filesystem.php</a> here.</p>
<p><span id="more-198"></span></p>
<h3 style="margin-top: 30px !important;">map<span style="font-weight:normal"> ($path, $levels = NULL, $structured = FALSE, $files_first = FALSE)</span></h3>
<p><strong>Returns a hierarchical array of folders and files from the specified path.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li>[<strong>levels</strong>] : <em>number</em> &#8211; limit how many folders deep you want to recursively scan</li>
<li>[<strong>structured</strong>] : <em>boolean</em> &#8211; split each returned branch into <em>&#8216;/folder&#8217;</em> and <em>&#8216;/files&#8217;</em> sub-arrays</li>
<li>[<strong>files_first</strong>] : <em>boolean</em> &#8211; if not returning as a structured array, list files before folders</li>
</ul>
<h3 style="margin-top: 30px !important;">get_folders<span style="font-weight:normal"> ($path, $appendPath = false)</span></h3>
<p><strong>Returns an array of folders from the specified </strong><strong>path</strong><strong>.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li>[<strong>append_path</strong>] : <em>boolean</em> &#8211; append the original path to the return output</li>
</ul>
<h3 style="margin-top: 30px !important;">get_files<span style="font-weight:normal"> ($path, $mask = NULL, $appendPath = false)</span></h3>
<p><strong>Returns an array of files from the specified </strong><strong>path</strong><strong>.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li>[<strong>mask</strong>] : <em>mixed</em> &#8211; a file mask to determine which files to return. Can be either
<ul>
<li><em>null</em> &#8211; all files</li>
<li><em>string</em> &#8211; a single file extension</li>
<li><em>array</em> &#8211; an array of file extensions</li>
<li><em>regular expression</em> &#8211; any valid regular expression, for example &#8216;/^config/&#8217;</li>
</ul>
</li>
<li>[<strong>append_path</strong>] : <em>boolean</em> &#8211; append the original path to the return output</li>
</ul>
<h3 style="margin-top: 30px !important;">delete_files<span style="font-weight:normal"> ($path, $mask = NULL, $del_dir = FALSE, $del_root = FALSE)</span></h3>
<p><strong>Recursively deletes all files and optionally folders from the specified </strong><strong>path</strong><strong>.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li>[<strong>mask</strong>] : <em>mixed</em> &#8211; a file mask to determine which files to delete. Can be either
<ul>
<li><em>null</em> &#8211; all files</li>
<li><em>string</em> &#8211; a single file extension</li>
<li><em>array</em> &#8211; an array of file extensions</li>
<li><em>regular expression</em> &#8211; any valid regular expression, for example &#8216;/^config/&#8217;</li>
</ul>
</li>
<li>[<strong>del_dir</strong>] : <em>boolean</em> &#8211; delete any directories encountered when prcoessing</li>
<li>[<strong>del_root</strong>] : <em>boolean</em> &#8211; delete the root directory after processing</li>
</ul>
<h3 style="margin-top: 30px !important;">read_file<span style="font-weight:normal"> ($file)</span></h3>
<p><strong>Opens the specified </strong><strong>file </strong><strong>and returns its contents as a string.</strong></p>
<p>The parameters are:</p>
<ul>
<li><strong>file</strong>: <em>string</em> &#8211; path to the folder</li>
</ul>
<h3 style="margin-top: 30px !important;">write_file<span style="font-weight:normal"> ($path, $data, $append = FALSE)</span></h3>
<p><strong>Writes data to the specified </strong><strong>file</strong><strong>.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : <em>string</em> &#8211; path to the folder</li>
<li><strong>data</strong> : <em>string</em> &#8211; the data you want written to the file</li>
<li>[<strong>append</strong>] &#8211; <em>boolean</em> &#8211; optionally append data to the file, rather than overwriting it</li>
</ul>
<h3 style="margin-top: 30px !important;">make_path<span style="font-weight:normal"> ($path, $permissions = 0755)</span></h3>
<p><strong>Recursively create folders to form the specified path.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>path</strong> : mixed &#8211; path or an array of paths</li>
<li>[<strong>permissions</strong>]: <em>number</em> &#8211; permissions you want granted to the new folders</li>
</ul>
<h3 style="margin-top: 30px !important;">download<span style="font-weight:normal"> ($filedata, $filename = NULL)</span></h3>
<p><strong>Download file content by popping up a download dialog in the user&#8217;s browser.</strong></p>
<p>The parameters are</p>
<ul>
<li><strong>filedata</strong> : <em>mixed</em> &#8211; can either be
<ul>
<li><em>filepath</em> &#8211; the path to an existing file</li>
<li><em>string</em> &#8211; data you want downloaded as a file</li>
</ul>
</li>
<li>[<strong>filename</strong>] : <em>string</em> &#8211;  a filename that will appear in the user&#8217;s download dialog</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/kohana-filesystem-helper/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>&#8220;List&#8221; struct</title>
		<link>http://www.keyframesandcode.com/code/development/maxscript/list-struct/</link>
		<comments>http://www.keyframesandcode.com/code/development/maxscript/list-struct/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 18:21:21 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[For Scripters]]></category>
		<category><![CDATA[Functions]]></category>
		<category><![CDATA[MaxScript]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/development/maxscript/for-scripters/list-struct/</guid>
		<description><![CDATA[As 3dsmax doesn&#8217;t allow for either associative arrays or dynamically-set object properties, it can be difficult to store unstructured, arbitrary variables.
Sometimes you just want to store lists of name/value pairs, to keep track of a few settings throughout your script, without relying on a host of variables, resorting to .ini files, or custom attributes.
Therefore, I [...]]]></description>
			<content:encoded><![CDATA[<p>As 3dsmax doesn&#8217;t allow for either associative arrays or dynamically-set object properties, it can be difficult to store unstructured, arbitrary variables.</p>
<p>Sometimes you just want to store lists of name/value pairs, to keep track of a few settings throughout your script, without relying on a host of variables, resorting to .ini files, or custom attributes.</p>
<p>Therefore, I set about writing a basic Dictionary, or List struct, similar to VB and other languages.</p>
<h3>Example code</h3>
<p>Here&#8217;s a really basic example of storing 5 named variables within a List:</p>
<pre>names = #("five", "four", "three", "two", "one")
values = #(5,4,3,2,1)
lst = List()

for i = 1 to 5 do lst.addItem names[i] values[i]</pre>
<p>So let&#8217;s get some data back out:</p>
<pre>lst.getValue "two"
-- 2

lst.getIndex "two"
-- 4

lst.getValues()
-- #(5, 4, 3, 2, 1)</pre>
<p>Or print the whole lot:</p>
<pre>lst.print() -- unsorted

five:	5
four:	4
three:	3
two:	2
one:	1</pre>
<p>How about some sorting:</p>
<pre>lst.sort() -- by name, alphabetically

five:	5
four:	4
one:	1
three:	3
two:	2

lst.sort field:#value -- by value

one:	1
two:	2
three:	3
four:	4
five:	5</pre>
<p>As you can see, it&#8217;s pretty straightforward stuff!</p>
<h3>Properties and Methods</h3>
<blockquote>
<h3>Properties</h3>
<ul>
<li>&lt;array&gt; <strong>items</strong> &lt;name&gt; &lt;value&gt; &#8211; the key/value pairs.
<ul>
<li>Names can be a #name, &#8220;string&#8221;, or even an index</li>
<li>Values can be any MaxWrapper value (i.e. anything)</li>
</ul>
</li>
</ul>
<h3>Setters</h3>
<ul>
<li>&lt;ListItem&gt; <strong>addItem </strong>&lt;name&gt; &lt;value&gt; &#8211; adds an item to the List, and if it already exists</li>
<li>&lt;ListItem&gt; <strong>setItem </strong>&lt;name&gt; &lt;value&gt; &#8211; synonym for the above</li>
</ul>
<h3>Getters</h3>
<ul>
<li>&lt;value&gt; <strong>getValue </strong>&lt;name&gt; &#8211; returns the value of the named item</li>
<li>&lt;index&gt; <strong>getIndex </strong>&lt;name&gt; &#8211; returns the index of the named item</li>
<li>&lt;name&gt; <strong>getName </strong>&lt;value&gt; &#8211; returns the name of the first item that matches the supplied value</li>
<li>&lt;ListItem&gt; <strong>getItem </strong>&lt;name&gt; &#8211; returns the List item corresponding to the supplied name (typically, you wouldn&#8217;t use this, as you know the name component already, it&#8217;s just included for completeness)</li>
<li>&lt;array&gt; <strong>getItems()</strong> &#8211; returns all items as an array of ListItem structs</li>
<li>&lt;array&gt; <strong>getNames()</strong> &#8211; returns all names as an array</li>
<li>&lt;array&gt; <strong>getValues() </strong>- returns all values as an array</li>
</ul>
<h3>Clear or delete</h3>
<ul>
<li>&lt;array&gt; <strong>clear()</strong> &#8211; clears the lit of all items, and returns the empty ListItems array</li>
<li>&lt;boolean&gt; <strong>deleteItem </strong>&lt;name&gt; &#8211; deletes the named item from the list, and returns it</li>
<li>&lt;boolean&gt; <strong>deleteIndex </strong>&lt;index&gt; &#8211; deletes the item at the index, and returns it</li>
</ul>
<h3>Utilities</h3>
<ul>
<li>&lt;array&gt; <strong>sort</strong> field:&lt;name&gt; order:&lt;name&gt; func:&lt;function&gt; &#8211; sorts the list in a variety of ways, even supply a comparison function (see the max help on qsort)</li>
<li>&lt;string&gt; <strong>print()</strong> &#8211; prints the List items to the Listener</li>
</ul>
</blockquote>
<h3>Next version</h3>
<p>Possible improvements in the next version might be:</p>
<ul>
<li>.ini file integration, with <strong>save()</strong> and <strong>load()</strong> methods</li>
<li>Support for hierarchical Lists, perhaps <strong>getValue #(#parent, #child, #grandchild, &#8230;)</strong></li>
</ul>
<h3>Download</h3>
<p>Download <a href="http://www.keyframesandcode.com/resources/maxscript/Functions/List.struct.ms">List.struct.ms</a> here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/maxscript/list-struct/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Time Stamper &#8211; Meshops.attach() Case Study</title>
		<link>http://www.keyframesandcode.com/code/development/maxscript/time-stamper-meshopsattach-case-study/</link>
		<comments>http://www.keyframesandcode.com/code/development/maxscript/time-stamper-meshopsattach-case-study/#comments</comments>
		<pubDate>Mon, 26 May 2008 00:00:00 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[MaxScript]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/development/maxscript/time-stamper-meshopsattach-case-study/</guid>
		<description><![CDATA[Overview
In response to a post on CG Talk,  Optimization ideas needed, a few other developers and I us pitched in to help out with ideas to solve a puzzling problem.
The issue was that a loop to attach 7500 objects was taking up to 8 minutes to complete. Where did the problem lie? Was it [...]]]></description>
			<content:encoded><![CDATA[<h3>Overview</h3>
<p>In response to a post on CG Talk,  <a href="http://forums.cgsociety.org/showthread.php?p=5172805#post5172805">Optimization ideas needed</a>, a few other developers and I us pitched in to help out with ideas to solve a puzzling problem.</p>
<p>The issue was that a loop to attach 7500 objects was taking up to 8 minutes to complete. Where did the problem lie? Was it in the transformation code, the attachment code, or somewhere else?</p>
<p>Well as luck would have it, today&#8217;s Bank Holiday has been totally washed out with rain, so I had nothing better to than to do some testing and find the cause, and in the process road test my recently-developed <a href="http://www.keyframesandcode.com/code/development/maxscript/time-stamper/">TimeStamper</a> struct.</p>
<h3>Approach</h3>
<p>After turning undo and redraw off, as well as optimizing the transformation code within the script, which cut a 1000-object test scene&#8217;s processing time in half, surprisingly the 7500-object scene was still taking around 8 minutes.</p>
<p>I suspected that the problem may well be in the fact that as mesh gets larger, perhaps it becomes computationally more expensive to add new meshes, seeing as the entire array of points and faces needs to be evaluated every time a new mesh is added. Cumulatively, this could really add up.</p>
<p>I though that perhaps the right approach would be to split the attaching up into phases, using a 2D loop, and I suspected that perhaps the square-root of the total attaches might yield the optimal performance, ie for 10000 attaches I&#8217;d perform a 100 x 100 loop, creating 100 intermediate meshes, then attaching them all at the end.</p>
<h3> Results</h3>
<p>These are the results for various variations of 2D loops, limiting the amount of objects attached per loop. The results are impressive!</p>
<ul>
<li>For 1000 objects, the optimum loop combination was 31 loops of 32, a speed increase of <strong>12 </strong>times over a single loop</li>
<li>For 3000 objects, the optimum loop combination was 55 loops of 54, a speed increase of <strong>22 </strong>times over a single loop</li>
<li>For 5000 objects, the optimum loop combination was 50 loops of 100, a speed increase of <strong>28 </strong>times over a single loop</li>
<li>For 7500 objects, the optimum loop combination was 87 loops of 86, a speed increase of <strong>30 </strong>times over a single loop</li>
</ul>
<p>And yes, the square root approach was most successful 3 out of 4 times.</p>
<p>Here are the results in table format, with the optimum loop highlighted:</p>
<p><img src="http://www.keyframesandcode.com/resources/maxscript/For%20Scripters/Time%20Stamper/img/time-stamper-table.gif" /></p>
<h3>1D / 2D loop comparison</h3>
<p>Compared to the 1D loop, the 2D loop was <strong>30</strong> times faster on <strong>7500 </strong>attachments.</p>
<p>In minutes and seconds, that means a decrease from <strong>6 minutes and 29 seconds</strong> to just <strong>12 seconds</strong>!</p>
<p>In graph-form that looks like this:</p>
<p><img src="http://www.keyframesandcode.com/resources/maxscript/For%20Scripters/Time%20Stamper/img/time-stamper-graph.gif" /></p>
<h3>Conclusion</h3>
<p>It seems pretty safe to say that in this case, building up intermediate meshes and attaching at the end is the best way to go. It looks likely that adding to already-huge arrays carries with it an overhead that can have an extremely negative effect in a lengthy loop situation.</p>
<p>I&#8217;ve no doubt that this approach most likely extends to other mesh / array / hash based computations as well, so splitting up large cumulatively-expensive calculations into smaller chunks could well be a great time-saver in other tasks as well.</p>
<p>So &#8211; a shame about the rain, but perhaps a bonus in disguise!</p>
<h3>Resources</h3>
<ul>
<li>View the <a href="http://www.keyframesandcode.com/code/development/maxscript/time-stamper/">Time Stamper page</a></li>
<li>Download <a href="http://www.keyframesandcode.com/resources/maxscript/For%20Scripters/Time%20Stamper/TimeStamper.ms">TimeStamper.ms</a></li>
<li>Download the <a href="http://www.keyframesandcode.com/resources/maxscript/For%20Scripters/Time%20Stamper/TimeStamper-create-spheres.ms">test script</a> that generates the 1000&#8217;s of spheres that get attached, and performs the benchmarking</li>
<li>Download the Excel report that was built using TimeStamper getReport() function in <a href="http://www.keyframesandcode.com/resources/maxscript/For%20Scripters/Time%20Stamper/docs/TimeStamper-report.xls">Excel 2003</a> or <a href="http://www.keyframesandcode.com/resources/maxscript/For%20Scripters/Time%20Stamper/docs/TimeStamper-report.xlsx">Excel 2007</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/maxscript/time-stamper-meshopsattach-case-study/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transform Presets</title>
		<link>http://www.keyframesandcode.com/code/development/maxscript/transform-presets/</link>
		<comments>http://www.keyframesandcode.com/code/development/maxscript/transform-presets/#comments</comments>
		<pubDate>Sat, 17 May 2008 00:00:41 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Animation]]></category>
		<category><![CDATA[Cameras]]></category>
		<category><![CDATA[MaxScript]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/development/maxscript/transform-presets/</guid>
		<description><![CDATA[Transform Presets is a pretty simple plugin &#8211; it allows you to store multiple transformations of an object (and it&#8217;s target, if there is one) in a list, to call up when you like.
You apply it to any object, and it adds a custom rollout to the base object, with a small interface that you [...]]]></description>
			<content:encoded><![CDATA[<p>Transform Presets is a pretty simple plugin &#8211; it allows you to store multiple transformations of an object (and it&#8217;s target, if there is one) in a list, to call up when you like.</p>
<p>You apply it to any object, and it adds a custom rollout to the base object, with a small interface that you can use when the object is selected.</p>
<p>I built it for fun in response to <a href="http://forums.cgsociety.org/showthread.php?f=98&amp;t=632251">a thread on CGTalk</a>.</p>
<h3>Screenshots</h3>
<p>Here it is working on a target camera. Note both the camera and target are transformed.</p>
<p><img src="http://www.keyframesandcode.com/resources/maxscript//Animation/Transform%20Presets/transform-presets-camera.gif" alt="" /></p>
<p>And here it is working with an IK handle. Note the swivel angle is updated as well as the transform.</p>
<p><img src="http://www.keyframesandcode.com/resources/maxscript//Animation/Transform%20Presets/transform-presets-ik.gif" alt="" /></p>
<h3>Download and installation</h3>
<p>Download <a href="http://www.keyframesandcode.com/resources/maxscript/Animation/Transform%20Presets/TransformPresets.mzp">TransformPresets.mzp</a> and then drag the .mzp file onto one of your 3dsmax viewports, which will install the script in the correct directory. Then you can add the script to a toolbar / quad by going to:</p>
<ul>
<li>Customize &gt; Customize User Interface…</li>
<li>Then look under the <strong>Animation Tools</strong> category for <strong>Transform Presets</strong></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/development/maxscript/transform-presets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Towards an optimal method of quoting &#8211; Dom&#8217;s response</title>
		<link>http://www.keyframesandcode.com/code/freelance/doms-response/</link>
		<comments>http://www.keyframesandcode.com/code/freelance/doms-response/#comments</comments>
		<pubDate>Thu, 15 May 2008 13:14:06 +0000</pubDate>
		<dc:creator>Dave Stewart</dc:creator>
				<category><![CDATA[Freelance]]></category>
		<category><![CDATA[Quoting]]></category>

		<guid isPermaLink="false">http://www.keyframesandcode.com/code/freelance/doms-response/</guid>
		<description><![CDATA[Hi DJ
Well done to you for tackling  this one, is the hardest part of this design lark for sure
After reading everyones comments here I am glad I choose to avoid print and web design. Animation is easier as you dont have to quantify exact details to your client, you dont usually have to work [...]]]></description>
			<content:encoded><![CDATA[<p>Hi DJ</p>
<p>Well done to you for tackling  this one, is the hardest part of this design lark for sure</p>
<p>After reading everyones comments here I am glad I choose to avoid print and web design. Animation is easier as you dont have to quantify exact details to your client, you dont usually have to work with complicated file structures as you would with someone’s company branding/website.</p>
<p>To be quick, I just spend as much time as possible in a one to one basis trying to uncover the clients aspirations for the product, I then give them some reality of costs using other projects they will know as case studies. After this they usually understand cost vs &#8216;quality&#8217;. If they understand these factors its easy to manage the project from then in.</p>
<p>I think having T&amp;C’s are important in quotes but mainly to protect you from a muppet client. If you have &#8216;managed&#8217; the client well you shouldn&#8217;t need T&amp;C’s too much.</p>
<p>I am trying to build a business that services clients&#8217; long term needs, that way I avoid pissing matches with details/arguments as we build a relationship of trust with clients who then get out of the loop THUS saving eveyone money.. i hope</p>
<p>Dom</p>
]]></content:encoded>
			<wfw:commentRss>http://www.keyframesandcode.com/code/freelance/doms-response/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
