<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/atom10full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb"><title type="text">tech.ablegray.com</title>
<subtitle type="text">You heard it here first©</subtitle>

<link rel="alternate" type="text/html" href="http://tech.ablegray.com/" />
<id>tag:tech.ablegray.com,2005:e0e38361baa13d14fdc058ee9fb8ea0e</id>
<generator uri="http://textpattern.com/" version="4.0.3">Textpattern</generator>
<updated>2007-10-30T20:38:28Z</updated>
<author>
		<name>Mike Nicholaides</name>
		<email>mike.nicholaides@gmail.com</email>
		<uri>http://tech.ablegray.com/</uri>
</author>
<link rel="self" href="http://feeds.feedburner.com/techablegray" type="application/atom+xml" /><entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2007-10-30T20:38:27Z</published>
		<updated>2007-10-30T20:38:27Z</updated>
		<title>Wishlist: window.alert() Shouldn't Take Over The Application</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/wishlist-windowalert-shouldnt-take-over-the-application" />
		<id>tag:tech.ablegray.com,2007-10-30:e0e38361baa13d14fdc058ee9fb8ea0e/8acbe36c22c4bc641a99eff744eb601e</id>
		
		
		<content type="html">
	&lt;p&gt;I’m tired of having my browser hijacked by &lt;code&gt;window.alert()&lt;/code&gt;.  Before the advent of tabbed browsing, I’m sure that taking over the application wasn’t that bad, but now that I have multiple web pages and applications open in different tabs it’s a different situation.  I don’t see why my browser won’t let me do anything (I can’t even close it!) when some website wants to tell me something.&lt;/p&gt;
	&lt;p&gt;Is this feature listed for FF3?  If not, it should be.  Or maybe an extension could take care of this? Any takers?&lt;/p&gt;

 
</content>
</entry>
<entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2007-10-30T20:33:23Z</published>
		<updated>2007-10-30T20:33:23Z</updated>
		<title>Rails Gotcha: Calling Attribute Methods From the Model Instance</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/rails-gotcha-calling-attribute-methods-from-the-model-instance" />
		<id>tag:tech.ablegray.com,2007-10-30:e0e38361baa13d14fdc058ee9fb8ea0e/f334b953ad75ea4b88ca6f9f395ebabc</id>
		
		
		<content type="html">
	&lt;p&gt;Here’s a little one that got me in the past.  When you’re writing a method of a model, you have to be careful about how you set attributes.&lt;/p&gt;
	&lt;p&gt;Let’s say for example that you have a model Country, with attributes &lt;code&gt;population&lt;/code&gt;, &lt;code&gt;area&lt;/code&gt;, and &lt;code&gt;government&lt;/code&gt;. When you want to use this property in a method, you can say:&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;Country
  def population_density
    area / population
  end
end&lt;/pre&gt;&lt;/code&gt;
	&lt;p&gt;And this will work just fine.  So, it seems like you can use the &lt;code&gt;area&lt;/code&gt; and &lt;code&gt;population&lt;/code&gt; in your code when you need to deal with these attributes.&lt;/p&gt;
	&lt;p&gt;Watch Out!&lt;/p&gt;
	&lt;p&gt;Look out that you don’t do this in the method:&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;Country
  def plague
    government = 'anarchy'
    population = 0
    save
  end
end&lt;/pre&gt;&lt;/code&gt;
	&lt;p&gt;The problem is that &lt;code&gt;population = 0&lt;/code&gt; will only set a local variable to 0, and not your population attribute.  Instead, you have to use &lt;code&gt;self.population = 0&lt;/code&gt;.  So, your &lt;code&gt;#plague&lt;/code&gt; method would look like this:&lt;/p&gt;
&lt;code&gt;&lt;pre&gt;def plague
  self.government = 'anarchy'
  self.population = 0
  save
end&lt;/pre&gt;&lt;/code&gt;
	&lt;p&gt;Disclaimer:&lt;/p&gt;
	&lt;p&gt;Yes, I know, #plague would really look like this:&lt;br /&gt;
&lt;code&gt;&lt;pre&gt;def plague
  update_attributes :government =&amp;gt; 'anargy', :population =&amp;gt; 0&lt;br /&gt;
end&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;
	&lt;p&gt;I used the example above to demonstrate the concept.&lt;/p&gt;

 
</content>
</entry>
<entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2007-09-12T16:11:28Z</published>
		<updated>2007-09-12T16:11:28Z</updated>
		<title>A Killer Combo: SASS and Styler</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/a-killer-combo-sass-and-styler" />
		<id>tag:tech.ablegray.com,2007-09-12:e0e38361baa13d14fdc058ee9fb8ea0e/f78800d5481f5ff2e82fb76007f4e630</id>
		
		
		<content type="html">
	&lt;p&gt;They work together out of the box.&lt;/p&gt;
	&lt;p&gt;&lt;a href="http://haml.hamptoncatlin.com/docs/rdoc"&gt;SASS&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://the.railsi.st/2007/5/3/styler-stylesheets-made-easy"&gt;Styler&lt;/a&gt;&lt;/p&gt;

 
</content>
</entry>
<entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2007-08-18T04:04:00Z</published>
		<updated>2007-08-18T04:08:49Z</updated>
		<title>Why we use i, j, and k in for loops</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/why-we-use-i-j-and-k-in-for-loops" />
		<id>tag:tech.ablegray.com,2007-08-17:e0e38361baa13d14fdc058ee9fb8ea0e/b97cd3dae3880e2a59f3eaf2481b2a27</id>
		
		
		<content type="html">
&lt;p&gt;Let this quote explain:&lt;/p&gt;
&lt;blockquote&gt;In Fortran, all variables starting with the letters I, J, K, L, M and N are integers... (This is the source of the long tradition of using "i", "j", "k" etc as the loop indexes of "for loops" in many programming languages -- few of which have implicit typing).&lt;/blockquote&gt;

&lt;p&gt;
&lt;cite&gt;&lt;a href="http://en.wikipedia.org/wiki/Sigil_%28computer_programming%29"&gt;
Wikipedia - Sigil (computer programming)&lt;/a&gt;&lt;/cite&gt;
&lt;/p&gt;

&lt;p&gt;
I guess you learn something new everyday.
&lt;/p&gt;
</content>
</entry>
<entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2007-05-08T13:33:00Z</published>
		<updated>2007-05-08T16:41:32Z</updated>
		<title>Running Individual Tests in Textmate</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/running-individual-tests-in-textmate" />
		<id>tag:tech.ablegray.com,2007-05-08:e0e38361baa13d14fdc058ee9fb8ea0e/058276b8432f12d1c9202cf7c9a719ff</id>
		
		
		<content type="html">
	&lt;p&gt;I just found out that you can run a single test in &lt;a href="http://macromates.com"&gt;TextMate&lt;/a&gt; with Apple+Shift+R when you’re editing a test in Ruby on Rails mode.  No more scrolling in my test window!&lt;/p&gt;

 
</content>
</entry>
<entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2006-08-31T17:26:00Z</published>
		<updated>2006-08-31T17:34:07Z</updated>
		<title>Can you guess what this button does?</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/can-you-guess-what-this-button-does" />
		<id>tag:tech.ablegray.com,2006-08-31:e0e38361baa13d14fdc058ee9fb8ea0e/8a0598363728ce2b84cb55f95c31bff0</id>
		
		
		<content type="html">
	&lt;p&gt;We use Lotus Notes at work.  We’re the government, so you can’t expect us to always be on the cutting edge, or even within 5 years of it.  That’s just how it is.&lt;/p&gt;
	&lt;p&gt;Anyways, if you are familiar with Lotus Notes, you know that it can do everything, poorly.  I have many complaints about Notes, but today I just wanted to share one example that could give you a feel for the general quality (or lack there of) of the application.  Let’s look at the main toolbar (I shortened it by cutting some uninteresting parts.) that I see while when I’m reading my email:&lt;/p&gt;
	&lt;p&gt;&lt;img src="/images/2.png" alt="" /&gt;&lt;/p&gt;
	&lt;p&gt;Can you guess what these buttons do?  Go through each one and guess what each button does.  Below are the answers.&lt;/p&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;img src="/images/5.png" alt="" /&gt; Stumped? &lt;em&gt;Obviously&lt;/em&gt; this button brings up a little window that shows the properties of the page you’re currently viewing.  &lt;em&gt;What else would “two squares, one superimposed on the other and rotated 45 degrees” mean?!&lt;/em&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;img src="/images/6.png" alt="" /&gt; &lt;em&gt;Save&lt;/em&gt;. Ok, that was too easy.  But don’t get cocky. This next one will get you for sure.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;img src="/images/4.png" alt="" /&gt; Well, let’s see, an &lt;em&gt;open&lt;/em&gt; folder, with an arrow gesturing to &lt;em&gt;open&lt;/em&gt; it.  Could this be &lt;em&gt;Open&lt;/em&gt;?  WRONG! It’s &lt;em&gt;New&lt;/em&gt;.  It brings up a menu where you can choose to make a new email, new calendar entry, new contact, or a new todo item.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;img src="/images/3.png" alt="" /&gt; Yeah, these are all boring.  &lt;em&gt;Edit&lt;/em&gt;, &lt;em&gt;Forward Email&lt;/em&gt;, &lt;em&gt;Print&lt;/em&gt;, &lt;em&gt;Back&lt;/em&gt;, &lt;em&gt;Forward&lt;/em&gt;, &lt;em&gt;Stop&lt;/em&gt;, &lt;em&gt;Refresh&lt;/em&gt;.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;img src="/images/7.png" alt="" /&gt; Ok, now this one was kind of a trick question.  You would think it means either &lt;em&gt;Search&lt;/em&gt; (which is the right answer) or &lt;em&gt;Magnify&lt;/em&gt;.  However, clicking on it brings up a friendly little dialog box that says “Cannot execute the specified command”.  A button that does nothing? That’s pretty dumb.  At the very least it should be greyed-out like the &lt;em&gt;Save&lt;/em&gt; button.&lt;/li&gt;
	&lt;/ul&gt;
	&lt;p&gt;Yeah, Lotus Notes is pretty terrible.  However, in its defense, I may be holding it to a higher standard than it deserves.  After all, they’ve only had 15 or so years to perfect it.&lt;/p&gt;
	&lt;p&gt;Well, I hope you learned something today. Maybe you learned that you should avoid Lotus Notes.  Or perhaps you need to take a look at your own application and make sure you aren’t making the same mistakes.  Or maybe you’ve now have a better appreciation for the software you use that &lt;em&gt;doesn’t&lt;/em&gt; suck.&lt;/p&gt;

 
</content>
</entry>
<entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2006-08-11T20:21:00Z</published>
		<updated>2006-08-11T20:25:31Z</updated>
		<title>Where is Dreamweaver + Subversion?</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/where-is-dreamweaver-subversion" />
		<id>tag:tech.ablegray.com,2006-08-11:e0e38361baa13d14fdc058ee9fb8ea0e/868b5f246d91bec423f54ea13d466a65</id>
		
		
		<summary type="html">
	&lt;p&gt;If you’ve ever looked for a way to use Subversion from within Dreamweaver, you know that there are only 2 or 3 products that do this, and they are all closed source, and they are all pretty much inadequate for actual work.  How come there are no good products? Well, I have a few guesses.&lt;/p&gt;

 
</summary>
</entry>
<entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2006-08-10T21:12:00Z</published>
		<updated>2006-08-12T22:47:01Z</updated>
		<title>Firefox for Web Developers</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/firefox-for-web-developers" />
		<id>tag:tech.ablegray.com,2006-08-10:e0e38361baa13d14fdc058ee9fb8ea0e/ef9066735ff8bbc0689b38debbb8d783</id>
		
		
		<summary type="html">
&lt;p&gt;
	Firefox: a web developer's best friend.  Armed with the right extensions, Firefox really is the most powerful tool a web develop has these days.  In this article, I want to highlight the web development extensions that I find particularly useful. 
&lt;/p&gt;
</summary>
</entry>
<entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2006-08-03T18:51:00Z</published>
		<updated>2006-08-03T19:07:47Z</updated>
		<title>getChildrenByTagName</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/getchildrenbytagname" />
		<id>tag:tech.ablegray.com,2006-08-03:e0e38361baa13d14fdc058ee9fb8ea0e/8974191b78b34c52a671da2f72d4f53b</id>
		
		
		<content type="html">
&lt;p&gt;
Until the day we can use javascript select elements with XPath (natively) this script will be useful.
&lt;/p&gt;

&lt;p&gt;
Select all children (not descendants) that have a specified tag name.
&lt;/p&gt;

E.g. &lt;code&gt;getChildrenByTagName( $('navigation'), 'li' )&lt;/code&gt; will only select &lt;code&gt;li&lt;/code&gt; elements that are children of your &lt;code&gt;&amp;lt;ul id="navigation"&amp;gt;&lt;/code&gt; element. Note that the &lt;code&gt;$(..)&lt;/code&gt; function is provided by the &lt;a href="http://prototype.conio.net/"&gt;Prototype library&lt;/a&gt;.

&lt;pre&gt;&lt;code&gt;function getChildrenByTagName(root_element, tag) {
  var kids = root_element.childNodes

  var kids_w_tag = new Array()
  
  for (var i=0; i&amp;lt;kids.length; i++)
    if (kids.item(i).tagName == tag.toUpperCase())
      kids_w_tag.push(kids.item(i))
      
  return kids_w_tag
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
This is useful because some browsers (including FF) correctly include white-space between elements in the DOM as &lt;code&gt;TextNode&lt;/code&gt;s.
&lt;p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;ul&amp;gt;
 &amp;lt;li&amp;gt;Harry&amp;lt;/li&amp;gt;
 &amp;lt;li&amp;gt;Susan&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
The child nodes of the &lt;code&gt;ul&lt;/code&gt; above are &lt;code&gt;[ TextNode, LIElement:Harry, TextNode, LIElement:Susan, TextNode ]&lt;/code&gt;
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;ul&amp;gt;&amp;lt;li&amp;gt;Harry&amp;lt;/li&amp;gt;&amp;lt;li&amp;gt;Susan&amp;lt;/li&amp;gt;&amp;lt;/ul&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
But in this example, the childnodes of the &lt;code&gt;ul&lt;/code&gt; are &lt;code&gt;[ LIElement:Harry, LIElement:Susan ]&lt;/code&gt; 
&lt;/p&gt;
</content>
</entry>
<entry>
		<author>
			<name>Mike Nicholaides</name>
		</author>
		<published>2006-08-03T18:20:00Z</published>
		<updated>2006-08-03T19:09:49Z</updated>
		<title>getElementsByTagAndClass</title>
		<link rel="alternate" type="text/html" href="http://tech.ablegray.com/article/getelementsbytagandclass" />
		<id>tag:tech.ablegray.com,2006-08-03:e0e38361baa13d14fdc058ee9fb8ea0e/101a62ee010a8c2480049f794969750d</id>
		
		
		<content type="html">
&lt;p&gt;This is a nice little utility function that I want to save.&lt;/p&gt;

&lt;p&gt;
	&lt;code&gt;getElementsByTagAndClass(document, 'div', 'product')&lt;/code&gt; will return an &lt;code&gt;Array&lt;/code&gt; of &lt;code&gt;div&lt;/code&gt; elements with class name exactly equal to &lt;code&gt;"product"&lt;/code&gt;.
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function getElementsByTagAndClass(root_element, tag, className) {
  var tags_with_class = new Array()
  
  var tags = root_element.getElementsByTagName(tag)
  
  for (var i=0; i&amp;lt;tags.length; i++)
    if (tags[i].className == className)
      tags_with_class.push(tags[i])
      
  return tags_with_class
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;

&lt;p&gt;Caveat: this may not work in IE. I'm not sure if IE supports &lt;code&gt;someElement.getElementsByTagName(..)&lt;/code&gt; when &lt;code&gt;someElement&lt;/code&gt; is not &lt;code&gt;document&lt;/code&gt;.&lt;/p&gt;
</content>
</entry></feed>
