<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Standsolid's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 23:49:12 GMT</pubDate>
    <description>DZone Snippets: Standsolid's Code Snippets</description>
    <item>
      <title>Active Record to_hash</title>
      <link>http://snippets.dzone.com/posts/show/3082</link>
      <description>With this mix-in, you can have nice "to_hash" methods on your active record objects.  &lt;br /&gt;&lt;br /&gt;I find it good for programming JSON apps.&lt;br /&gt;&lt;br /&gt;In lib/ar_hashing.rb&lt;br /&gt;&lt;code&gt;&lt;br /&gt;module ActiveRecordHashing&lt;br /&gt;  def to_hash&lt;br /&gt;      Hash[*self.map{ |m| [m.id, m]}.flatten]               &lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;and in config/environment.rb&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'ar_hashing'&lt;br /&gt;&lt;br /&gt;class ActiveRecord::Associations::AssociationCollection&lt;br /&gt;  include ActiveRecordHashing&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 05 Dec 2006 05:13:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3082</guid>
      <author>standsolid (Kenny)</author>
    </item>
    <item>
      <title>Sanitize runaway Z indexes!</title>
      <link>http://snippets.dzone.com/posts/show/821</link>
      <description>This is a function I wrote to sanitize zIndexes of a list of elements that you may continually are bringing to the top of a page.  This function goes through HTML Elements and makes all the numbers as low as can be without affecting ordering. &lt;br /&gt;&lt;br /&gt;Feel free to make suggestions or to use this code how you'd like. &lt;br /&gt;&lt;br /&gt;One condition, please just tell me if you're using it, and if you have ideas for improvement, let me know&lt;br /&gt;kenny[@t  ]]]standsolid.com&lt;br /&gt;&lt;br /&gt;&lt;code&gt;function sanitizeZ(elements){&lt;br /&gt;&lt;br /&gt;	function sortByZIndex(a, b){&lt;br /&gt;		return a[1] - b[1];&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	var tempZArray = new Array();&lt;br /&gt;	for(i in elements)&lt;br /&gt;		tempZArray.push([i, elements[i].style.zIndex]);&lt;br /&gt;&lt;br /&gt;	tempZArray.sort(sortByZIndex);&lt;br /&gt;&lt;br /&gt;	for(i in tempZArray)&lt;br /&gt;		elements[ tempZArray[i][0] ].style ['zIndex'] = i;&lt;br /&gt;&lt;br /&gt;}&lt;/code&gt;</description>
      <pubDate>Wed, 19 Oct 2005 11:57:11 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/821</guid>
      <author>standsolid (Kenny)</author>
    </item>
  </channel>
</rss>
