<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Enrique Delgado Monroy</title>
    <link>http://www.enriquedelgado.com</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Work, Life, Stuff</description>
    <item>
      <title>Attaching functions to events in JavaScript: The unobstrusive way! - Part 2</title>
      <description>&lt;p&gt;&lt;a href="http://www.enriquedelgado.com/articles/2007/05/03/attaching-functions-to-events-in-javascript-the-unobstrusive-way"&gt;Previously&lt;/a&gt;, I talked about a good way to attach event listeners to &lt;span class="caps"&gt;DOM&lt;/span&gt; elements. I like the approach described in that post because is pure JavaScript and not dependent on a framework, but if you happen to be using a framework already, or are thinking on using some, here are two methods of achieving this task:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://prototypejs.org/api/event"&gt;Prototype.js&lt;/a&gt;: &lt;tt&gt;observe&lt;/tt&gt; method.&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;: &lt;tt&gt;bind&lt;/tt&gt; method and friends.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;It is important to remember that, your code should wait for the &lt;span class="caps"&gt;DOM&lt;/span&gt; tree to completely load before attempting to attach events to elements. The typical scenario is that some JavaScript code is attempting to attach an event to an element that does not exist yet, because the document is still loading.&lt;/p&gt;


	&lt;p&gt;Each framework has ways of wrapping your code, so that it runs only when the &lt;span class="caps"&gt;DOM&lt;/span&gt; is ready:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;Prototype&lt;/strong&gt;&lt;br/&gt;&lt;pre style="overflow: auto; background: #EEE;"&gt;
document.observe("dom:loaded", function() {
  // Your code here
});
&lt;/pre&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;strong&gt;jQuery&lt;/strong&gt;&lt;br/&gt;&lt;pre style="overflow: auto; background: #EEE;"&gt;
$(document).ready(function(){
   // Your code here
 });

&lt;/pre&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h3&gt;Using Prototype&lt;/h3&gt;


	&lt;p&gt;Prototype offers several event handling methods, but the most common is &lt;code&gt;observe&lt;/code&gt; and &lt;code&gt;stopObserving&lt;/code&gt;.&lt;/p&gt;


	&lt;p&gt;Example:&lt;/p&gt;


&lt;pre style="overflow: auto; background: #EEE;"&gt;
$('foo').observe('click', respondToClick);

function respondToClick(event) {
  // This is how you access the element that triggered the event:
  var element = event.element();
  // Your code here, e.g.:
  alert('Hello');
}
&lt;/pre&gt;

	&lt;p&gt;Notice the name of the event, in this case is &lt;tt&gt;click&lt;/tt&gt;. The complete list of events are defined in the &lt;a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings"&gt;&lt;span class="caps"&gt;W3C&lt;/span&gt; recommendations&lt;/a&gt;, but here is a summary of the most common event names organized by type:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Mouse Events
	&lt;ul&gt;
	&lt;li&gt;&lt;tt&gt;click&lt;/tt&gt; &amp;#8211; Occurs when the pointing device button is clicked over an element.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;mousedown&lt;/tt&gt; &amp;#8211; Occurs when the pointing device button is pressed over an element.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;mouseup&lt;/tt&gt; &amp;#8211; Occurs when the pointing device button is released over an element.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;mouseover&lt;/tt&gt; &amp;#8211; Occurs when the pointing device is moved onto an element.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;mousemove&lt;/tt&gt; &amp;#8211; Occurs when the pointing device is moved while it is over an element.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;mouseout&lt;/tt&gt; &amp;#8211; Occurs when the pointing device is moved away from an element.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;Key Events
	&lt;ul&gt;
	&lt;li&gt;&lt;span class="caps"&gt;W3C&lt;/span&gt; does not have them, but the following are supplied by Prototype:&lt;br /&gt;&lt;tt&gt;&lt;span class="caps"&gt;KEY&lt;/span&gt;_BACKSPACE, &lt;span class="caps"&gt;KEY&lt;/span&gt;_TAB, &lt;span class="caps"&gt;KEY&lt;/span&gt;_RETURN, &lt;span class="caps"&gt;KEY&lt;/span&gt;_ESC, &lt;span class="caps"&gt;KEY&lt;/span&gt;_LEFT, &lt;span class="caps"&gt;KEY&lt;/span&gt;_UP, &lt;span class="caps"&gt;KEY&lt;/span&gt;_RIGHT, &lt;span class="caps"&gt;KEY&lt;/span&gt;_DOWN, &lt;span class="caps"&gt;KEY&lt;/span&gt;_DELETE, &lt;span class="caps"&gt;KEY&lt;/span&gt;_HOME, &lt;span class="caps"&gt;KEY&lt;/span&gt;_END, &lt;span class="caps"&gt;KEY&lt;/span&gt;_PAGEUP, &lt;span class="caps"&gt;KEY&lt;/span&gt;_PAGEDOWN&lt;/tt&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
		&lt;li&gt;&lt;span class="caps"&gt;HTML&lt;/span&gt; Events
	&lt;ul&gt;
	&lt;li&gt;&lt;tt&gt;load&lt;/tt&gt; &amp;#8211; Occurs when the &lt;span class="caps"&gt;DOM&lt;/span&gt; implementation finishes loading.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;unload&lt;/tt&gt; &amp;#8211; Occurs when the &lt;span class="caps"&gt;DOM&lt;/span&gt; implementation removes a document from a window or frame.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;select&lt;/tt&gt; &amp;#8211; Occurs when a user selects some text in a text field.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;change&lt;/tt&gt; &amp;#8211; Occurs when a control loses the input focus and its value has been modified since gaining focus.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;submit&lt;/tt&gt; &amp;#8211; Occurs when a form is submitted.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;focus&lt;/tt&gt; &amp;#8211; Occurs when an element receives focus either via a pointing device or by tabbing navigation.&lt;/li&gt;
		&lt;li&gt;&lt;tt&gt;blur&lt;/tt&gt; &amp;#8211; Occurs when an element loses focus either via the pointing device or by tabbing navigation.&lt;/li&gt;
	&lt;/ul&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h3&gt;Using jQuery&lt;/h3&gt;


	&lt;p&gt;jQuery mostly has &amp;#8220;helper methods&amp;#8221; to set event listeners that are named after the event name, but the two most basic methods are &lt;tt&gt;bind&lt;/tt&gt; and &lt;tt&gt;unbind&lt;/tt&gt;.&lt;/p&gt;


	&lt;p&gt;Example:&lt;/p&gt;


&lt;pre style="overflow: auto; background: #EEE;"&gt;
$("#foo").bind("click", function(e){
  // This is how you access the element that triggered the event:
  var element = event.target;
  // Your code here, e.g.:
  alert('Hello');
});
&lt;/pre&gt;

Again, notice the name of the event, in this case is &lt;tt&gt;click&lt;/tt&gt;. According to the jQuery documentation, these are the allowed event names:
	&lt;ul&gt;
	&lt;li&gt;&lt;tt&gt;blur, focus, load, resize, scroll, unload, click, dblclick,  mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select,  submit, keydown, keypress, keyup, error&lt;/tt&gt;.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Most helper elements are named after the event names above, so you have things like &lt;tt&gt;click()&lt;/tt&gt;, &lt;tt&gt;focus()&lt;/tt&gt;, &lt;tt&gt;submit()&lt;/tt&gt;, etc.&lt;/p&gt;


	&lt;p&gt;Example using an anonymous function as the functioned to be executed when the event is triggered:&lt;/p&gt;


&lt;pre style="overflow: auto; background: #EEE;"&gt;
$("#foo").click(function () { 
  // The element is access by using "$(this)" 
  // Your code here, e.g.:
  alert('Hello');
});
&lt;/pre&gt;

	&lt;h3&gt;Event Delegation&lt;/h3&gt;


	&lt;p&gt;One often source of confusion is how to attach event listeners to dynamically-generated &lt;span class="caps"&gt;DOM&lt;/span&gt; elements (for example, adding &lt;tt&gt;&amp;lt;li&amp;gt;&lt;/tt&gt; elements to a list via &lt;span class="caps"&gt;AJAX&lt;/span&gt;).&lt;/p&gt;


	&lt;p&gt;When an element is crated, it is not already bound to an event listener, so you will have to perform a two-step process: create the element in the &lt;span class="caps"&gt;DOM&lt;/span&gt;, and then attach the event listener. This can get tedious easily, so instead of attaching the event listener to the &lt;span class="caps"&gt;DOM&lt;/span&gt; element desired, you attach an event listener to a parent element in the &lt;span class="caps"&gt;DOM&lt;/span&gt; tree.&lt;/p&gt;


	&lt;p&gt;In turn, this parent element acts as a &amp;#8220;catch all&amp;#8221; event listener. It will figure out which element triggered the event in the first place and act accordingly. This technique is referred to as &lt;a href="http://icant.co.uk/sandbox/eventdelegation/"&gt;event delegation&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Event delegation works because some events &amp;#8220;bubble up&amp;#8221; from child nodes to parent nodes in the &lt;span class="caps"&gt;DOM&lt;/span&gt; tree; see &lt;a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow-bubbling"&gt;event bubbling&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Hope thins helps someone out there getting started. Post your questions if you run into trouble. :)&lt;/p&gt;</description>
      <pubDate>Fri, 24 Oct 2008 08:00:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:3690a8d5-8f49-4316-95b8-250cc37c4f3f</guid>
      <author>Enrique Delgado</author>
      <link>http://www.enriquedelgado.com/articles/2008/10/24/attaching-functions-to-events-in-javascript-the-unobstrusive-way-part-2</link>
      <category>Web Development</category>
      <category>javascript</category>
      <category>html</category>
      <category>DOM</category>
      <category>prototype</category>
      <category>jquery</category>
    </item>
    <item>
      <title>Slider Controls with Prototype and Scriptaculous</title>
      <description>&lt;div style="float:right;"&gt;&lt;a href="/files/Slider.zip"&gt;&lt;img src="/files/slider.gif" alt="" /&gt;&lt;/a&gt;&lt;/div&gt;Even though web-based applications have the majority of input elements found in traditional desktop-based ones, once in a while you are going to wish you had input elements that for some reason did not make it to the &lt;span class="caps"&gt;HTML&lt;/span&gt; standards.

	&lt;p&gt;One of the input elements I wish were supported by default are draggable slider controls. There is something cool about having a slider to quickly change a setting of a search or a calculation, instead of having to type values on a text box or clicking on drop-down boxes.&lt;/p&gt;


	&lt;p&gt;Out of the myriad of options I found during a quick Google search, I found these two options to be the most attractive:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/examples/slider/slider-ticks.html"&gt;Yahoo UI Slider Control&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://wiki.script.aculo.us/scriptaculous/show/SliderDemo"&gt;Scriptaculous Slider Control&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Since I was already using Scriptaculous on the application in question, I decided to stick to that solution. Yahoo&amp;#8217;s version is definitely worth a look though. At first glance, Yahoo&amp;#8217;s example looks better than the Scriptaculous one, but as you will see we can get the best of both worlds.&lt;/p&gt;


	&lt;p&gt;One word of warning; even though sliders are a useful control, you should exercise discretion as to not over use them. The truth of the matter is that not everyone is familiar using sliders on the web, and it can quickly become a usability problem if not careful. Good uses for sliders are things like mortgage calculators, search result filter controls, and things of that sort. Do not replace menus or tabs with a slider ;)&lt;/p&gt;


	&lt;p&gt;Onto the interesting part. In order to use Scriptculous&amp;#8217; sliders, you will need to make sure you are including the library with the slider component. By default, everything is included when you include scriptaculous in the traditional way:&lt;/p&gt;


&lt;pre style="overflow: auto; background: #EEE;"&gt;
&amp;lt;script src="prototype.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="scriptaculous.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;This will load about six components, but it is a good practice to load only those components that you are actually using. In my case, I&amp;#8217;ll be using effects and slider so I&amp;#8217;m calling Scriptaculous in this fashion:&lt;/p&gt;


&lt;pre style="overflow: auto; background: #EEE;"&gt;
 &amp;lt;script src="prototype.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
 &amp;lt;script src="scriptaculous.js?load=effects,slider" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;

A Scriptaculous slider consist of two things:
	&lt;ul&gt;
	&lt;li&gt;A &amp;#8220;parent&amp;#8221; element (typically a &lt;tt&gt;&lt;span class="caps"&gt;DIV&lt;/span&gt;&lt;/tt&gt;) deemed to be the &amp;#8220;track&amp;#8221; on which a knob will slide.&lt;/li&gt;
		&lt;li&gt;A &amp;#8220;child&amp;#8221; nested element (typically a &lt;tt&gt;&lt;span class="caps"&gt;DIV&lt;/span&gt;&lt;/tt&gt;) that will act as the element to be slided across the length (or height) of the track.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;You can create a slider track and controls purely based on &lt;span class="caps"&gt;CSS&lt;/span&gt; code like in the Scriptaculous sample, but I chose to use images within &lt;tt&gt;&lt;span class="caps"&gt;DIV&lt;/span&gt;&lt;/tt&gt; elements to obtain the look of the Yahoo UI slider control. A possible &lt;span class="caps"&gt;HTML&lt;/span&gt; mark-up would be:&lt;/p&gt;


&lt;pre style="overflow: auto; background: #EEE;"&gt;
 &amp;lt;div id="track1" style="background-image:url(bg-fader.gif); background-repeat:no-repeat; width:209px; height:28px;"&amp;gt;
  &amp;lt;div id="handle1" style="background-image:url(thumb-n.gif); background-repeat:no-repeat; width:17px; height:21px; cursor:move;"&amp;gt; &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;In the example above, we have a parent &lt;tt&gt;&lt;span class="caps"&gt;DIV&lt;/span&gt;&lt;/tt&gt; element (the track) with an ID of &lt;tt&gt;track1&lt;/tt&gt; and a child (the handle) element with an ID of &lt;tt&gt;handle1&lt;/tt&gt;. In this case the width and height of the &lt;tt&gt;&lt;span class="caps"&gt;DIV&lt;/span&gt;&lt;/tt&gt; elements match the track and handle image dimensions.&lt;/p&gt;


	&lt;p&gt;Here is where the magic comes. Lets make a &lt;tt&gt;Slider&lt;/tt&gt; object to give life to our &lt;span class="caps"&gt;HTML&lt;/span&gt; slider:&lt;/p&gt;


&lt;pre style="overflow: auto; background: #EEE;"&gt;
 &amp;lt;script type="text/javascript" language="javascript"&amp;gt;
  // &amp;lt;![CDATA[
  window.onload = function() {
    new Control.Slider('handle1',
                       'track1',                                  
                       {axis:'horizontal',
                        range: $R(1,5)
                       });
  }
  // ]]&amp;gt;
 &amp;lt;/script&amp;gt;
&lt;/pre&gt;

	&lt;p&gt;In the example above, we are creating a horizontal slider with a handle element ID of &lt;tt&gt;handle1&lt;/tt&gt; and a track element ID of &lt;tt&gt;track1&lt;/tt&gt;. The slider possible values range from 1 to 5.&lt;/p&gt;


	&lt;p&gt;You may have noticed that the code is within the document&amp;#8217;s &lt;tt&gt;onLoad&lt;/tt&gt; event. This is because the slider object needs to be created after the track and slider elements have completely loaded. Alternatively, you could place the JavaScript code somewhere after the &lt;span class="caps"&gt;HTML&lt;/span&gt; elements in your document, but it is typically not a good idea to place JavaScript anywhere other than in its own &lt;tt&gt;.js&lt;/tt&gt; file and then calling that file on your document. See my other post about &lt;a href="http://enriquedelgado.com/articles/2007/05/03/attaching-functions-to-events-in-javascript-the-unobstrusive-way"&gt;unobstrusive JavaScript&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;There are several options you can play with to create many variations of Scriptaculous sliders. For a good reference, check out the &lt;a href="http://wiki.script.aculo.us/scriptaculous/show/Slider"&gt;slider documentation page&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Download a complete working demo &lt;a href="/files/Slider.zip"&gt;here&lt;/a&gt;. Just unzip the file and open the &lt;tt&gt;index.html&lt;/tt&gt; file with your browser. You should see some sliders with different attributes and further examples as to how to get useful data from the sliders :)&lt;/p&gt;</description>
      <pubDate>Tue, 11 Dec 2007 07:00:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:3ee3ab69-fd9b-4abc-8dfe-1698f9b3a7b1</guid>
      <author>Enrique Delgado</author>
      <link>http://www.enriquedelgado.com/articles/2007/12/11/html-slider-controls-with-prototype-and-scriptaculous</link>
      <category>Web Development</category>
      <category>html</category>
      <category>slider</category>
      <category>scriptaculous</category>
      <category>prototype</category>
      <category>DOM</category>
      <category>css</category>
      <enclosure type="application/zip" url="http://www.enriquedelgado.com/files/Slider.zip" length="284287"/>
    </item>
    <item>
      <title>Enhance your JavaScript-fu with LowPro</title>
      <description>&lt;p&gt;During RailsConf 2007 I had the pleasure to have a beer with &lt;a href="http://danwebb.net"&gt;Dan Webb&lt;/a&gt; at the &lt;a href="http://www.railsmachine.com/"&gt;Rails Machine&lt;/a&gt; hangout. It was cool to talk all about JavaScript (one of my interests) as it relates to Rails.&lt;/p&gt;


	&lt;p&gt;It was interesting to find out that Rails is not quite adopting the &amp;#8220;unobtrusive way&amp;#8221; completely. Just look at how the &lt;code&gt;link_to_remote&lt;/code&gt; JavaScript code is generated; it mixes content with JS code.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m hoping that as Rails gets betetr and better, it will also support better graceful degradation for JavaScript. For now, Dan&amp;#8217;s awesome library a.k.a &lt;a href="http://www.danwebb.net/2006/9/3/low-pro-unobtrusive-scripting-for-prototype"&gt;Low Pro&lt;/a&gt;  should help us all become true JavaScript-fu disciples.&lt;/p&gt;


	&lt;p&gt;Talk about navigating through the &lt;span class="caps"&gt;DOM&lt;/span&gt; with ninja-like swiftness! :)&lt;/p&gt;</description>
      <pubDate>Thu, 31 May 2007 09:34:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:660b9d9f-ae2a-4848-9d9c-f7a457a3e9ef</guid>
      <author>Enrique Delgado</author>
      <link>http://www.enriquedelgado.com/articles/2007/05/31/enhance-your-javascript-fu-with-lowpro</link>
      <category>Web Development</category>
      <category>javascript</category>
      <category>rails</category>
    </item>
    <item>
      <title>RailsConf 2007 Keynote: A peek at Rails 2.0</title>
      <description>&lt;p&gt;RailsConf 2007 is well underway now. After a day of tutorials, we were welcomed by Chad Fowler, writer and fellow Pragmtic Studio Alumni. Chad had some cool things to say to the community, namely that we have an opportunity to have a good impact and he encouraged us and everyone to raise money for charity as a Rails community. Go to &lt;a href="http://pragmaticstudio.com/donate"&gt;http://pragmaticstudio.com/donate&lt;/a&gt; to make your donation.&lt;/p&gt;


	&lt;p&gt;David Heinemeier Hansson kicked-off the conference with his keynote speech &amp;#8220;A peek at Rails 2.0&amp;#8221;. David spoke about some of the upcoming features in 2.0, but specifically said that 2.0 is not going to be a &amp;#8220;magic unicorn&amp;#8221;. I.e. not a re-write, but more like a progression of sorts; real and humble. I&amp;#8217;m sure the screencast will g up soon at the &lt;a href="http://www.rubyonrails.com"&gt;rails site&lt;/a&gt; site.&lt;/p&gt;


	&lt;h3&gt;Some of the features are:&lt;/h3&gt;


	&lt;ol&gt;
	&lt;li&gt;namespaces in routes.&lt;/li&gt;
		&lt;li&gt;Default scaffold, will have a complete xml backend. &lt;/li&gt;
		&lt;li&gt;scaffold_resource will be just scaffold and it will be RESTful &lt;/li&gt;
		&lt;li&gt;Easy to connect to a &lt;span class="caps"&gt;REST&lt;/span&gt; interface, even with an isolated simple ruby file. &amp;#8220;This stuff works now&amp;#8221;. Active Web Service no longer bundled with 2.0, just Active Resource. &amp;#8220;The answer is not &lt;span class="caps"&gt;SOAP&lt;/span&gt;, it&amp;#8217;s active resource&amp;#8221; &lt;/li&gt;
		&lt;li&gt;Breakpoints are back. Rails-debugger.&lt;/li&gt;
		&lt;li&gt;Debugger&lt;/li&gt;
		&lt;li&gt;&lt;span class="caps"&gt;HTTP&lt;/span&gt; performance though JS and &lt;span class="caps"&gt;CSS&lt;/span&gt; cache to make the browser make fewer connections also, asset hosts. Query cache. &lt;/li&gt;
		&lt;li&gt;Sexy migrations &lt;/li&gt;
		&lt;li&gt;The &lt;span class="caps"&gt;MIT&lt;/span&gt; license assumption. &lt;/li&gt;
		&lt;li&gt;Spring cleaning (all those deprecation warnings will become a reality)&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;More soon!&lt;/p&gt;</description>
      <pubDate>Fri, 18 May 2007 17:03:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:0582a014-5155-4421-9021-f5cfa94a80a3</guid>
      <author>Enrique Delgado</author>
      <link>http://www.enriquedelgado.com/articles/2007/05/18/railsconf-2007-keynote-a-peek-at-rails-2-0</link>
      <category>Rails</category>
      <category>RailsConf2007</category>
    </item>
    <item>
      <title>Gearing up for RailsConf 2007 in Portland!</title>
      <description>&lt;p&gt;With only three days to go, I&amp;#8217;ve been busy getting everything in place for my trip to Portland.&lt;/p&gt;


	&lt;p&gt;I spent some time reading through all the descriptions and presenter bios for each of the sessions in the conference. I&amp;#8217;m excited to hear from some big names like &lt;a href="http://danwebb.net"&gt;Dan Webb&lt;/a&gt;, &lt;a href="http://topfunky.com"&gt;Geoffrey Grosenbach&lt;/a&gt;, &lt;a href="http://slash7.com"&gt;Amy Hoy&lt;/a&gt; amongst others.&lt;/p&gt;


	&lt;p&gt;A buddy of mine pointed me to this &lt;a href="http://myconfplan.com/conferences/RailsConf2007"&gt;conference-planning site&lt;/a&gt;. It&amp;#8217;s pretty cool; &lt;a href="http://myconfplan.com/conferences/RailsConf2007/users/enriquedelgado"&gt;this is my preliminary plan&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Keep an eye on my &lt;a href="http://www.flickr.com/photos/38934033@N00/"&gt;Flickr photostream&lt;/a&gt; for pictures of the conference :)&lt;/p&gt;</description>
      <pubDate>Sun, 13 May 2007 12:30:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:41db40f1-b66a-4514-b139-7f7fd5bc327d</guid>
      <author>Enrique Delgado</author>
      <link>http://www.enriquedelgado.com/articles/2007/05/13/gearing-up-for-railsconf-2007-in-portland</link>
      <category>Rails</category>
      <category>Ruby</category>
      <category>Travel</category>
      <category>RailsConf2007</category>
    </item>
    <item>
      <title>Attaching functions to events in JavaScript: The unobstrusive way!</title>
      <description>&lt;p&gt;I needed to set a simple focus when a page loads in a legacy site I was working on so I decided to exercise a &amp;#8220;better way&amp;#8221; to attach functions to events in JavaScript.&lt;/p&gt;


In the past, I used to attach &lt;code&gt;onLoad&lt;/code&gt; events through an anonymous function like so:
&lt;pre style="overflow: auto; background: #EEE;"&gt;
window.onload = function() {
  init();
}

function init() {
  //do something interesting
}
&lt;/pre&gt;
This method has its drawbacks tho; it assumes that this script is the only script that may act upon a document. We &amp;#8220;assume instead that it is part of a whole group of scripts all of which fulfilling different tasks.&amp;#8221; As described in this awesome &lt;a href="http://icant.co.uk/articles/from-dhtml-to-dom/from-dhtml-to-dom-scripting.html#domasset3"&gt;webzine&lt;/a&gt; by &lt;a href="http://icant.co.uk/articles/from-dhtml-to-dom/"&gt;Chris Heilmann&lt;/a&gt; .

Instead, Chris points out a better solution; something unobstrusive (because you don&amp;#8217;t have to mix JavaScript with &lt;span class="caps"&gt;HTML&lt;/span&gt;) and that plays well with others (because more than one script can act upon a document):
&lt;pre style="overflow: auto; background: #EEE;"&gt;
  // Attach the function init() to the window.onload event:
  addEvent(window,'load',init,false);

  // Initialization; I'm setting the focus on the first field:
  function init() {
    //do something interesting
  }

  // Function to attach events to objects.
  // (http://icant.co.uk/articles/from-dhtml-to-dom/from-dhtml-to-dom-scripting.html#domasset3)
  function addEvent(elm, evType, fn, useCapture){
    if (elm.addEventListener)
    {
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent) {
      var r = elm.attachEvent('on' + evType, fn);
      return r;
    } else {
      elm['on' + evType] = fn;
    }
  }
&lt;/pre&gt;

	&lt;p&gt;The key here is the way &lt;code&gt;addEvent&lt;/code&gt; adds event listeners to the document.&lt;/p&gt;</description>
      <pubDate>Thu, 03 May 2007 10:33:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:643e3e53-254e-4719-83d6-e3d3f97b236d</guid>
      <author>Enrique Delgado</author>
      <link>http://www.enriquedelgado.com/articles/2007/05/03/attaching-functions-to-events-in-javascript-the-unobstrusive-way</link>
      <category>Web Development</category>
      <category>javascript</category>
      <category>html</category>
    </item>
    <item>
      <title>SliceHost + Deprec Plug-in</title>
      <description>&lt;p&gt;I&amp;#8217;ve recently purchased a slice at &lt;a href="http://www.slicehost.com"&gt;SliceHost&lt;/a&gt; and started to use the Deprec plug-in for Rails for my apps.&lt;/p&gt;


	&lt;p&gt;Thanks to the awesome Top Funky free &lt;a href="http://peepcode.com/"&gt;peepcode screencast&lt;/a&gt; I was able to start deploying applications (including the entire Rails stack) quickly and in a predictable manner.&lt;/p&gt;


	&lt;p&gt;Check out the &lt;a href="http://topfunky.com/clients/peepcode/free-episodes/peepcode-free-deprec.mov"&gt;screencast&lt;/a&gt;  for details, but this is my basic recipe to setup a new application. These steps will create a sample rails application, setup apache, mongrel, and deploy (with migrations!):&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;&lt;code&gt;rails mykillerapp&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;deprec --apply-to .&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;Edit your &lt;code&gt;config/deploy.rb&lt;/code&gt; file.&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;cap deprec_setup&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;cap setup_scm&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;cap deploy_with migrations&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;&lt;code&gt;cap restart_apache&lt;/code&gt;&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;And you are done! Subsequent releases are even easier:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;&lt;code&gt;cap deploy_with_migrations&lt;/code&gt;&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;Pretty good eh?&lt;/p&gt;</description>
      <pubDate>Tue, 01 May 2007 10:00:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:545c47d9-cfb4-4791-99f6-bffa7dbd6293</guid>
      <author>Enrique Delgado</author>
      <link>http://www.enriquedelgado.com/articles/2007/05/01/slicehost-deprec-plug-in</link>
      <category>Rails</category>
      <category>rails</category>
      <category>plugins</category>
      <category>capistrano</category>
      <category>deployment</category>
      <category>deprec</category>
    </item>
    <item>
      <title>Interactive Ruby Console Tip: Remember the last X commands</title>
      <description>&lt;p&gt;This is an excellent tip by &lt;a href="http://www.clarkware.com"&gt;Mike Clark&lt;/a&gt; to make &lt;span class="caps"&gt;IRB&lt;/span&gt; remember the last X number of commands even after you exit and restart &lt;span class="caps"&gt;IRB&lt;/span&gt;.&lt;/p&gt;


	&lt;p&gt;This is great when developing and after modifying a model, you don&amp;#8217;t have to re-type everyting once again :)&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&amp;#8220;Simply add the code below to your ~/.irbrc file. Then you can use up-arrow to cycle through the history, even
after restarting &lt;span class="caps"&gt;IRB&lt;/span&gt;. It relies on the built-in history of readline, so you&amp;#8217;ll need readline installed. The code below also enables completion using the &lt;span class="caps"&gt;TAB&lt;/span&gt; key&amp;#8221;&lt;/p&gt;
	&lt;/blockquote&gt;


&lt;pre style="overflow: auto; background: #EEE;"&gt;
IRB.conf[:PROMPT_MODE] = :SIMPLE

require 'irb/completion'

IRB.conf[:AUTO_INDENT] = true

# Session History

HISTFILE = "~/.irb.hist" unless defined? HISTFILE
MAXHISTSIZE = 100 unless defined? MAXHISTSIZE

begin
if defined? Readline::HISTORY
histfile = File::expand_path(HISTFILE)
if File::exists?(histfile)
lines = IO::readlines(histfile).collect { |line| line.chomp }
Readline::HISTORY.push(*lines)
end

Kernel::at_exit {
lines = Readline::HISTORY.to_a.reverse.uniq.reverse
lines = lines[-MAXHISTSIZE, MAXHISTSIZE] if lines.nitems &amp;gt;
MAXHISTSIZE
File::open(histfile, File::WRONLY|File::CREAT|File::TRUNC) {|f|
lines.each {|line| f.puts line }
}
}
end
end
&lt;/pre&gt;</description>
      <pubDate>Wed, 25 Apr 2007 10:47:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:9bc46352-8e4c-4521-9bc8-ae23b7ec3896</guid>
      <author>Enrique Delgado</author>
      <link>http://www.enriquedelgado.com/articles/2007/04/25/interactive-ruby-console-tip-remember-the-last-x-commands-even-after-logging-out</link>
      <category>Rails</category>
      <category>ruby</category>
      <category>irb</category>
      <category>tips</category>
    </item>
    <item>
      <title>New home!</title>
      <description>&lt;p&gt;Hi All,&lt;/p&gt;


	&lt;p&gt;Welcome to the brand-spanking new home for all my blogging needs. It&amp;#8217;s better, it&amp;#8217;s faster, we rebuilt it, we had the technology :p&lt;/p&gt;</description>
      <pubDate>Mon, 23 Apr 2007 15:46:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:98a46daa-5586-4b2f-bfe0-110856d17362</guid>
      <author>Enrique Delgado</author>
      <link>http://www.enriquedelgado.com/articles/2007/04/23/new_home</link>
      <category>Fun Stuff</category>
    </item>
  </channel>
</rss>
