<?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>O! Mr Speaker! &#187; Dictaphone</title>
	<atom:link href="http://www.mrspeaker.net/category/dictaphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mrspeaker.net</link>
	<description>Javascript flâneur, internet flibbertygibbert</description>
	<lastBuildDate>Thu, 02 Feb 2012 13:18:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>AI Class Playlists</title>
		<link>http://www.mrspeaker.net/2011/10/26/ai-class-playlists/</link>
		<comments>http://www.mrspeaker.net/2011/10/26/ai-class-playlists/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 09:35:45 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>

		<guid isPermaLink="false">http://www.mrspeaker.net/?p=2982</guid>
		<description><![CDATA[Lil' reference for anyone doing the Stanford AI class... It's a collection of playlists for each unit, so you can grab them with something like youtube-dl (I use the command youtube-dl -w -t -f 18 http://playlisturl. I didn't check what those flags do, but it says "wtf", and that's all that matters). Final: Questions Unit [...]]]></description>
			<content:encoded><![CDATA[<p>Lil' reference for anyone doing the Stanford <a href="http://ai-class.com/">AI class</a>... It's a collection of playlists for each unit, so you can grab them with something like <a href="http://rg3.github.com/youtube-dl/">youtube-dl</a> (I use the command <code>youtube-dl -w -t -f 18 http://playlisturl</code>. I didn't check what those flags do, but it says "wtf", and that's all that matters).<br />
<span id="more-2982"></span>
<ul>
<li>
     <a href="http://www.youtube.com/playlist?list=PL2F9ABBCED1CF9214">Final: Questions</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL3C43237A74CCFA79">Unit 22: Natural Language Processing II</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PLCDAA3722F28F23B4">Unit 21: Natural Language Processing</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL77CBBAB962931380">Homework 8: Questions</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL36C1C4569FA69081">Unit 20</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL4F4981DC2E967F8E">Unit 19</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL9F55AC5D9C8BE398">Homework 7: Questions</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PLAED3C1DF7984260A">Unit 18: Computer Vision III</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PLBAD3EFA5F0D3ACC7">Unit 17: Computer Vision II</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL3EDA9934D6D676D9">Unit 16: Computer Vision I</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PLB692621D22E0E2A7">Homework 6 - questions</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL17B676D0F1FC1383">Unit 15: Advanced Planning</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL2936A035F1A912DA">Unit 14: Game Theory</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL5C16D0FE51316B80">Unit 13: Games</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL7F28274FAF76777B">Midterm 1 - questions</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PLF195EB5BE37B5336">Unit 12: MDP review</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PLE471E7E92FC47E67">Unit 11: HMMs and Filters</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL16D0E6216D8B19DF">AI Class Homework 5 - Questions</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PLA03477DCA516DD2D">Unit 10:  Reinforcement Learning</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL9163DC3C43AF7612">Unit 9: Planning under Uncertainty</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL3A69B9E8E3FB8D11">Homework 4 - Questions</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL30E0EE2724D24D90">Unit 8: Planning</a>
  </li>
<li>
     <a href="http://www.youtube.com/playlist?list=PL00F43265B86ADE59">Unit 7: Representation with Logic</a>
  </li>
<li>
    <a href="http://www.youtube.com/playlist?list=PLA34C532DFCB0B27E">Homework 3 - Q &#038; A</a>
  </li>
<li>
    <a href="http://www.youtube.com/playlist?list=PLBC6833C96B44DB57">Unit 6: Unsupervised Learning</a>
  </li>
<li>
    <a href="http://www.youtube.com/playlist?list=PLDBB34E08F7520DBA">Unit 5: Machine Learning</a>
  </li>
<li>
    <a href="http://www.youtube.com/playlist?list=PL315629DA83C13A94">Homework 2 - Q &#038; A</a>
  </li>
<li>
    <a href="http://www.youtube.com/playlist?list=PL3EEF6C645E7D0C9B">Unit 4: Probabilistic Inference</a>
  </li>
<li>
    <a href="http://www.youtube.com/playlist?list=PL381FD5E9802BCE1C">Unit 3: Probability in AI</a>
  </li>
<li>
    <a href="http://www.youtube.com/playlist?list=PLD672D5918A140E6C">Homework 1 - Q &#038; A</a>
  </li>
<li>
    <a href="http://www.youtube.com/playlist?list=PL7D40B622BF0A97BC">Unit 2:Problem Solving (order messed up!)</a>
  </li>
<li>
    <a href="http://www.youtube.com/playlist?list=PL9E57DDFB85A81644">Unit 1: Welcome to AI</a>
  </li>
</ul>
<p>As a post note, these playlists were generated using a quick-and-dirty jQuery script to scrape and sort the video page, and a python script using the GData APIs to create and populate the playlists. If you want to D-I-Y, then the <a href="https://gist.github.com/1333398">Playlist Uploader Gist</a> is now available!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2011/10/26/ai-class-playlists/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Anonymous functions for inline event handlers</title>
		<link>http://www.mrspeaker.net/2011/01/21/inline-handlers/</link>
		<comments>http://www.mrspeaker.net/2011/01/21/inline-handlers/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 13:45:15 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.mrspeaker.net/?p=2165</guid>
		<description><![CDATA[Inline event handlers... remember them?! Yes, they've gone the way of the blink tag and Adobe Flash, but recently I used one while debugging and realised: "Hey! I have no idea how to get the event object in an inline even handler!" and, shortly after "In fact, no idea how to write an anonymous function [...]]]></description>
			<content:encoded><![CDATA[<p>Inline event handlers... remember them?! Yes, they've gone the way of the blink tag and Adobe Flash,  but recently I used one while debugging and realised: "Hey! I have <em>no</em> idea how to get the event object in an inline even handler!" and, shortly after "In fact, no idea how to write an anonymous function in an inline event handler either!". So I set out to rectify the matters. After a bit of experimenting I came up with this:</p>
<pre><code>onclick="(function(e){ alert(e); })(event)"</code></pre>
<p><span id="more-2165"></span>The <code>event</code> keyword gets magically passed into the context of the handler code - so you can write <code>onclick="alert(event)"</code>. Though, I think you'd have to do <code>alert( event || window.event )</code> for IE. tw;dt (too windows; did not test). </p>
<p>Next, if you want an anonymous function then you'll need to wrap it so it self-executes. </p>
<p>And finally, if you still want a handle to the <code>this</code> element, you'll need to pass that in too:</p>
<pre><code>(function(e, obj){ alert(obj); })(event, this)</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2011/01/21/inline-handlers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nifty jQuery trick: setting attributes</title>
		<link>http://www.mrspeaker.net/2009/11/26/nifty-jquery-trick-attr/</link>
		<comments>http://www.mrspeaker.net/2009/11/26/nifty-jquery-trick-attr/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 00:39:23 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>
		<category><![CDATA[Nerd]]></category>

		<guid isPermaLink="false">http://www.mrspeaker.net/?p=1340</guid>
		<description><![CDATA[I've been knee deep in the jQuery source code recently. It's all gooey, but you do get to see some snazzy things. Today's nifty jQuery trick is about programmatically setting attribute values via a function. To follow along at home you'll need some scissors, a length of string, and some double sided tape... We all [...]]]></description>
			<content:encoded><![CDATA[<p>I've been knee deep in the jQuery source code recently. It's all gooey, but you do get to see some snazzy things. Today's nifty jQuery trick is about programmatically setting attribute values via a function. To follow along at home you'll need some scissors, a length of string, and some double sided tape...</p>
<p><span id="more-1340"></span>We all know that you can grab attribute values using jQuery's <code>attr</code> method. For example, to check if a checkbox is checked you check the checkbox's checked, um, value:<br />
<code>var checked = $("chkNoMail").attr("checked");</code><br />
And, of course, to set attributes we simply pass the value in as the second parameter: <code>$("&lt;div&gt;&lt;/div&gt;").attr("id", "myDiv1");</code><br />
Ok, ok... buuuut, there's also <em>another</em> version of the <code>attr</code> method that accepts not a lowly string... but a mighty function!</p>
<p>The function can implement whatever logic you want, but it needs to return the value that you want the attribute to have. For example, if you want to invert the "selected" values of a multi-select box:
<pre><code>$("selBox").children()
		.attr( "selected", function(){
			return !$(this).attr( "selected" );
		});</code></pre>
<p>Nice! Certainly saves us an extra <em>.each</em> call, and keeps your jQuery gravy-train going. It can also be used to add IDs to a bunch of elements you need to ID:</p>
<pre><code>$("div").attr( "id", function( i ){
	return "myDiv" + i;
}</code></pre>
<p>End tip.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2009/11/26/nifty-jquery-trick-attr/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Closures with self-invoking functions</title>
		<link>http://www.mrspeaker.net/2009/11/05/self-invoking-functions/</link>
		<comments>http://www.mrspeaker.net/2009/11/05/self-invoking-functions/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 10:39:22 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.mrspeaker.net/?p=1131</guid>
		<description><![CDATA[Just a quick note-to-self... I'm a big fan of using self-invoking anonymous functions to keep stuff out of the global namespace, but I forgot that they are also nifty for keeping variables in scope via closures. Here's the problem... Let's say with have an array that we'd like to populate with functions. The functions simply [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note-to-self... I'm a big fan of using self-invoking anonymous functions to keep stuff out of the global namespace, but I forgot that they are also nifty for keeping variables in scope via closures. Here's the problem... Let's say with have an array that we'd like to populate with functions. The functions simply log their index to the console:</p>
<p><span id="more-1131"></span>
<pre><code>var funcArray = [];
for( var i = 0; i < 3; i++ ){
	funcArray.push(
		function(){ console.log( i ); }
	);
}
// What will these functions log?
funcArray[ 0 ]();
funcArray[ 1 ]();
i = 99; // just for fun
funcArray[ 2 ]();</code></pre>
<p>What will the functions output? If you guessed 3, 3, 99 then you win! Choose anything from the bottom shelf! The reason is that when we log <em>i</em>, JavaScript goes looking for it... up and up the scope chain until it finds it. For us, it'll find it on the <em>window</em> object where we would have incremented it to 3 (after the loop finishes).</p>
<p>Right, so how do we fix it? With a closure! We certainly don't want to pollute the global namespace (more that we already have), so let's wrap our array push in an anonymous self-invoking function and pass the index as a parameter:</p>
<pre><code>var funcArray = [];
for( var i = 0; i < 3; i++ ){
	(function( i ){
		funcArray.push(
			function(){ console.log( i ); }
		);
	})( i );
}</code></pre>
<p>Huzzah! 0,1,2! That's more like it. The function parameter is trapped in our anonymous function scope, ready to do our bidding (I'd probably call the parameter something else, just for clarity - but it's up to you).</p>
<p>For an example of this in the real world, check the source for this <a href="http://raphaeljs.com/hand.html">Raphaël demo</a>. Notice that the <em>angle</em> and <em>colour</em> parameters are passed in to an anonymous function? That's so when the click event handler fires, the colours and angles will be available inside! Nifty!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2009/11/05/self-invoking-functions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Convert WordPress fetch_rss to fetch_feed</title>
		<link>http://www.mrspeaker.net/2009/08/07/convert-wordpress-fetch_rss-to-fetch_feed/</link>
		<comments>http://www.mrspeaker.net/2009/08/07/convert-wordpress-fetch_rss-to-fetch_feed/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 00:16:37 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>
		<category><![CDATA[Nerd]]></category>

		<guid isPermaLink="false">http://www.mrspeaker.net/?p=974</guid>
		<description><![CDATA[I realised that I wasn't properly handling the return value on a feed I was grabbing to display the "Spiffy things from the Internet" section of the blog. I went to WordPress to look up the fetch_rss API details, only to find that it had been deprecated in WordPress 2.8.something. Being the ever-vigilant beacon of [...]]]></description>
			<content:encoded><![CDATA[<p>I realised that I wasn't properly handling the return value on a feed I was grabbing to display the "Spiffy things from the Internet" section of the blog. I went to WordPress to look up the fetch_rss API details, only to find that it had been deprecated in WordPress 2.8.something. Being the ever-vigilant beacon of vigilance, I decided to covert my feed-fetching to feed_fetch. Here's what I had to do.</p>
<p>There's not much to it, for the simple stuff. But SimplePie (the rss class that feed_fetch uses) has a LOT of <a href="http://simplepie.org/wiki/" title="SimplePie docs">advanced options</a> that you should check out. For a basic feed we just need to update a couple of calls. </p>
<p><span id="more-974"></span>From the old code:</p>
<pre><code>&lt;ul&gt;
&lt;?php
include_once(ABSPATH . WPINC . '/rss.php');
$rss = fetch_feed('http://feed_url_here');
foreach ( $rss-&gt;items as $item ) :
?&gt;
	&lt;li&gt;
		&lt;a href='&lt;?php echo $item['link']; ?&gt;'&gt;
			&lt;?php echo $item['title']; ?&gt;
		&lt;/a&gt;
		&lt;?php echo $item['summary']; ?&gt;
	&lt;/li&gt;
&lt;?php endforeach; ?&gt;
&lt;/ul&gt;</code></pre>
<p>To the new code:</p>
<pre><code>&lt;ul&gt;
&lt;?php
$rss = fetch_feed('http://feed_url_here'');
foreach ( $rss-&gt;get_items() as $item ) :
?&gt;
	&lt;li&gt;
		&lt;a href='&lt;?php echo $item->get_permalink(); ?&gt;'&gt;
			&lt;?php echo $item->get_title(); ?&gt;
		&lt;/a&gt;
		&lt;?php echo $item->get_description(); ?&gt;
	&lt;/li&gt;
&lt;?php endforeach; ?&gt;
&lt;/ul&gt;</code></pre>
<p>All we have done is moved from array indexes ($item['title']) to class getters ($item->get_title()). And we're away! If you hunt through the SimplePie docs, you'll notice that there are options to set cache files, timeout times, content types etc... But don't worry about these: WordPress handles it in the fetch_feed wrapper it provides.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2009/08/07/convert-wordpress-fetch_rss-to-fetch_feed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Faking email delivery in .NET</title>
		<link>http://www.mrspeaker.net/2009/07/16/faking-email-delivery-in-dot-net/</link>
		<comments>http://www.mrspeaker.net/2009/07/16/faking-email-delivery-in-dot-net/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 03:17:02 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>
		<category><![CDATA[Nerd]]></category>

		<guid isPermaLink="false">http://www.mrspeaker.net/?p=873</guid>
		<description><![CDATA[Well here's a tip that would have prevented me from barraging the owners of test.com and asdf.com with mountains of garbage test emails, had I discovered it many years ago (sorry about that, guys!). In .NET you can easily specify a location to dump emails ready to be picked up by the SMTP server. If [...]]]></description>
			<content:encoded><![CDATA[<p>Well here's a tip that would have prevented me from barraging the owners of <a href="http://www.test.com">test.com</a> and <a href="http://www.asdf.com">asdf.com</a> with mountains of garbage test emails, had I discovered it many years ago (sorry about that, guys!). In .NET you can easily specify a location to dump emails ready to be picked up by the SMTP server. If you make it a location that the SMTP server doesn't know about, then they'll sit there forever, and asdf.com can rest easy at night...</p>
<p><span id="more-873"></span>All you gots to do is add the <em>SpecifiedPickupDirectory</em> setting in your web.config, like so:</p>
<pre><code>&lt;system.net&gt;
    &lt;mailSettings&gt;
      &lt;smtp <strong>deliveryMethod="specifiedPickupDirectory"</strong>&gt;
        &lt;specifiedPickupDirectory
          <strong>pickupDirectoryLocation="c:\myEmailzHerePlz"</strong>
        /&gt;
      &lt;/smtp&gt;
    &lt;/mailSettings&gt;
  &lt;/system.net&#038;gt</code>;</pre>
<p>Make sure you create the directory, else it'll explode. And that's it! .eml files will start stacking up in the directory you specify, ready to be examined in your email client. Happy HTML-email testing day!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2009/07/16/faking-email-delivery-in-dot-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Revisions in WordPress 2.7</title>
		<link>http://www.mrspeaker.net/2009/05/23/revisions-in-wordpress-27/</link>
		<comments>http://www.mrspeaker.net/2009/05/23/revisions-in-wordpress-27/#comments</comments>
		<pubDate>Fri, 22 May 2009 23:28:34 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>
		<category><![CDATA[Nerd]]></category>

		<guid isPermaLink="false">http://www.mrspeaker.net/?p=721</guid>
		<description><![CDATA[Quick note for those running WordPress 2.7, and are starting to freak out about the 500 gazillion revision rows that are now getting inserted into your database... There are a few ways to cull them - such as deleting all posts with type "revision", but that's pretty annoying. Thankfully, the WordPress docs now have a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/images/revisions.jpg" alt="blog revisions" class="frame-right" />Quick note for those running WordPress 2.7, and are starting to freak out about the 500 gazillion revision rows that are now getting inserted into your database... There are a few ways to cull them - such as deleting all posts with type "revision", but that's pretty annoying. Thankfully, the WordPress docs now have a <em>rough draft</em> up on <a href="http://codex.wordpress.org/Revision_Management">revision management</a> which outlines some "hidden options".</p>
<p>The nicest is the WP_POST_REVISIONS setting you can add to your wp-config.php file. It accepts the following values:</p>
<p><span id="more-721"></span></p>
<ul>
<li>true (default), -1: store every revision</li>
<li>false, 0: do not store any revisions (except the one autosave per post)</li>
<li>(int) > 0: store that many revisions (+1 autosave) per post. Old revisions are automatically deleted.</li>
</ul>
<p>So you can turn them off entirely by setting WP_POST_REVISIONS to false. I like to keep it enabled (it <em>is</em> useful when you just realised you did something stupid) but limit it to, say, 10 rows per post. Just open up wp-config.php in your text editor and add the line:<br />
<code>define('WP_POST_REVISIONS', 10);</code><br />
The next time you save a post, all the old revisions (besides the last 10) will be automatically deleted and your database will breathe a sigh of relief.</p>
<p>You can add the definition anywhere in the config file, but I put mine just before the comment: <code>/* That's all, stop editing! Happy blogging. */</code></p>
<p>That's all, stop editing! Happy blogging.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2009/05/23/revisions-in-wordpress-27/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wolfram Alpha and jQuery Easing</title>
		<link>http://www.mrspeaker.net/2009/05/19/wolfram-alpha-and-jquery-easing/</link>
		<comments>http://www.mrspeaker.net/2009/05/19/wolfram-alpha-and-jquery-easing/#comments</comments>
		<pubDate>Tue, 19 May 2009 12:15:23 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>
		<category><![CDATA[Nerd]]></category>

		<guid isPermaLink="false">http://www.mrspeaker.net/?p=580</guid>
		<description><![CDATA[Wolfram Alpha is out and about, and promising to link all information in the world together in a way that will render further human thought obsolete. Most people who know that thinking is boring, and want to learn important things about b-grade celebrities, quickly realised this weird search engine wasn't going to tell them anything [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.mrspeaker.net/wp-content/uploads/2009/05/wolframalphafail.png" alt="wolfram alpha fail" title="wolfram alpha fail" /></p>
<p>Wolfram Alpha is out and about, and promising to link all information in the world together in a way that will render further human thought obsolete. Most people who know that thinking is boring, and want to learn important things about b-grade celebrities, quickly realised this weird search engine wasn't going to tell them anything exciting, and moved on. I realised it too - so was quite shocked, when this afternoon I needed Wolfram Alpha's help in answering a pressing concern I had about the jQuery default easing algorithms, "swing" and "linear"...<br />
<span id="more-580"></span><br />
Like every good nerd I jumped on Wolfram Alpha the first opportunity I had - expecting it to solve all of life's mysteries for me (and guessing it will tell me the meaning of life is 42, I am refusing to type it in). Of course, I left the site 2.5 minutes later, impressed with the idea of putting the spinner inside the logo - but having no other real feelings about it...</p>
<p>...24 hours later, only the noise of a clattering keyboard can be heard. A gentle rain stokes the windows. Dusk. I am penning some amazingly creative and humorous lines about "easing" in jQuery. Easing, you see, is applying a simple mathematical to a piece of animation to make it look more cool, like there is a gravity-like force being applied to it. In jQuery there are two built-in easing methods that you can use. One is called "linear" and on is called "swing".</p>
<p>Linear, I imagine, means that <em>no</em> real algorithm is applied - and an element just moves at a constant speed from its start position to its destination. "Swing" however... I was unsure about. I mean, I'd seen it go of course - it's the default easing method in jQuery - but I couldn't find any reference to what "swing" look like when graphed. (Here's a graph of a bunch of <a href="http://hosted.zeh.com.br/tweener/docs/en-us/misc/transitions.html">more complex easing functions</a>)</p>
<p>What <em>was</em> this "swing" algorithm? Google turned up nothing. I was all alone. My first step was the jQuery code. I found this:</p>
<pre><code>
swing: function( p, n, firstNum, diff ) {
	return ((-Math.cos(p*Math.PI)/2) + 0.5)
			* diff + firstNum;
}</code></pre>
<p>But what the heck does that mean? Sure, it looks nice and cos-y, but I wanted to find a snazzy graph to see what it looks like. I could try and find some graphing software and wasting a zillion hours trying to re-write the algorithm, or... wait a minute! Are you thinking what I'm thinking?! YES! WOLFRAM ALPHA!</p>
<p>Taking the JavaScript keywords out of the equation, I just popped this into the search bar: (-cos(p*PI)/2) + 0.5). And after a bit of fiddling, Bob's your uncle - a perdy graph!</p>
<p><img src="http://www.mrspeaker.net/wp-content/uploads/2009/05/easing.png" alt="jquery default easing" title="jquery default easing"  /></p>
<p>To me, "swing" looks closest to "easeInOutSine" from the <a href="http://www.robertpenner.com/easing/easing_demo.html">Robert Penner easing algorithms</a>. I'll have to check the code some day. But anyhoo... thank you Wolfram Alpha, my apathy owes you an apology.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2009/05/19/wolfram-alpha-and-jquery-easing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vertical Selecting</title>
		<link>http://www.mrspeaker.net/2007/08/31/vertical-selecting/</link>
		<comments>http://www.mrspeaker.net/2007/08/31/vertical-selecting/#comments</comments>
		<pubDate>Fri, 31 Aug 2007 03:42:52 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>

		<guid isPermaLink="false">http://mrspeaker.webeisteddfod.com/2007/08/20/vertical-selecting/</guid>
		<description><![CDATA[Here's a helpful little mouse-wielding tip for all you Windows users out there (Oops, "mouse" and "Windows" - there goes my geek cred.)... Did you know that you can vertically select text in some programs? Well you can, with the power of ALT + mouse! Selecting text with a mouse is a very important computer-user [...]]]></description>
			<content:encoded><![CDATA[<p>Here's a helpful little mouse-wielding tip for all you Windows users out there (Oops,  "mouse" <em>and</em> "Windows" - there goes my geek cred.)... Did you know that you can vertically select text in some programs? Well you can, with the power of <em>ALT + mouse</em>!</p>
<p>Selecting text with a mouse is <span style='background-color:#0A246A;color:#fff;'>a very important computer-user skill, that enables you to capture parts of a paragraph</span> or sentence for use in other applications.</p>
<p>But what if, right, you wanted to extract just the messages from the text below, and paste them somewhere else:<br />
<span id="more-202"></span><br />
14:18:27 DEBUG: OnItemRemoved from cache<br />
14:18:56 DEBUG: Initialise Application<br />
14:19:14 DEBUG: MemberCurrent unavailable<br />
14:22:21 DEBUG: IRegistrationModule added</p>
<p>Well, you could select it all, paste it to the destination, then remove the timestamp from each line... but if there was 20 gazillion lines that'd take a while...</p>
<p><strong>ALT + mouse!</strong><br />
If you had that list opened up in Notepad++, Microsoft products (Word, Visual Studio, SQL Server Management thingo, Outlook...), and most likely many others, you could use the not-often-enough used ALT key to help you out.</p>
<p>Simply hold down ALT then make your selection - notice that you are free to roam the screen, unrestricted by the text below! </p>
<p>Kid Koala - <span style='background-color:#0A246A;color:#fff;'>01 - </span>Strat Hear<br />
Kid Koala - <span style='background-color:#0A246A;color:#fff;'>02 - </span>Basin Street Blues<br />
Kid Koala - <span style='background-color:#0A246A;color:#fff;'>03 - </span>Radio Nufonia<br />
Kid Koala - <span style='background-color:#0A246A;color:#fff;'>04 - </span>Stompin' At Le Savoi<br />
Kid Koala - <span style='background-color:#0A246A;color:#fff;'>05 - </span>Space Cadet 2<br />
Kid Koala - <span style='background-color:#0A246A;color:#fff;'>06 - </span>Grandmaphone Speaks</p>
<p>You can also <em>paste</em> a selection vertically as well, which is pretty damn cool.</p>
<p>It seems to work with a bunch of Microsoft products (it works on Word on Mac, but sadly not <em>Notepad</em>), and a few other text editors I tried. </p>
<p>It doesn't work on Linux, as ALT + Mouse moves the current screen around (which is also very handy) - Though if you're using Linux then you don't touch the mouse anyway, and you would have regex-ed out the result before you even had a chance to think about it.</p>
<p><strong>There you go</strong><br />
A bonus handy-hint: if your vertical lines don't match-up happily, try converting the font to a monospace font (like Courier).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2007/08/31/vertical-selecting/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Javascript Hexadecimal Helpers</title>
		<link>http://www.mrspeaker.net/2006/11/23/javascript-hex-helpers/</link>
		<comments>http://www.mrspeaker.net/2006/11/23/javascript-hex-helpers/#comments</comments>
		<pubDate>Thu, 23 Nov 2006 09:25:06 +0000</pubDate>
		<dc:creator>Mr Speaker</dc:creator>
				<category><![CDATA[Dictaphone]]></category>
		<category><![CDATA[Nerd]]></category>

		<guid isPermaLink="false">http://mrspeaker.webeisteddfod.com/2006/11/17/javascript-hex-helpers/</guid>
		<description><![CDATA[Hexadecimal sure comes in handy sometimes. Like, say, um, if you wanted to know why there was some of the alphabet on your scientific calculator for example. Here are a couple of javascript objects to help you out with some hexadecimal byte conversion.]]></description>
			<content:encoded><![CDATA[<p><img src="/images/oboeshoes.gif" alt="Oboe Shoes" class="frame-right" style="border:0;" />Hexadecimal sure comes in handy sometimes. Like, say, um, if you wanted to know why there was some of the alphabet on your scientific calculator for example. There's been a few times I've needed the following functions to convert decimal bytes to hex in javascript: converting decimal RGB values to those <span style="color:#f0f">#FF00FF</span> looking ones, or far more commonly, creating <a href="http://mrspeaker.webeisteddfod.com/2005/03/27/xmb-images/">XBM</a> images by hand. You <em>do</em> create your XBM images by hand don't you?</p>
<p>First up, here's a javascript object I use to convert bytes (0-255) between the two numbering systems. I can't remember where I got the guts of the dec2hex function. But I do like it:<br />
<span id="more-290"></span></p>
<pre><code>
var HexConverter = {
	hexDigits : '0123456789ABCDEF',

	dec2hex : function( dec )
	{
		return( this.hexDigits[ dec >> 4 ] + this.hexDigits[ dec &#038; 15 ] );
	},

	hex2dec : function( hex )
	{
		return( parseInt( hex, 16 ) )
	}
}
</code></pre>
<p>Here's a couple of example usages:</p>
<p><code>alert( HexConverter.dec2hex( 240 ) ); // gives: F0</code><br />
<code>alert( HexConverter.hex2dec( 'EF' ) ); // gives: 239</code></p>
<p>That's all you need for byte conversion happiness. But if you, like me, want some hardcore performance boostin' you'll want to use a lookup table. I got the lookup table method from the impressive <em><a href="http://www.wolf5k.com/">Wolf5k</a></em>. The lookup table means that you don't have to do CPU intensive operations every time you need to convert decimal to hex. Yeah, it's not really CPU intensive. But if you want to make Wolfenstein in 5k of javascript you'll need all the help you can get.</p>
<pre><code>
var HexHelper = {
	hexDigits : '0123456789ABCDEF',

	lookup : [],
	initLookup : function()
	{
		for( var i = 0; i < 256; i++ )
		{
			this.lookup[ i ] = '0x' + this.hexDigits[ i >> 4 ] + this.hexDigits[ i &#038; 15 ];
		}
	},
}
HexHelper.initLookup();
</code></pre>
<p>example usage: </p>
<p><code>alert( HexHelper.lookup[129] ); //gives 0x81</code></p>
<p>All this talk of XBM images has made me sad. I miss them. <a href="http://mrspeaker.webeisteddfod.com/2006/09/04/the-end-of-xbm/">DAMN YOU MICROSOFT!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrspeaker.net/2006/11/23/javascript-hex-helpers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

