<?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>Garrick Cheung</title>
	<atom:link href="http://www.garrickcheung.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.garrickcheung.com</link>
	<description>Sharing what I know and learn about CSS, MooTools, Javascript, PHP and etc.</description>
	<lastBuildDate>Fri, 01 Mar 2013 20:54:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>JavaScript Jabber Interview: MooTools with Valerio Proietti and Arian Stolwijk</title>
		<link>http://www.garrickcheung.com/javascript/javascript-jabber-interview-mootools-with-valerio-proietti-and-arian-stolwijk/</link>
		<comments>http://www.garrickcheung.com/javascript/javascript-jabber-interview-mootools-with-valerio-proietti-and-arian-stolwijk/#comments</comments>
		<pubDate>Fri, 01 Mar 2013 20:52:44 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=471</guid>
		<description><![CDATA[Valerio (MooTools Founder) and Arian (MooTools Core Dev.) were interviewed for the JavaScript Jabber Show! Definitely a must listen. They covered topics such as what is MooTools, the future, MooTools vs. jQuery, using MooTools and jQuery together, MooTools for frameworks and a bunch of other stuff. Thanks for mentioning Neuro MVC, you guys! More on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://github.com/kamicane" title="Valerio" target="_blank">Valerio (MooTools Founder)</a> and <a href="https://github.com/arian" target="_blank">Arian (MooTools Core Dev.)</a> were interviewed for the <a href="http://javascriptjabber.com/049-jsj-mootools-with-valerio-proietti-and-arian-stolwijk/" target="_blank">JavaScript Jabber Show</a>! Definitely a must listen.<span id="more-471"></span></p>
<p>They covered topics such as what is MooTools, the future, MooTools vs. jQuery, using MooTools and jQuery together, MooTools for frameworks and a bunch of other stuff.</p>
<p>Thanks for mentioning <a href="https://github.com/gcheung55/neuro" target="_blank">Neuro MVC</a>, you guys! More on Neuro MVC later&#8230; but just a teaser: It&#8217;s an MVC I built with MooTools.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/javascript-jabber-interview-mootools-with-valerio-proietti-and-arian-stolwijk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MooTools Elements Garbage Collection Gotchas</title>
		<link>http://www.garrickcheung.com/javascript/mootools-elements-garbage-collection-gotchas/</link>
		<comments>http://www.garrickcheung.com/javascript/mootools-elements-garbage-collection-gotchas/#comments</comments>
		<pubDate>Thu, 24 Jan 2013 02:37:18 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=465</guid>
		<description><![CDATA[MooTools handles a lot of the garbage collection with elements. While Element.destroy handles some garbage collection, it&#8217;s not obvious where else garbage collection occurs. Let&#8217;s clear some of this up. Garbage Collection? Yes, garbage collection. Elements can take up a lot of memory. Add events and items stored with Element Storage to the mix and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mootools.net" title="MooTools" target="_blank">MooTools</a> handles a lot of the garbage collection with elements. While Element.destroy handles some garbage collection, it&#8217;s not obvious where else garbage collection occurs. Let&#8217;s clear some of this up.<span id="more-465"></span></p>
<h3>Garbage Collection?</h3>
<p>Yes, garbage collection. Elements can take up a lot of memory. Add events and items stored with Element Storage to the mix and there are more things to worry about than just the elements themselves. To help with memory issues, MooTools helps with the garbage by removing events and items stored using Element Storage methods (Element.store and Element.retrieve). But it doesn&#8217;t do it with every method that involves removing elements.</p>
<p><strong>Elements.dispose</strong><br />
The dispose method does not handle garbage collection. It only removes the element node from the parent node.</p>
<p><strong>Elements.empty</strong><br />
The empty method does not handle garbage collection either. It uses the dispose method when removing the child nodes of an element.</p>
<h3>Then What Do You Do?</h3>
<p>Well, if you intend to remove a collection of elements completely, then the simple thing is to have them all destroyed. Keep in mind doing so means that if you want to add that element back (because you kept a reference of it somewhere) then it won&#8217;t have items stored in its storage or events you&#8217;ve previously attached.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//If you want to get all the elements in an element using the getElements method...</span>
someElement.<span style="color: #660066;">getElements</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'*'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// or if you want to use the getChildren method...</span>
someElement.<span style="color: #660066;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">destroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// or if you already have an array of elements...</span>
<span style="color: #009900;">&#91;</span>element1<span style="color: #339933;">,</span> element2<span style="color: #339933;">,</span> element3<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">invoke</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'destroy'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// or if you already have a collection of elements...</span>
$$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.elementsToDestroy'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">destory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/mootools-elements-garbage-collection-gotchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Use MooTools Element Methods in an iFrame Element</title>
		<link>http://www.garrickcheung.com/javascript/how-to-use-mootools-element-methods-in-an-iframe-element/</link>
		<comments>http://www.garrickcheung.com/javascript/how-to-use-mootools-element-methods-in-an-iframe-element/#comments</comments>
		<pubDate>Thu, 01 Nov 2012 00:33:58 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=436</guid>
		<description><![CDATA[Ever create an iFrame and wanted to use MooTools Elements methods in them, but you couldn&#8217;t? One solution is to add a &#60;script&#62; element whose src attribute points to a MooTools JavaScript file. Instead of doing that, you could just use the MooTools that is loaded in the parent page! The trick! var iframe = new [...]]]></description>
			<content:encoded><![CDATA[<p>Ever create an iFrame and wanted to use MooTools Elements methods in them, but you couldn&#8217;t? One solution is to add a &lt;script&gt; element whose src attribute points to a MooTools JavaScript file. Instead of doing that, you could just use the MooTools that is loaded in the parent page!<span id="more-436"></span></p>
<h3>The trick!</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> iframe <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> IFrame<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    src<span style="color: #339933;">:</span> <span style="color: #3366CC;">'javascript:&quot;&quot;'</span> <span style="color: #006600; font-style: italic;">// Workaround for HTTPs warning in IE6/7</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Need to inject so that iframe.contentWindow exists</span>
iframe.<span style="color: #660066;">inject</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> win <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">contentWindow</span><span style="color: #339933;">,</span>
    doc <span style="color: #339933;">=</span> win.<span style="color: #660066;">document</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Mootoolize window, document and body</span>
Object.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>win<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">new</span> Window<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Object.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>doc<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">new</span> Document<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Browser.<span style="color: #660066;">Element</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> winElement <span style="color: #339933;">=</span> iframe.<span style="color: #660066;">contentWindow</span>.<span style="color: #660066;">Element</span>.<span style="color: #660066;">prototype</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> method <span style="color: #000066; font-weight: bold;">in</span> Element<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// methods from Element generics</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>method.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^[A-Z]|\$|prototype/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            winElement<span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Element.<span style="color: #660066;">prototype</span><span style="color: #009900;">&#91;</span>method<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    document.<span style="color: #660066;">id</span><span style="color: #009900;">&#40;</span>doc.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Write the HTML into the document</span>
doc.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
doc.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
doc.<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Place the markup into the iframe's document body</span>
doc.<span style="color: #660066;">body</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;p id=&quot;test&quot;&gt;Test!&lt;/p&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Check that the iframe exists, and the parapgraph is retrievable with MooTools</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>iframe<span style="color: #339933;">,</span> doc.<span style="color: #660066;">getElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#test'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> win.$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'test'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Thanks to <a href="https://github.com/cheeaun" title="Lim Chee Aun">Lim Chee Aun</a> and <a href="https://github.com/cheeaun/mooeditable" title="MooEditable">MooEditable &#8211; A simple web-based WYSIWYG editor, written in MooTools</a> that he wrote. That&#8217;s where I got this snippet!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/how-to-use-mootools-element-methods-in-an-iframe-element/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dedupe an Array with MooTools</title>
		<link>http://www.garrickcheung.com/javascript/dedupe-an-array-with-mootools/</link>
		<comments>http://www.garrickcheung.com/javascript/dedupe-an-array-with-mootools/#comments</comments>
		<pubDate>Mon, 20 Aug 2012 21:00:54 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=423</guid>
		<description><![CDATA[shanebo asked on IRC today: twhat is ze cleanest way to remove duplicate items from an array I wrote a few solutions until I got what I think is a fairly quick and short snippet to remove duplicate items in an array. It&#8217;s really basic. There are probably a few cases this doesn&#8217;t cover.. such [...]]]></description>
			<content:encoded><![CDATA[<p>shanebo asked on IRC today:</p>
<blockquote><p>twhat is ze cleanest way to remove duplicate items from an array</p></blockquote>
<p>I wrote a few solutions until I got what I think is a fairly quick and short snippet to remove duplicate items in an array. It&#8217;s really basic. There are probably a few cases this doesn&#8217;t cover.. such as objects with different ordered items but containing the same contents. I also didn&#8217;t test these solutions for their performance.<span id="more-423"></span></p>
<p>Assuming the following code before each solution:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> orig <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'a'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'a'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'b'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'c'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'b'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> arr <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>1. Execute a function during each loop of the original array that checks if the new array contains the item using the Array.contains method. If it doesn&#8217;t exist, then add the item to the new array with the Array.push method.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">orig.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>arr.<span style="color: #660066;">contains</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>arr.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>2. Same as 1. but checks for the index of the item in the new array. If the item doesn&#8217;t exist in the new array, Array.indexOf method will return -1. If so, then add the item to the new array with the Array.push method.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">orig.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>arr.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>arr.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>3. Execute the MooTools Array.include method, which is bound to the new array, during each loop of the original array. The Array.include method will be executed to include the item in the original array if the new array does not already contain the item.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">orig.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>arr.<span style="color: #660066;">include</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>4. Same as 3. with the exception that the Array.include method isn&#8217;t bound to the new array prior to executing the loop. The Array.include will be bound to the second argument, in this case the new array, during the loop.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">orig.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>arr.<span style="color: #660066;">include</span><span style="color: #339933;">,</span> arr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// or</span>
orig.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span>arr.<span style="color: #660066;">include</span><span style="color: #339933;">,</span> arr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// or</span>
orig.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span>arr.<span style="color: #660066;">include</span><span style="color: #339933;">,</span> arr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/dedupe-an-array-with-mootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Undo a commit in git</title>
		<link>http://www.garrickcheung.com/general/undo-a-commit-in-git/</link>
		<comments>http://www.garrickcheung.com/general/undo-a-commit-in-git/#comments</comments>
		<pubDate>Wed, 15 Aug 2012 21:00:41 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=414</guid>
		<description><![CDATA[I&#8217;ve been using git for a while now. And I&#8217;ve happend upon a pattern: I commit, and then have to undo my commit because I either missed a file or a change that should go with the commit. So, how do you undo a commit in git..? But what is git? If you don&#8217;t know [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been using git for a while now. And I&#8217;ve happend upon a pattern: I commit, and then have to undo my commit because I either missed a file or a change that should go with the commit.</p>
<p>So, how do you undo a commit in git..?<span id="more-414"></span></p>
<h3>But what is git?</h3>
<p>If you don&#8217;t know what git is..</p>
<blockquote><p>Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.</p></blockquote>
<h3>Eureka! The solution:</h3>
<p>I searched for a solution and happened upon <a href="http://stackoverflow.com/questions/927358/git-undo-last-commit#answer-927386">a solution on Stock Overflow</a>.</p>
<blockquote><p>Undo a commit and redo<br />
<code><br />
$ git commit ...<br />
$ git reset --soft HEAD^ (1)<br />
$ edit (2)<br />
$ git add .... (3)<br />
$ git commit -c ORIG_HEAD (4)<br />
</code><br />
This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before &#8220;reset&#8221;.</p>
<p>Make corrections to working tree files.</p>
<p>Stage changes for commit.</p>
<p>&#8220;reset&#8221; copies the old head to .git/ORIG_HEAD; redo the commit by starting with its log message. If you do not need to edit the message further, you can give -C option instead.</p></blockquote>
<p>This has been super helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/general/undo-a-commit-in-git/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sorry, I&#8217;ve Been Lazy</title>
		<link>http://www.garrickcheung.com/general/sorry-ive-been-lazy/</link>
		<comments>http://www.garrickcheung.com/general/sorry-ive-been-lazy/#comments</comments>
		<pubDate>Wed, 15 Aug 2012 06:43:32 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=409</guid>
		<description><![CDATA[If you&#8217;re reading this, then I really appreciate that you&#8217;ve stuck around. I&#8217;ve been a little lazy, you see. I haven&#8217;t posted in a long while, obviously. This and that happened and then I just lacked the motivation to post. But hey, something happened and I&#8217;m back in the game. A little update: I&#8217;m now [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re reading this, then I really appreciate that you&#8217;ve stuck around. I&#8217;ve been a little lazy, you see. I haven&#8217;t posted in a long while, obviously. This and that happened and then I just lacked the motivation to post.</p>
<p>But hey, something happened and I&#8217;m back in the game. <img src='http://www.garrickcheung.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>A little update: I&#8217;m now employed at <a href="http://www.fitbit.com">Fitbit Inc.</a> I left in March 2012. What made me do it? Lots of changes were going on that triggered my curiosity about the world beyond.</p>
<p>Things that haven&#8217;t changed: I&#8217;m still passionate about <a href="http://mootools.net/">MooTools.</a></p>
<p>Anyways, I&#8217;ve got a few things to share. So I&#8217;ll start with this much. Stay tuned, if you&#8217;d like. <img src='http://www.garrickcheung.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>-Garrick-</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/general/sorry-ive-been-lazy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Date.now!</title>
		<link>http://www.garrickcheung.com/javascript/date-now/</link>
		<comments>http://www.garrickcheung.com/javascript/date-now/#comments</comments>
		<pubDate>Thu, 14 Jun 2012 03:55:26 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=403</guid>
		<description><![CDATA[Here&#8217;s a little cool snippet I picked up from MDN. It&#8217;s how to implement the Date.now method in browsers that don&#8217;t currently support it. The method returns a number value in milliseconds from 1 January 1970 00:00:00 UTC till now. 1 2 3 4 5 if &#40;!Date.now&#41; &#123; Date.now = function now&#40;&#41; &#123; return +&#40;new [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a little cool snippet I picked up from <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/now">MDN</a>. It&#8217;s how to implement the Date.now method in browsers that don&#8217;t currently support it. The method returns a number value in milliseconds from 1 January 1970 00:00:00 UTC till now.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>Date.<span style="color: #660066;">now</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  Date.<span style="color: #660066;">now</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> now<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/date-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MooTools Core Has Your (Element.NativeEvents) Back</title>
		<link>http://www.garrickcheung.com/javascript/mootools-core-element-native-events/</link>
		<comments>http://www.garrickcheung.com/javascript/mootools-core-element-native-events/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 09:45:38 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=391</guid>
		<description><![CDATA[While scanning through MooTools-Core code the other day, I came across Element.NativeEvents and forgot what the value in each property meant. I remember asking MooTools-Core devs about it probably three to four times. You may be wondering &#8220;What&#8217;s the point?&#8221; Well, let me tell you. Event Types There are three types to what the value [...]]]></description>
			<content:encoded><![CDATA[<p>While scanning through MooTools-Core code the other day, I came across Element.NativeEvents and forgot what the value in each property meant. I remember asking MooTools-Core devs about it probably three to four times. You may be wondering &#8220;What&#8217;s the point?&#8221; Well, let me tell you.<span id="more-391"></span></p>
<h3>Event Types</h3>
<p>There are three types to what the value can be in the property: 0, 1, or 2.</p>
<p><strong>Type 0</strong> doesn&#8217;t usually appear in Element.NativeEvents because custom events are type 0 by default. Adding a custom event to the Element.NativeEvents object and setting it to type 0 is the same as it not existing in the object. Custom events need to be triggered with the fireEvent method.</p>

<!-- Iframe plugin v.2.1 (wordpress.org/extend/plugins/iframe/) -->
<iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/garrickcheung/XDFq5/embedded/" allowfullscreen="allowfullscreen" frameborder="0" width="100%" height="480" scrolling="no" class="iframe-class"></iframe>
<p><em>Note: fireEvent method can also trigger native events.</em></p>
<p><strong>Type 1</strong> represents events that don&#8217;t have event information passing into the callback function. domready and load are two examples of events that don&#8217;t pass an event argument into the function attached to the event.</p>

<!-- Iframe plugin v.2.1 (wordpress.org/extend/plugins/iframe/) -->
<iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/garrickcheung/pX9F2/embedded/" allowfullscreen="allowfullscreen" frameborder="0" width="100%" height="480" scrolling="no" class="iframe-class"></iframe>
<p><strong>Type 2</strong> represents events that DO have event information passing into the callback function. It also helps normalize the event object that is passed in. click, focus, and blur are three examples.</p>

<!-- Iframe plugin v.2.1 (wordpress.org/extend/plugins/iframe/) -->
<iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/garrickcheung/YEnwa/embedded/" allowfullscreen="allowfullscreen" frameborder="0" width="100%" height="480" scrolling="no" class="iframe-class"></iframe>
<h3>It&#8217;s Important Because&#8230;</h3>
<p>MooTools or any other lib/plugin built with MooTools may not have added support for a native event that you need. With the knowledge of native event types, you can easily add them to the Element.NativeEvents object.</p>
<p>At the time of this writing, MooTools-Core 1.4.5 Element.NativeEvents objects code looks like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">Element.<span style="color: #660066;">NativeEvents</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	click<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> dblclick<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> mouseup<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> mousedown<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> contextmenu<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//mouse buttons</span>
	mousewheel<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> DOMMouseScroll<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//mouse wheel</span>
	mouseover<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> mouseout<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> mousemove<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> selectstart<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> selectend<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//mouse movement</span>
	keydown<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> keypress<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> keyup<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//keyboard</span>
	orientationchange<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// mobile</span>
	touchstart<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> touchmove<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> touchend<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> touchcancel<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// touch</span>
	gesturestart<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> gesturechange<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> gestureend<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// gesture</span>
	<span style="color: #000066;">focus</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #000066;">blur</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> change<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> reset<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> select<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> submit<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> paste<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> input<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//form elements</span>
	load<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> unload<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> beforeunload<span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> resize<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> move<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> DOMContentLoaded<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> readystatechange<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//window</span>
	error<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> abort<span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #000066;">scroll</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span> <span style="color: #006600; font-style: italic;">//misc</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>They show the native events that are available, but by no means is it a comprehensive of every single event out there.</p>
<p>With this list, you can basically add any native event listed to an element.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Create an image element.</span>
<span style="color: #003366; font-weight: bold;">var</span> element <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Element<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Attach the load event. It's a Type 1 so data isn't passed into the function</span>
element.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Once the image has loaded, inject it into the document body.</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">inject</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Change the element's source so it will start loading an image.</span>
<span style="color: #006600; font-style: italic;">// Setting the src of an image will automatically make it begin downloading.</span>
<span style="color: #006600; font-style: italic;">// Once that's complete, it will trigger the load event that's attached to the element.</span>
element.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'src'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'http://somePath.com/img/abcd.jpg'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>More information about <a href="http://mootools.net/docs/core/Element/Element.Event#Element-NativeEvents" target="_blank">Element.NativeEvents has been added to the MooTools documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/mootools-core-element-native-events/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MooTools Core 1.3.2 and More 1.3.2.1</title>
		<link>http://www.garrickcheung.com/javascript/mootools-core-1-3-2-and-more-1-3-2-1/</link>
		<comments>http://www.garrickcheung.com/javascript/mootools-core-1-3-2-and-more-1-3-2-1/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 17:24:06 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=381</guid>
		<description><![CDATA[MooTools just released an update to their Core and More libs. They are mostly fixes but More also comes with a brand new and shiny new Utility class called Tables! Changes (and I quote!) to Core Fixed Slick bug with ~div-like selectors Fixed MooTools in the Node.js environment Fixed an exception in DOMReady in Chrome [...]]]></description>
			<content:encoded><![CDATA[<p>MooTools just released an <a href="http://mootools.net/blog/2011/04/28/mootools-core-1-3-2-and-more-1-3-2-1/">update to their Core and More libs</a>. They are mostly fixes but More also comes with a brand new and shiny new <a href="http://mootools.net/docs/more/Utilities/Table">Utility class called Tables</a>!</p>
<p><strong>Changes (and I quote!) to Core</strong></p>
<ul>
<li>Fixed Slick bug with ~div-like selectors</li>
<li>Fixed MooTools in the Node.js environment</li>
<li>Fixed an exception in DOMReady in Chrome when the page with MooTools was in an IFrame</li>
<li>Fixed setOpacity for very small numbers in IE</li>
<li>Fixed an exception in FireFox 4 when MooTools tried to overwrite document.head</li>
<li>Added the possibility to create elements with boolean values with an selector, e.g. new Element(&#8216;input[checked]&#8216;);</li>
</ul>
<p><strong>Changes to More (that I also quote):</strong></p>
<ul>
<li>Rewritten Element.Position which solved some issues</li>
<li>Added Table, as described above</li>
<li>Ironed out some Event Delegation issues</li>
<li>Additional fixes can be found at the <a href="https://mootools.lighthouseapp.com/projects/24057/milestones/104271-1322" rel="nofollow">Lighthouse for 1.3.2.1</a></li>
</ul>
<p>Yay, MooTools developers! You guys are seriously stepping up with a quicker release. In the words of my friend <a href="http://davidwalsh.name/">David Walsh</a>: MooTools FTW!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/mootools-core-1-3-2-and-more-1-3-2-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MooTools Core 1.3.1 and More 1.3.1.1</title>
		<link>http://www.garrickcheung.com/mootools/mootools-core-1-3-1-and-more-1-3-1-1/</link>
		<comments>http://www.garrickcheung.com/mootools/mootools-core-1-3-1-and-more-1-3-1-1/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 07:03:25 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=373</guid>
		<description><![CDATA[A post long overdue.. but that&#8217;s besides the point. The MooTools Dev team released MooTools Core 1.3.1 and More 1.3.1.1! Changes (and I quote!) Lots (and by that I mean LOTS) of documentation improvements, clarifications and cleanups Updated Slick to 1.1.5 and improved the speed of our Slick selector engine Added delegation support for submit, [...]]]></description>
			<content:encoded><![CDATA[<p>A post long overdue.. but that&#8217;s besides the point. The MooTools Dev team <a href="http://mootools.net/blog/2011/02/25/mootools-core-more-1-3-1/">released MooTools Core 1.3.1 and More 1.3.1.1</a>!</p>
<p><strong>Changes (and I quote!)</strong></p>
<ul>
<li>Lots (and by that I mean LOTS) of documentation improvements, clarifications and cleanups</li>
<li>Updated Slick to 1.1.5 and improved the speed of our Slick selector engine</li>
<li>Added delegation support for submit, focus, blur, reset, change and select events in MooTools More</li>
<li>If available the native JSON methods are now used in JSON.decode and JSON.encode</li>
<li>Multiple Pseudos click:relay(a):once (demo)</li>
<li>Two new pseudo events: :throttle and :pause</li>
<li>Added String.truncate to String.Extras in More</li>
<li>More than two hundred changes to increase the stability of both Core &#038; More</li>
</ul>
<p>MooTools Dev, you&#8217;ve been quite awesome. Keep up the great work!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/mootools/mootools-core-1-3-1-and-more-1-3-1-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
