<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">

	<title type="text">mennovanslooten.nl</title>
	<subtitle type="text"></subtitle>
	<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/" />
	<link rel="self" type="application/atom+xml" href="http://www.mennovanslooten.nl/blog/atom/" />
	<updated>2010-04-27T08:29:36+02:00</updated>
	<rights>Copyright (c) 2006, Menno van Slooten</rights>

	<generator uri="http://www.codeigniter.com/" version="1.5.1">Code Igniter</generator>
	<id>tag:mennovanslooten.nl,2006:/blog</id>


			<entry>
			<title>jQuery Bay Area Conference 2010</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/75" />
			<id>tag:mennovanslooten.nl,2010-04-27:/blog/post/75</id>

			<published>2010-04-27T08:29:36+02:00</published>
			<updated>2010-04-27T08:29:36+02:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p><a href="http://www.flickr.com/photos/dougneiner/4555793190/"><img src="http://farm5.static.flickr.com/4026/4555793190_9c486500a8_m.jpg" alt="" title="A picture taken of my presentation by Doug Neiner"/></a> This weekend I was in Mountain View to speak at the <a href="http://events.jquery.org/2010/sf-bay-area/">jQuery Bay Area Conference 2010</a> which was incredible. It was really amazing to meet so many passionate JavaScript developers and an honor to be part of that group for 2 days. <a href="http://speakerrate.com/talks/2976-automated-ui-testing-with-jquery">My presentation</a> was about automated UI testing and focused on a framework I have developed at <a href="http://www.ebuddy.com">eBuddy</a> to do UI testing on <a href="http://web.ebuddy.com">our new web messenger</a>.</p>

<p>Although the presentation was a bit messy (the room's technician hijacked my laptop for a couple of minutes to fix an issue with one of the screens), the framework seemed to struck a chord with many developers. Afterwards it was made very clear by some of them that I should get it out in the open as soon as possible. I specifically asked them "how?" and it was unanimously decided <a href="http://github.com/mennovanslooten/UITest">it should definitely be on GitHub</a>. So there you go.</p>

<p>Unfortunately, from the San Francisco hotel I'm currently staying in, I can't seem to get a good enough connection to this site's FTP server or otherwise I would have put up a demo and made my slides available. That will have to wait until I get back to The Netherlands. I will try to start adding some useful documentation as well.</p>

<p>I really hope some people in the jQuery community will pick up this ball and start running with it. Several people at the conference said it could be a useful tool including some jQuery and jQuery UI team members. If you like it, please send some love in eBuddy's direction since they were the ones who allowed me to develop <em>and</em> release it in the first place.</p>

<p>I would like to thank the jQuery team and all the other speakers having me there and making this weekend an unforgettable experience. Hopefully, I can meet you all at another conference in the near future. Perhaps <em>jQuery Amsterdam 2010</em>?</p>

<p><strong>P.S.</strong> Ralph Whitbeck and Rey Bango of the official jQuery podcast interviewed me right after the presentation and <a href="http://blip.tv/file/3579912">put up the video as well</a> and I <a href="http://www.slideshare.net/mennovanslooten/jquery-bay-area-conference-2010">put up the slides as well</a>.</p>
			]]></content>
		</entry>
			<entry>
			<title>New eBuddy Web Messenger</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/73" />
			<id>tag:mennovanslooten.nl,2010-02-12:/blog/post/73</id>

			<published>2010-02-12T11:56:59+01:00</published>
			<updated>2010-02-12T11:56:59+01:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p><img src="/static/gfx/aurora2.png" alt=""/> It's been awfully quiet out here but now I have some actual news to share with you. At <a href="http://www.ebuddy.com">eBuddy</a> headquarters in Amsterdam, I've been working with my team on creating a new web messenger.</p>

<p>Even though eBuddy's current web messenger is an awesome product and – with over 2,5 million users daily – the most popular multi-network IM client on the web, it definitely has its shortcomings, both for users as well as for the developers working on it. The new messenger has been designed from the ground up to overcome these shortcomings, creating a product that is both easier to work with as well as to work on.</p>

<p>In the future, I'd like to tell you about some of the technical improvements we've made, such as the publish/subscribe based architecture and the custom made automated GUI testsuite. For now, I'll just point you straight towards <a href="http://web.ebuddy.com">web.ebuddy.com</a> and hope you'll have a great chat experience. If you have any remarks, don't hesitate to contact me via the link below or click the "Feedback" button at the top of the messenger.</p>			]]></content>
		</entry>
			<entry>
			<title>Plasma effects</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/72" />
			<id>tag:mennovanslooten.nl,2009-02-02:/blog/post/72</id>

			<published>2009-02-02T09:27:37+01:00</published>
			<updated>2009-02-02T09:27:37+01:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p>I recently tried to recreate the famous <em>plasma effect</em> that was often used in the demo scene. Since I didn't know a lot about it and how to achieve it I had to do some research first. I thought I'd write a little bit about what the effect is and how I ended up implementing it.</p>
&lt;style type="text/css"&gt;
    #target {
        margin:1.5em 0 0 1.5em;
        width:256px;
        height:256px;
        float:right;
        position:relative;
        xleft:16px;
        xtop:16px;
        background:#E7E7CC url(/static/gfx/plasma_0.gif) no-repeat;
    }
    
    #target div {
        position:absolute;
    }
&lt;/style&gt;

<div id="target"></div>
[removed][removed]

<p>Click inside the square on the right to see the plasma effect in action. Click again to stop the animation.</p>

<p>First a little disclaimer: usually, these effects are coded by very smart, very math-savvy programmers that know their target system inside and out. None of these attributes apply to me so I just brute-forced my way through the implementation making convenient choices whereever possible:</p>

<ol>
    <li>The canvas is 32 units wide and 32 units high.</li>
    <li>One such unit is an 8 by 8 pixed <code>div</code> element, making the total width and height 256 pixels.</li>
    <li>The color pallette will consist of 256 colors.</li>
</ol>

<p>After some research I found that the principle behind the effect is really simple. The base is any function <em>f</em>(x, y, t) = n where x and y are the coordinates in the canvas, t is the time and n is an integer between 0-256, representing a color in the palette. When we have such a function we initiate by drawing the canvas for t=0 after which we redraw the canvas periodically for new values of t, which generates the 'flowing' colors. The next step was to find such a function.</p>

<h3>The first function</h3>

<img src="/static/gfx/plasma_1.gif" style="float:right; margin:1.5em 0 0 1.5em;" width="128" height="128"/>
<p>Remember that the output of the function should stay in the 0-256 range. The easiest way to guarantee this is to base our functions on <em>sin</em> and <em>cos</em>, since their result is always between -1 and 1. For clarity I will not discuss the normalization from floats between -1 and 1 to integers between 0 and 256 here so we can suffice with <em>f</em> being in the -1 to 1 range.</p>

<p>A simple example of the type of function we're looking for is then: <em>f</em>(x) = sin(x / 40.74). The 40.74 is to make our <em>sin</em> have a period of about 256. If we then map the output to a greyscale palette where 0 is black and 255 is white we get something like the picture on the right.</p>

<h3>The second function</h3>

<img src="/static/gfx/plasma_2.gif" style="float:right; margin:1.5em 0 0 1.5em;" width="128" height="128"/>
<p>Looks nice, but it doesn't resemble a plasma effect, so let's investigate a little further for a nice function. Something that's used often in this effect is the sinus of a distance to a certain point in the canvas. Here's such a function: <em>f</em>(x, y) = sin(distance(x, y, 128, 256) / 40.74), where distance(x1, y1, x2, y2) is the distance between (x1, y1) and (x2, y2). In our case we're measuring the distance to the center of the bottom edge. Mapping this to our palette we'd get something like the picture on the right again.</p>

<h3>Combining two functions</h3>

<img src="/static/gfx/plasma_3.gif" style="float:right; margin:1.5em 0 0 1.5em;" width="128" height="128"/>
<p>The last picture already looked a bit more like a good base for a plasma effect. The interesting stuff happens if we combine the two functions and average their results. As you can see in the picture on the right, this is getting pretty close to the effect we're looking for: flowing, asymmetrical blobs of color. Two things remain: finding a nicer palette of colors to map and adding in some animation.</p>

<h3>Animation</h3>

<p>Adding animation is reasonably straightforward. We just introduce a variable <em>t</em> in a strategic place to our functions which we continuously increment. Usually for these effects t starts at 0 and is incremented by 1 each step. In my experience floating point arithmetic isn't particularly slower than integer arithmetic in JavaScript so I chose to increment by 0.1 because it was more convenient. Here's an example of the 2 previous functions with the added t variable:</p>
<ol>
    <li><strong>f(x, t) = sin(x / 40.74 + t)</strong> - which gives the effect of the first pattern moving to the left.</li>
    <li><strong>f(x, y, t) = sin(distance(x, y, (128 * sin(-t) + 128), (128 * cos(-t) + 128)) / 40.74)</strong> - which gives the effect of the second pattern rotating around the center of the canvas.</li>
</ol>

<h3>Colors</h3>

<p>Believe it or not, we're not completely done with sinus and cosinus yet. The nicest effects are achieved with palettes that smoothly 'wrap around'. These types of palettes are usually generated with mathematical functions. Here's a few examples where for each palette we iterate i from 0-256 and the red, green and blue values are normalized to 0-256 integers again:</p>

<p><img src="/static/gfx/plasma_palette_1.gif"/>
<em>red</em>(i) = sin(π * i / 32)<br/>
<em>green</em>(i) = sin(π * i / 64)<br/>
<em>blue</em>(i) = sin(π * i / 128)</p>

<p><img src="/static/gfx/plasma_palette_2.gif"/>
<em>red</em>(i) = 0<br/>
<em>green</em>(i) = cos(π * i / 128)<br/>
<em>blue</em>(i) = sin(π * i / 128)</p>

<p><img src="/static/gfx/plasma_palette_3.gif"/>
<em>red</em>(i) = cos(π * i / 128)<br/>
<em>green</em>(i) = sin(π * i / 128)<br/>
<em>blue</em>(i) = 0</p>

<p>Combining all this: the functions, the animation, the palette I ended up with the plasma effect shown above. It should be clear right now that there is an endless range of possibilities for variations on this theme. Like so many things I write about this started of as a little 'how does that work?'-experiment. This is how I think it works but if you're reading this and have a better idea, don't hesitate and <a href="/blog/contact/">let me know</a>!</p>			]]></content>
		</entry>
			<entry>
			<title>Flexible panel layouts revisited</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/71" />
			<id>tag:mennovanslooten.nl,2009-01-28:/blog/post/71</id>

			<published>2009-01-28T10:33:18+01:00</published>
			<updated>2009-01-28T10:33:18+01:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p>A couple of years ago I wrote a small post about what I call "panel layouts" and how to create them with CSS. I've used the method succesfully for a number of projects since then but there was always something that bothered me: to make it work, browsers had to be forced to render in the <em>content box model</em> using a forced <em>quirks mode</em>. Recently I started using another way, that eliminated this problem.</p>

<h3>Flexible panels</h3>
<p><img src="/static/gfx/outlook_layout.gif" alt=""/> <strong>The ideal I'm trying to achieve is to have a <strong>viewport-filling layout</strong> with flexible and fixed panels combined.</strong> A common example is what I usually refer to as the "Outlook layout". Here's <a href="http://experiments.mennovanslooten.nl/2008/panels/panels.html">a more complex example</a>.</p>
<p>The hard part here is to have flexible panels that fill whatever space isn't taken up by other (fixed) panels. Ideally you'd be able to write something like this:</p>
<pre>
.contentPanel {
    width: calc(100% - 200px);
    height: calc(100% - 400px);
}
</pre>
<p>...which in CSS3, <a href="http://www.w3.org/TR/css3-values/#calc">you will be able to</a>.  However, we're not going to wait for that, so we're going to use an often-ignored feature of CSS: <strong>if you have an absolutely positioned element and you specify <code>left</code> and <code>right</code> but not <code>width</code>, the width becomes flexible</strong>: the edges stick to their coordinates. The same goes for <code>height</code> if you spefify <code>top</code> and <code>bottom</code>. Using this technique, we can get what we want:</p>
<pre>
.contentPanel {
    position: absolute;
    left: 200px;
    right: 0;
    top: 400px;
    bottom:0;
}
</pre>
<p>But the story doesn't end here. Although this technique runs fine in (standards mode) IE7, IE6 does not support it. For this browser, we will use an even rarer technique: <code>[removed])</code>.</p>
<p><code>[removed])</code> is an IE-only CSS statement that works a lot like <code>calc()</code> mentioned above. With it, you can assign the result of a JScript expression to a CSS property. In our case:</p>
<pre>
.contentPanel {
    width: [removed]this[removed].clientWidth - 200 + 'px');
    height: [removed]this[removed].clientHeight - 400 + 'px');
}
</pre>
<h3>An example</h3>
<p>Let's create an example to illustrate the two techniques and how to combine them. Here's a set of three panels, the top one fixed height, the left one fixed width, the remaining one flexible:</p>

<div id="panels">
    <div id="panelTop"><code>#panelTop</code></div>
    <div id="panelLeft"><code>#panelLeft</code></div>
    <div id="panelRight"><code>#panelRight</code>
    [removed]
    function setPanelWidth(w) {
        document.getElementById('panels').style.width = w + '%';
    }
    [removed]
    <p>Click the buttons to set the total width.</p>
    <button>50%</button>
    <button>75%</button>
    <button>100%</button>
    </div>
</div>

&lt;style type="text/css"&gt;
#panels {
    width:100%;
    height:10em;
    position:relative;
}

#panelTop, #panelLeft, #panelRight {
    position:absolute;
    left:0;
    top:0;
    overflow:auto;
}

#panelTop {
    width:100%;
    height:20px;
    background:#F7F7CC;
}

#panelLeft {
    top:20px;
    width:100px;
    bottom:0;
    height:[removed]this[removed].clientHeight - 20 + 'px');
    background:#CCF7F7;
}

#panelRight {
    top:20px;
    left:100px;
    right:0;
    bottom:0;
    width:[removed]this[removed].clientWidth - 100 + 'px');
    height:[removed]this[removed].clientHeight - 20 + 'px');
    background:#F7CCF7;
}
&lt;/style&gt;

<p>As you can see, <code>#panelRight</code> fills up whatever space remains. Its CSS is very simple:</p>
<pre>
#panelRight {
    top:20px;
    left:100px;
    right:0;
    bottom:0;
    width:[removed]this[removed].clientWidth - 100 + 'px');
    height:[removed]this[removed].clientHeight - 20 + 'px');
    background:#F7CCF7;
}
</pre>

<h3>Issues</h3>
<p><code>expression</code> Is of course a non-standard CSS property that will invalidate your CSS file. Browsers that don't support it will gracefully ignore it (as they should) but the W3C CSS validator will not. There are several ways to hide the code from validators (i.e. conditional comments) so if you care about validating your CSS you should take some extra steps there.</p> 
<p>Another issue is that I haven't found a way yet to combine multiple flexible  panels horizontally or vertically. The method works beautifully, however, in my experience and makes it really easy to define flexible page layouts with just a few lines of CSS and the most basic HTML.</p>			]]></content>
		</entry>
			<entry>
			<title>More JavaScript combinatorics</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/70" />
			<id>tag:mennovanslooten.nl,2009-01-27:/blog/post/70</id>

			<published>2009-01-27T08:18:22+01:00</published>
			<updated>2009-01-27T08:18:22+01:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p>An email sent by a reader of <a href="http://www.mennovanslooten.nl/blog/post/51">my previous post about combinatorics</a> renewed my interest in the subject. As I wrote in that particular post I didn't really understand why the code did what it did. It was actually the result of an almost evolutionary process of trial and error until I was confident it did what it should do.</p>

<h3>Another method</h3>
<p>A reader called Fabrice pointed out another way to get the same results using bitmasks. For example, when you want to get <em>all</em> the combinations of items from <code>[0,1,2]</code> you create a list binary representations of the numbers 1 to (2<sup>3</sup>-1):</p>
<ol>
<li><code>001</code></li>
<li><code>010</code></li>
<li><code>011</code></li>
<li><code>100</code></li>
<li><code>101</code></li>
<li><code>110</code></li>
<li><code>111</code></li>
</ol>
<p>Applying each of these numbers as a mask to the original array gives us all the combinations:</p>
<ol>
<li><code>001 × [0,1,2] = [2]</code></li>
<li><code>010 × [0,1,2] = [1]</code></li>
<li><code>011 × [0,1,2] = [1,2]</code></li>
<li><code>100 × [0,1,2] = [0]</code></li>
<li><code>101 × [0,1,2] = [0,2]</code></li>
<li><code>110 × [0,1,2] = [0,1]</code></li>
<li><code>111 × [0,1,2] = [0,1,2]</code></li>
</ol>

<p>It's a very simple algorithm to understand and to implement. Since this returns all possible combinations the only thing left is filtering for results of a certain length. Here's an implementation in JavaScript as an extension on the array prototype:</p>

<pre class="JavaScript" name="code">
Array.prototype.combinate2 = function( length ) {
    var result = [];
    // iterate from 1 to 2<sup>n</sup>
    for (var i = 1; i &lt; Math.pow(2, this.length) - 1; i++) {
         var combination = [];
         // For each value of i, check the individual 'bits' (powers of 2
         // components). If 2<sup>m</sup> is a component of i then this[m] is a
         // part of this combination
         for (var j = 0; j &lt; i; j++) {
             var mask = Math.pow(2,j);
             if (i &amp; mask) {
                 combination.push(this[j]);
             }
         }
         if (combination.length === length) {
             result.push(combination);
         }
    }
    
    return result;
}
</pre>

<h3>Performance problems</h3>
<p>Unfortunately, the simplicity of the algorithm comes with a price: the time it takes to execute increases much more quickly with the length of the array than the other one. If I knew something about big O-notation I could probably write something profound about why this is the case. It's a shame I don't because I feel it would really help understanding stuff like this. On the other hand, after having taken another look at the code from the original post I now fully understand what it does. Perhaps I will dedicate another post to that subject.</p>			]]></content>
		</entry>
			<entry>
			<title>Kings of Code 2008</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/67" />
			<id>tag:mennovanslooten.nl,2008-05-28:/blog/post/67</id>

			<published>2008-05-28T22:13:19+02:00</published>
			<updated>2008-05-28T22:13:19+02:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p>
<img src="/static/gfx/logo-kingsofcode.png"/>
Yesterday I attended the Kings of Code event for web developers where I had the opportunity to present on a topic very close to my heart: the development of front-end development. Of course I also saw most of the other speakers. Here's a little review of the day.</p>

<h3>Peter Paul Koch (<a href="http://www.quirksmode.org/">Quirksmode</a>)</h3>
<p>First up, at 9:30 AM, was PPK with a <a href="http://www.quirksmode.org/blog/archives/2008/05/kings_of_code_s.html">presentation on cross-browser JavaScript event handling</a>. Most people were in on time, for a change and there were an amazingly little amount of laptops being opened by attendees. (something that usually annoys me alot) PPK, obviously no stranger to presenting delivered a flawless and technically very deep presentation about the differences between the W3C's events spec and the real world as implemented by Safari, IE, Opera and Firefox. Quote of the day: "I think I'll start looking into this Firebug thing, I hear it's pretty good."</p>

<h3>Folke Lemaitre (<a href="http://netlog.com/">Netlog</a>)</h3>
<p>Next up, was Folke who presented on the scaling of Netlog's back-end architecture. As a front-end developer, most of that stuff was somewhat over my head but interesting nonetheless. I know my eBuddy colleagues who deal with the scaling of our own platform were listening attentively :)</p>

<h3>Mark Birbeck (<a href="http://www.w3.org/">W3C</a>)</h3>
<p>After the morning break, Mark Birbeck took the stage with a presentation about markup languages that I'm sure was not to everybody's tastes. I found it to be the most interesting talk of the day because he concluded that markup languages like XForms and SMIL are an excellent way to abstract the complexity of JavaScript away. That's something that I've been preaching since the early days of <a href="http://www.backbase.com">Backbase</a> (and by the way, my subject of the <a href="http://www.mennovanslooten.nl/blog/post/43">presentation I gave at XTech</a> 2006). Later on, I realized why Mark's name was so familiar. He was once responsible for building a plugin for IE that added XForms support.</p>

<h3>Nate Abele (<a href="http://cakephp.org/">CakePHP</a>)</h3>
<p>Lots of controversy ensued when the first Nate took the mic. After a brief introduction about what frameworks are and why and when you should use one, he proceeded to rip apart some well-known competitors of his CakePHP framework: <a href="http://framework.zend.com/">Zend</a>, <a href="http://codeigniter.com/">CodeIgniter</a> (on which this blog is built) and <a href="http://rubyonrails.org/">Rails</a>. It was quite funny actually and I found him to be refreshingly honest. A welcome change from the let's-pet-each-other-on-the-back- syndrome.</p>

<h3>Nate Koechley (<a href="http://yahoo.com/">Yahoo!</a>)</h3>
<p>Unfortunately I had to miss this one, as I had to be someplace else. I heard it was really good though; a very comprehensive presentation about startup performance, even though a lot of the material was well-known to the crowd.</p>

<h3>Open Source Pitches</h3>
<p>As I still had to prepare some slides for my presentation I decided to miss out on these. I heard there was a lot of disappointment that the 5-minute Phusion Passenger pitch was spent on promoting Rails, in stead of Passenger.</p>

<h3>Menno van Slooten (<a href="http://ebuddy.com">eBuddy</a>)</h3>
<p>I didn't see this one, but I heard it was pretty good ;) In all seriousness, I was really bloody nervous but luckily it was a very friendly crowd with lots of my old friends and colleagues. The presentation itself went pretty smooth in my experience with only a few hickups. If there's a next time I'll cover a more technical subject since I feel more at ease with that than with yesterday's subject matter: a look into the future of front-end developers. Here's <a href="http://www.flickr.com/photos/25246539@N05/2528818496/">a picture of me</a> during the presentation.</p>

<h3>John Resig (<a href="http://jquery.com">jQuery</a>)</h3>
<p>John absolutely blazed through a presentation that was obviously normally delivered in a much bigger timeslot. He took the big 4 in the world of Open Source JavaScript frameworks: jQuery, <a href="http://developer.yahoo.com/yui/">YUI</a>, <a href="http://dojotoolkit.org/">Dojo</a> and <a href="http://www.prototypejs.org/">Prototype</a> and compared them on various levels, from unit test coverage to CSS selector speed. It was very, very interesting, but I think the crowd would have appreciated a more spicy presentation (for instance about processing.js) a bit more. At the end of his presentation he mentioned he was working on a new DOM CSS selector module (I believe he called it Sizzle) and showed a table with some query benchmarks that looked very impressive. I hope to see more of that soon.</p>

<h3>Drinks at 11</h3>
<p>Luckily my bosses were willing to be the main sponsor for the drinks afterwards in the <a href="http://www.worldsbestbars.com/public/venue_listing.jsp?categoryId=1&currentVenueId=a68">excellent Club 11</a>. The atmosphere was good, with the DJ playing some nice Motown soul &amp; R&amp;B tracks. People were stopping me to tell me what they thought of my presentation and the worst criticism I received was "I liked your presentation but I don't agree with what you said." I can certainly live with that.</p>

<h3>Overall</h3>
<p>I have nothing but good words for the organisation and the visiting crowd. The whole event was flawlessly orchestrated and the atmosphere was extremely enjoyable. I heard the coffee wasn't that good, but that's about it. In the end, I only regret not taking more time to talk JavaScript with Resig, PPK and Koechley. So thanks to Sander and the rest of the crew and I hope I can be a part of future events as well.</p>
			]]></content>
		</entry>
			<entry>
			<title>Speaking at Kings of Code</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/66" />
			<id>tag:mennovanslooten.nl,2008-05-23:/blog/post/66</id>

			<published>2008-05-23T09:26:17+02:00</published>
			<updated>2008-05-23T09:26:17+02:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p>I am really, really pleased to write that I'll be speaking at the (Dutch) <a href="http://kingsofcode.nl/">Kings of Code</a> developers gathering next week, alongside such illustrious names as <a href="http://ejohn.org/">John Resig</a> and <a href="http://quirksmode.org/">Peter Paul Koch</a>. I was lucky enough to get into contact with the organisers through my employer, <a href="http://www.ebuddy.com">eBuddy</a> and thankfully they found some room in their busy schedule for me to deliver a presentation on the future of front-end development.</p>			]]></content>
		</entry>
			<entry>
			<title>Function.apply() and Function.call()</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/65" />
			<id>tag:mennovanslooten.nl,2008-05-16:/blog/post/65</id>

			<published>2008-05-16T09:21:28+02:00</published>
			<updated>2008-05-16T09:21:28+02:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p>I've been meaning to write this post for a while, now, mostly as a reminder to myself. The subject is the two methods available for all JavaScript functions: <code>apply()</code> and <code>call()</code>. Confusingly, they both do the same thing in very, very similar ways: executing the function in the scope of a specified object. I've always had trouble remembering their major difference, however, so I decided to finally write this post and hope it sticks.</p>
<h3>What they both do</h3>
<p>I can make this a very technical post about the ins and outs of these methods or I can just summarize by writing the following: <strong>apply() and call() allow you to specify what <code>this</code> will refer to inside that function</strong>, even when that function is a method on another object. An example:</p>
<pre>
var someObject = {
    myProperty : 'Foo',
    myMethod : function() {
        alert&#40;this.myProperty&#41;;
    }
};
someObject.myMethod(); // alerts 'Foo'

var someOtherObject  = {
    myProperty : 'Bar'
};
someObject.myMethod.call(someOtherObject); // alerts 'Bar'
someObject.myMethod.apply(someOtherObject); // alerts 'Bar'
</pre>
<p>As you can see, even thought it is <code>someObject</code>'s method that is executed, call() and apply() allows me to specify that the keyword <code>this</code> refers to <code>someOtherObject</code>.</p>

<h3>The difference</h3>
<p>The difference between these methods is in the way you can pass arguments to the original function. Let's extend the example to include arguments:</p>
<pre>
var someObject = {
    myProperty : 'Foo',
    myMethod : function(<strong>prefix, postfix</strong>) {
        alert&#40;prefix + this.myProperty + postfix&#41;;
    }
};
someObject.myMethod('&lt;', '&gt;'); // alerts '&lt;Foo&gt;'

var someOtherObject  = {
    myProperty : 'Bar'
};
someObject.myMethod.call(someOtherObject, <strong>'&lt;', '&gt;'</strong>); // alerts '&lt;Bar&gt;'
someObject.myMethod.apply(someOtherObject, <strong>['&lt;', '&gt;']</strong>); // alerts '&lt;Bar&gt;'
</pre>
<p>Obviously, the difference is this: If you want to pass arguments to the function <strong>apply() needs an array and call() needs a list of arguments</strong>. That's it! Ridiculously hard to remember, I know.</p>
			]]></content>
		</entry>
			<entry>
			<title>Out with the old...</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/64" />
			<id>tag:mennovanslooten.nl,2008-04-24:/blog/post/64</id>

			<published>2008-04-24T14:57:56+02:00</published>
			<updated>2008-04-24T14:57:56+02:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p>...and in with the new. It was time for a new design and some improvements on my blogging system. In the <a href="http://www.mennovanslooten.nl/blog/post/44">spirit of tradition</a>, that which I call an improvement is sometimes a step back for my visitors. There are some nice new features though. I'll go over them and describe some of the CSS techniques I used.</p>

<h3>New design</h3>

<p>First of all, I'm really happy with the new looks. For me, one of the most important attributes of the design is that I tried to combine <a href="http://24ways.org/2006/compose-to-a-vertical-rhythm">vertical baseline rhythm</a> with <a href="http://www.subtraction.com/archives/2004/1231_grid_computi.php">horizontal grid design</a>. Like Khoi Vinh, I used a background image on the body to guide me with the grid. Unlike Khoi, I incorporated the vertical rhythm in the image as well. You can view the grid I used on any page of this site by holding <code>SHIFT+ALT</code> and clicking anywhere in the body.</p>

<h3>Baseline rhythm &amp; horizontal grid</h3>
<p>In short, a baseline rhythm should make reading easier on the eyes by making sure all lines of text fall on a series of (invisible) evenly spaced horizontal lines. The baseline rhythm I decided on using is 18px. This is set on the body like this:</p>
<pre>
body {
    font-size:12px;
    line-height:1.5em; /* 1.5 * 12 = 18px */
}
</pre>
<p>Every other dimension (including font sizes) on every other element is from then on defined in <code>em</code> units. Keeping the rhythm in line vertically is just a matter of making sure the line height of every element plus top/bottom borders, margin and padding add up to a whole number of ems. For example, the title of this article is an <code>&lt;h2&gt;</code> element and has the following style:</p>
<pre>
h2 {
    font-size:3em; /* 3 * 12 = 36px */
    line-height:1em; /* = 36px */
    padding:.5em 0 .5em 0; /* vertical padding: 36px */
}
</pre>
<p>Obviously, no matter how many lines of text this element will have, the total height will always be a multiple of 18 thus preserving the vertical rhythm. This technique also ensures that the site layout has the same proportions for visitors with different font sizes. You can verify this yourself by pressing CTRL+PLUS or CTRL+MINUS.</p>

<h3>Don't feed the animals</h3>
<p>My Atom feeds were broken and they must've been for quite a while I think. My apologies for that. They should work fine now.
</p>

<h3>No comment</h3>
<p>This is something I had some second thoughts about but I removed all commenting possibilities from this weblog. I just didn't feel it added much to the content of the site and it sure added a whole lot of overhead to the code. Not to mention the amount of work needed to keep the site comment-spam free. <a href="http://akismet.com">Akismet</a> stopped most of it but I still had to spend too much time on removing links to porn, casino's and drugs.</p>

<h3>Drop me a line</h3>
<p>On the upside <a href="http://www.mennovanslooten.nl/blog/contact/">there is now a new contact page</a> where you can reach me. You can use the contact link in the main menu or, if you want to respond to a specific blog posting, there's a link at the bottom of every post like this one right here:.</p>			]]></content>
		</entry>
			<entry>
			<title>Turning arguments into an array...again</title>
			<link rel="alternate" type="text/html" href="http://www.mennovanslooten.nl/blog/post/63" />
			<id>tag:mennovanslooten.nl,2008-01-22:/blog/post/63</id>

			<published>2008-01-22T15:38:58+01:00</published>
			<updated>2008-01-22T15:38:58+01:00</updated>
			<author>
				<name>Menno van Slooten</name>
				<!-- email></email -->
				<uri>http://www.mennovanslooten.nl</uri>
			</author>

			<content type="html"><![CDATA[
				<p>A couple of months ago I wrote a <a href="http://www.mennovanslooten.nl/blog/post/59">little post</a> about a trick to turn the built-in, array-like JavaScript variable <code>arguments</code> into an actual array that supports methods like <code>slice</code>, <code>sort</code>, etc. Today I found out that this little trick actually doesn't work in Apple's most popular browser: <a href="http://www.apple.com/safari/">Safari</a>. Here's a small addendum to that post.</p>

<p>The original trick was this:</p>
<pre class="JavaScript" name="code">
var args = [].splice.call(arguments,0);
</pre>
<p>But unfortunately this doesn't work in Safari, the variable <code>args</code> just becomes an empty array. At first I thought the principle of <code>call</code>ing an array method on <code>arguments</code> just didn't work but when a co-worker suggested trying the <code>join()</code> method that turned out to actually work. After a bit of experimenting I finally settled on the following snippet:</p>
<pre class="JavaScript" name="code">
var args = [].slice.call(arguments,0);
</pre>
<p>Looks remarkably similar, doesn't it? The difference is just one letter: I call the <code>slice</code> method, in stead of the <code>splice</code> method. The slice method is very similar to splice in it's core functionality with one major difference: <strong>splice modifies the original array where slice doesn't</strong>. This, I believe is the problem for Safari when calling splice on <code>arguments</code>: this object is not modifiable. None of the other browsers seem to mind, though.</p>

			]]></content>
		</entry>
	</feed>