<?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>something cliche</title>
	<atom:link href="http://somethingcliche.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://somethingcliche.com</link>
	<description>web development, technology, personal finance</description>
	<lastBuildDate>Thu, 03 Feb 2011 20:16:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>trakt.tv &#8211; like last.fm but for tv and movies!</title>
		<link>http://somethingcliche.com/2011/02/03/trakt-tv-like-last-fm-but-for-tv-and-movies/</link>
		<comments>http://somethingcliche.com/2011/02/03/trakt-tv-like-last-fm-but-for-tv-and-movies/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 20:16:55 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[trakt]]></category>
		<category><![CDATA[xbmc]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=635</guid>
		<description><![CDATA[So I&#8217;ve been neglecting something cliche for quite a bit as I&#8217;m sure you have noticed. Rest assured I&#8217;m not sitting idly by and the time has been well spent. I&#8217;ve been working on trakt these past few months. trakt helps keep a record of what TV shows and movies you are watching. Based on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://trakt.tv" rel="external"><img src="http://somethingcliche.com/wp-content/uploads/2011/02/icon.png" alt="trakt.tv" title="trakt.tv" width="120" height="120" class="alignleft size-full wp-image-637" /></a>So I&#8217;ve been neglecting something cliche for quite a bit as I&#8217;m sure you have noticed. Rest assured I&#8217;m not sitting idly by and the time has been well spent. I&#8217;ve been working on <a href="http://trakt.tv" rel="external">trakt</a> these past few months.</p>
<p><a href="http://trakt.tv" rel="external">trakt</a> helps keep a record of what TV shows and movies you are watching. Based on your favorites, trakt recommends additional shows and movies you&#8217;ll enjoy. This works as a <a href="http://trakt.tv/downloads/xbmc" rel="external">plugin for XBMC media center</a> that automatically <strong>scrobbles</strong> all tv shows and movies you watch. We also have plugins for <a href="http://trakt.tv/downloads/mediaportal" rel="external">MediaPortal</a> available with several more media centers in the works.</p>
<h3>What make trakt better than other &#8220;check-in&#8221; sites?</h3>
<p>Well, the main thing that sets us apart is automatic and realtime scrobbling of all shows and movies. Some of the other sites out there like getglue and miso require a manual check in from your phone or the website. With <strong>trakt</strong>, we automate that so you don&#8217;t even have to remember to check in, the website will just sync up and track silently in the background.</p>
<p>If you don&#8217;t have a supported media center (btw, we are definitely focused on expanding our supported media centers), you have the option to manually mark a show as watched. In that sense, it is kinda like a check in and makes the site useful for everyone. There is also the concept of adding something to your library. This means you have the show or movie, but you haven&#8217;t watched it yet. When you browse the website it will indicate everything you&#8217;ve watched and have in your library so its super easy to see new things to watch.</p>
<h3>Community</h3>
<p>The <strong>trakt</strong> community is over 2100 members as of this post and is very active with discussions, ratings (love/hate), and members building up their watching history. We have a full featured API that community members are already leveraging to create custom mashups of their data. Interesting ideas that have been explored include customize charts of your history, mobile apps, and 2 way syncing your entire media collection with the website.</p>
<p>We&#8217;re actively developing the social aspects of the site including recommendations, facebook integration, and twitter integration. Stay tuned for that.</p>
<h3>Give it a try!</h3>
<p>This is a just a quick overview and update why something cliche has been devoid of new content lately. Check out <a href="http://trakt.tv" rel="external">http://trakt.tv</a> and sign up for a free acount! Also follow <a href="http://twitter.com/trakt" rel="external">@trakt</a> for updates!</p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2011/02/03/trakt-tv-like-last-fm-but-for-tv-and-movies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rules to code by, Part 1</title>
		<link>http://somethingcliche.com/2010/08/19/rules-to-code-by/</link>
		<comments>http://somethingcliche.com/2010/08/19/rules-to-code-by/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 21:21:16 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=621</guid>
		<description><![CDATA[When I code things myself and especially when working with code that other&#8217;s have written, here are things I always think to myself. Just a few friendly tips to keep in mind for your next project. These are in no particular order, just as I thought of them. &#160; &#160; &#160; use comments so others [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-627" title="Code" src="http://somethingcliche.com/wp-content/uploads/2010/08/code.jpg" alt="" width="120" height="120" />When I code things myself and especially when working with code that other&#8217;s have written, here are things I always think to myself.</p>
<p>Just a few friendly tips to keep in mind for your next project. These are in no particular order, just as I thought of them.</p>
<p>&nbsp;<br />
&nbsp;<br />
&nbsp;</p>
<ol>
<li>use comments so others can understand what you are doing</li>
<li>do not use any Dreamweaver generated code as your example (in most cases, do the opposite)</li>
<li>use a JavaScript framework (my favorite is <a rel="external" href="http://mootools.net">MooTools</a>), no need to re-invent the wheel for things like ajax</li>
<li>try and stick to one framework instead of mixing MooTool and jQuery</li>
<li>don&#8217;t make functions with a million arguments, just pass a single array for readability and flexibility (think MooTools style)</li>
<li>use tabs not spaces</li>
<li>use all lowercase filenames and directories</li>
<li>even worse, don&#8217;t name files in one case and code them in a different (ever heard of a case sensitive filesystem?)</li>
<li>use associative arrays where it makes sense, such as multi dimensional arrays and objects (see <a href="http://somethingcliche.com/2010/01/12/use-keyed-objects-instead-of-indexed-arrays/">this post</a>)</li>
<li>honestly, who uses Spry anymore?</li>
<li>CSS hacks and IE conditionals are cool and all, but learning to code CSS better will almost eliminate any hacks you&#8217;ll need</li>
<li>keep admin and front end code separated except for shared functions</li>
<li>test in all the browsers you need to support</li>
<li>code for standard compliance first, then fix as needed for Internet Explorer (see #11, in most cases IE will work well if you code well)</li>
<li>avoid flash for things like menus that can easily be accomplished using HTML and CSS</li>
<li>avoid inline JavaScript and instead use an external file to keep the HTML clean and maintainable</li>
<li>don&#8217;t use inline CSS either</li>
<li>make sure to secure your ajax pages, don&#8217;t want anyone messing with your database</li>
<li>keep mobile platforms in mind when thinking about usability</li>
<li>public pages should function in IE6, but I&#8217;m not too concerned about them looking good</li>
</ol>
<p>Well, those are 20 things I just thought of. I&#8217;m sure I&#8217;ll think of more and when I do there will be the inevitable part 2 post.</p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/08/19/rules-to-code-by/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PowerGallery Stack design</title>
		<link>http://somethingcliche.com/2010/07/29/powergallery-stack-design/</link>
		<comments>http://somethingcliche.com/2010/07/29/powergallery-stack-design/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 21:43:22 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[MooTools]]></category>
		<category><![CDATA[WebAssist]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=603</guid>
		<description><![CDATA[If you aren&#8217;t familiar with PowerGallery, it is a PHP web app that I created for WebAssist. Basically, you can upload your images and display them on your page with several built in gallery designs. When programming this product, one thing I wanted was easy extensibility so more designs could be added easily. The 1.1 [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://somethingcliche.com/wp-content/uploads/2010/07/stack.jpg" alt="" title="PowerGallery Stack design" width="120" height="120" class="alignleft size-full wp-image-606" />If you aren&#8217;t familiar with <a href="http://www.webassist.com/php-scripts-and-solutions/powergallery/" rel="external">PowerGallery</a>, it is a PHP web app that I created for <a href="http://www.webassist.com">WebAssist</a>. Basically, you can upload your images and display them on your page with several built in gallery designs. When programming this product, one thing I wanted was easy extensibility so more designs could be added easily. The 1.1 release added 3 slideshows that were great. </p>
<p>I&#8217;ve created another design called <strong>Stack</strong> and you can download it for free below. To install it, just unzip the file and upload the <strong>stack</strong> directory to the <strong>galleries</strong> directory inside your PowerGallery installation. That&#8217;s it! Log in to the admin and you&#8217;ll see Stack a new choice on the Choose Design page.</p>
<p><img src="http://somethingcliche.com/wp-content/uploads/2010/07/stack_example.jpg" alt="" title="PowerGallery Stack example" width="525" height="280" class="aligncenter size-full wp-image-610" /></p>
<p>This gallery was created using the <a href="http://mootools.net/forge/p/elementstack" rel="external">ElementStack</a> MooTools plugin. You can see a live demo <a href="http://nouincolor.com/ElementStack/" rel="external">here</a>. Since PowerGallery uses MooTools 1.2, you can easily create galleries yourself and just drop them into the <strong>galleries</strong> folder for easy use.</p>
<p>&nbsp;</p>
<p><a class="download" href="http://somethingcliche.com/wp-content/uploads/2010/07/powergallery_stack.zip">Download the design</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/07/29/powergallery-stack-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PayPal countries and regions in JSON</title>
		<link>http://somethingcliche.com/2010/07/22/paypal-countries-and-regions-in-json/</link>
		<comments>http://somethingcliche.com/2010/07/22/paypal-countries-and-regions-in-json/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 16:09:55 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PayPal]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=588</guid>
		<description><![CDATA[I was working on a PayPal powered commerce website and for the checkout form, I needed to create a dropdown list of the countries that PayPal supports. I couldn&#8217;t find a list in the exact format that I needed, so I created a JavaScript array of JSON objects. Pretty straightfoward, but I thought it would [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://somethingcliche.com/wp-content/uploads/2010/07/paypal.png" alt="" title="PayPal" width="120" height="120" class="alignleft size-full wp-image-595" />I was working on a PayPal powered commerce website and for the checkout form, I needed to create a dropdown list of the countries that PayPal supports. I couldn&#8217;t find a list in the exact format that I needed, so I created a JavaScript array of JSON objects. Pretty straightfoward, but I thought it would be a good starting point for some of you if you need the same thing.</p>
<p>This list uses the countries listed on <a href="https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&#038;content_ID=developer/e_howto_api_nvp_country_codes" rel="external">PayPal&#8217;s website</a>. PayPal requires that you send the 2-character IS0-3166-1 code to their API. Below I have the name and code combinations.<br />
<span id="more-588"></span></p>
<pre class="js">var countries = [
	{name: 'Afghanistan', code: 'AF'},
	{name: 'Åland Islands', code: 'AX'},
	{name: 'Albania', code: 'AL'},
	{name: 'Algeria', code: 'DZ'},
	{name: 'American Samoa', code: 'AS'},
	{name: 'AndorrA', code: 'AD'},
	{name: 'Angola', code: 'AO'},
	{name: 'Anguilla', code: 'AI'},
	{name: 'Antarctica', code: 'AQ'},
	{name: 'Antigua and Barbuda', code: 'AG'},
	{name: 'Argentina', code: 'AR'},
	{name: 'Armenia', code: 'AM'},
	{name: 'Aruba', code: 'AW'},
	{name: 'Australia', code: 'AU'},
	{name: 'Austria', code: 'AT'},
	{name: 'Azerbaijan', code: 'AZ'},
	{name: 'Bahamas', code: 'BS'},
	{name: 'Bahrain', code: 'BH'},
	{name: 'Bangladesh', code: 'BD'},
	{name: 'Barbados', code: 'BB'},
	{name: 'Belarus', code: 'BY'},
	{name: 'Belgium', code: 'BE'},
	{name: 'Belize', code: 'BZ'},
	{name: 'Benin', code: 'BJ'},
	{name: 'Bermuda', code: 'BM'},
	{name: 'Bhutan', code: 'BT'},
	{name: 'Bolivia', code: 'BO'},
	{name: 'Bosnia and Herzegovina', code: 'BA'},
	{name: 'Botswana', code: 'BW'},
	{name: 'Bouvet Island', code: 'BV'},
	{name: 'Brazil', code: 'BR'},
	{name: 'British Indian Ocean Territory', code: 'IO'},
	{name: 'Brunei Darussalam', code: 'BN'},
	{name: 'Bulgaria', code: 'BG'},
	{name: 'Burkina Faso', code: 'BF'},
	{name: 'Burundi', code: 'BI'},
	{name: 'Cambodia', code: 'KH'},
	{name: 'Cameroon', code: 'CM'},
	{name: 'Canada', code: 'CA'},
	{name: 'Cape Verde', code: 'CV'},
	{name: 'Cayman Islands', code: 'KY'},
	{name: 'Central African Republic', code: 'CF'},
	{name: 'Chad', code: 'TD'},
	{name: 'Chile', code: 'CL'},
	{name: 'China', code: 'CN'},
	{name: 'Christmas Island', code: 'CX'},
	{name: 'Cocos (Keeling) Islands', code: 'CC'},
	{name: 'Colombia', code: 'CO'},
	{name: 'Comoros', code: 'KM'},
	{name: 'Congo', code: 'CG'},
	{name: 'Congo, The Democratic Republic of the', code: 'CD'},
	{name: 'Cook Islands', code: 'CK'},
	{name: 'Costa Rica', code: 'CR'},
	{name: 'Cote D\'Ivoire', code: 'CI'},
	{name: 'Croatia', code: 'HR'},
	{name: 'Cuba', code: 'CU'},
	{name: 'Cyprus', code: 'CY'},
	{name: 'Czech Republic', code: 'CZ'},
	{name: 'Denmark', code: 'DK'},
	{name: 'Djibouti', code: 'DJ'},
	{name: 'Dominica', code: 'DM'},
	{name: 'Dominican Republic', code: 'DO'},
	{name: 'Ecuador', code: 'EC'},
	{name: 'Egypt', code: 'EG'},
	{name: 'El Salvador', code: 'SV'},
	{name: 'Equatorial Guinea', code: 'GQ'},
	{name: 'Eritrea', code: 'ER'},
	{name: 'Estonia', code: 'EE'},
	{name: 'Ethiopia', code: 'ET'},
	{name: 'Falkland Islands (Malvinas)', code: 'FK'},
	{name: 'Faroe Islands', code: 'FO'},
	{name: 'Fiji', code: 'FJ'},
	{name: 'Finland', code: 'FI'},
	{name: 'France', code: 'FR'},
	{name: 'French Guiana', code: 'GF'},
	{name: 'French Polynesia', code: 'PF'},
	{name: 'French Southern Territories', code: 'TF'},
	{name: 'Gabon', code: 'GA'},
	{name: 'Gambia', code: 'GM'},
	{name: 'Georgia', code: 'GE'},
	{name: 'Germany', code: 'DE'},
	{name: 'Ghana', code: 'GH'},
	{name: 'Gibraltar', code: 'GI'},
	{name: 'Greece', code: 'GR'},
	{name: 'Greenland', code: 'GL'},
	{name: 'Grenada', code: 'GD'},
	{name: 'Guadeloupe', code: 'GP'},
	{name: 'Guam', code: 'GU'},
	{name: 'Guatemala', code: 'GT'},
	{name: 'Guernsey', code: 'GG'},
	{name: 'Guinea', code: 'GN'},
	{name: 'Guinea-Bissau', code: 'GW'},
	{name: 'Guyana', code: 'GY'},
	{name: 'Haiti', code: 'HT'},
	{name: 'Heard Island and Mcdonald Islands', code: 'HM'},
	{name: 'Holy See (Vatican City State)', code: 'VA'},
	{name: 'Honduras', code: 'HN'},
	{name: 'Hong Kong', code: 'HK'},
	{name: 'Hungary', code: 'HU'},
	{name: 'Iceland', code: 'IS'},
	{name: 'India', code: 'IN'},
	{name: 'Indonesia', code: 'ID'},
	{name: 'Iran, Islamic Republic Of', code: 'IR'},
	{name: 'Iraq', code: 'IQ'},
	{name: 'Ireland', code: 'IE'},
	{name: 'Isle of Man', code: 'IM'},
	{name: 'Israel', code: 'IL'},
	{name: 'Italy', code: 'IT'},
	{name: 'Jamaica', code: 'JM'},
	{name: 'Japan', code: 'JP'},
	{name: 'Jersey', code: 'JE'},
	{name: 'Jordan', code: 'JO'},
	{name: 'Kazakhstan', code: 'KZ'},
	{name: 'Kenya', code: 'KE'},
	{name: 'Kiribati', code: 'KI'},
	{name: 'Korea, Democratic People\'S Republic of', code: 'KP'},
	{name: 'Korea, Republic of', code: 'KR'},
	{name: 'Kuwait', code: 'KW'},
	{name: 'Kyrgyzstan', code: 'KG'},
	{name: 'Lao People\'S Democratic Republic', code: 'LA'},
	{name: 'Latvia', code: 'LV'},
	{name: 'Lebanon', code: 'LB'},
	{name: 'Lesotho', code: 'LS'},
	{name: 'Liberia', code: 'LR'},
	{name: 'Libyan Arab Jamahiriya', code: 'LY'},
	{name: 'Liechtenstein', code: 'LI'},
	{name: 'Lithuania', code: 'LT'},
	{name: 'Luxembourg', code: 'LU'},
	{name: 'Macao', code: 'MO'},
	{name: 'Macedonia, The Former Yugoslav Republic of', code: 'MK'},
	{name: 'Madagascar', code: 'MG'},
	{name: 'Malawi', code: 'MW'},
	{name: 'Malaysia', code: 'MY'},
	{name: 'Maldives', code: 'MV'},
	{name: 'Mali', code: 'ML'},
	{name: 'Malta', code: 'MT'},
	{name: 'Marshall Islands', code: 'MH'},
	{name: 'Martinique', code: 'MQ'},
	{name: 'Mauritania', code: 'MR'},
	{name: 'Mauritius', code: 'MU'},
	{name: 'Mayotte', code: 'YT'},
	{name: 'Mexico', code: 'MX'},
	{name: 'Micronesia, Federated States of', code: 'FM'},
	{name: 'Moldova, Republic of', code: 'MD'},
	{name: 'Monaco', code: 'MC'},
	{name: 'Mongolia', code: 'MN'},
	{name: 'Montserrat', code: 'MS'},
	{name: 'Morocco', code: 'MA'},
	{name: 'Mozambique', code: 'MZ'},
	{name: 'Myanmar', code: 'MM'},
	{name: 'Namibia', code: 'NA'},
	{name: 'Nauru', code: 'NR'},
	{name: 'Nepal', code: 'NP'},
	{name: 'Netherlands', code: 'NL'},
	{name: 'Netherlands Antilles', code: 'AN'},
	{name: 'New Caledonia', code: 'NC'},
	{name: 'New Zealand', code: 'NZ'},
	{name: 'Nicaragua', code: 'NI'},
	{name: 'Niger', code: 'NE'},
	{name: 'Nigeria', code: 'NG'},
	{name: 'Niue', code: 'NU'},
	{name: 'Norfolk Island', code: 'NF'},
	{name: 'Northern Mariana Islands', code: 'MP'},
	{name: 'Norway', code: 'NO'},
	{name: 'Oman', code: 'OM'},
	{name: 'Pakistan', code: 'PK'},
	{name: 'Palau', code: 'PW'},
	{name: 'Palestinian Territory, Occupied', code: 'PS'},
	{name: 'Panama', code: 'PA'},
	{name: 'Papua New Guinea', code: 'PG'},
	{name: 'Paraguay', code: 'PY'},
	{name: 'Peru', code: 'PE'},
	{name: 'Philippines', code: 'PH'},
	{name: 'Pitcairn', code: 'PN'},
	{name: 'Poland', code: 'PL'},
	{name: 'Portugal', code: 'PT'},
	{name: 'Puerto Rico', code: 'PR'},
	{name: 'Qatar', code: 'QA'},
	{name: 'Reunion', code: 'RE'},
	{name: 'Romania', code: 'RO'},
	{name: 'Russian Federation', code: 'RU'},
	{name: 'RWANDA', code: 'RW'},
	{name: 'Saint Helena', code: 'SH'},
	{name: 'Saint Kitts and Nevis', code: 'KN'},
	{name: 'Saint Lucia', code: 'LC'},
	{name: 'Saint Pierre and Miquelon', code: 'PM'},
	{name: 'Saint Vincent and the Grenadines', code: 'VC'},
	{name: 'Samoa', code: 'WS'},
	{name: 'San Marino', code: 'SM'},
	{name: 'Sao Tome and Principe', code: 'ST'},
	{name: 'Saudi Arabia', code: 'SA'},
	{name: 'Senegal', code: 'SN'},
	{name: 'Serbia and Montenegro', code: 'CS'},
	{name: 'Seychelles', code: 'SC'},
	{name: 'Sierra Leone', code: 'SL'},
	{name: 'Singapore', code: 'SG'},
	{name: 'Slovakia', code: 'SK'},
	{name: 'Slovenia', code: 'SI'},
	{name: 'Solomon Islands', code: 'SB'},
	{name: 'Somalia', code: 'SO'},
	{name: 'South Africa', code: 'ZA'},
	{name: 'South Georgia and the South Sandwich Islands', code: 'GS'},
	{name: 'Spain', code: 'ES'},
	{name: 'Sri Lanka', code: 'LK'},
	{name: 'Sudan', code: 'SD'},
	{name: 'Suriname', code: 'SR'},
	{name: 'Svalbard and Jan Mayen', code: 'SJ'},
	{name: 'Swaziland', code: 'SZ'},
	{name: 'Sweden', code: 'SE'},
	{name: 'Switzerland', code: 'CH'},
	{name: 'Syrian Arab Republic', code: 'SY'},
	{name: 'Taiwan, Province of China', code: 'TW'},
	{name: 'Tajikistan', code: 'TJ'},
	{name: 'Tanzania, United Republic of', code: 'TZ'},
	{name: 'Thailand', code: 'TH'},
	{name: 'Timor-Leste', code: 'TL'},
	{name: 'Togo', code: 'TG'},
	{name: 'Tokelau', code: 'TK'},
	{name: 'Tonga', code: 'TO'},
	{name: 'Trinidad and Tobago', code: 'TT'},
	{name: 'Tunisia', code: 'TN'},
	{name: 'Turkey', code: 'TR'},
	{name: 'Turkmenistan', code: 'TM'},
	{name: 'Turks and Caicos Islands', code: 'TC'},
	{name: 'Tuvalu', code: 'TV'},
	{name: 'Uganda', code: 'UG'},
	{name: 'Ukraine', code: 'UA'},
	{name: 'United Arab Emirates', code: 'AE'},
	{name: 'United Kingdom', code: 'GB'},
	{name: 'United States', code: 'US'},
	{name: 'United States Minor Outlying Islands', code: 'UM'},
	{name: 'Uruguay', code: 'UY'},
	{name: 'Uzbekistan', code: 'UZ'},
	{name: 'Vanuatu', code: 'VU'},
	{name: 'Venezuela', code: 'VE'},
	{name: 'Viet Nam', code: 'VN'},
	{name: 'Virgin Islands, British', code: 'VG'},
	{name: 'Virgin Islands, U.S.', code: 'VI'},
	{name: 'Wallis and Futuna', code: 'WF'},
	{name: 'Western Sahara', code: 'EH'},
	{name: 'Yemen', code: 'YE'},
	{name: 'Zambia', code: 'ZM'},
	{name: 'Zimbabwe', code: 'ZW'}
];</pre>
<p>You can simply loop through this array to create a select list for use on your page.</p>
<pre class="js">var html = '&lt;select name="country"&gt;';
for(var i = 0; i &lt; countries.length; i++) {
	html += '&lt;option value="' + countries[i].code + '"&gt;' + countries[i].name + '&lt;/option&gt;';
}
html += '&lt;/select&gt;';
document.write(html);</pre>
<p>Let me know if this list ends up helping you out.</p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/07/22/paypal-countries-and-regions-in-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter encryption gotcha</title>
		<link>http://somethingcliche.com/2010/07/08/codeigniter-encryption-gotcha/</link>
		<comments>http://somethingcliche.com/2010/07/08/codeigniter-encryption-gotcha/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 20:57:43 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=577</guid>
		<description><![CDATA[Over the last few weeks, I have been learning CodeIgniter which is an open source PHP framework. It follows the MVC (model-view-controller) methodology, but allows you to utilize your existing PHP skillset. Overall I think CodeIgniter is great so far, but there are are few gotchas to look out for. I found an issue today [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-579" title="CodeIgniter" src="http://somethingcliche.com/wp-content/uploads/2010/07/codeigniter.jpg" alt="" width="120" height="120" />Over the last few weeks, I have been learning <a rel="external" href="http://codeigniter.com/">CodeIgniter</a> which is an open source PHP framework. It follows the MVC (model-view-controller) methodology, but allows you to utilize your existing PHP skillset. Overall I think CodeIgniter is great so far, but there are are few gotchas to look out for.</p>
<p>I found an issue today regarding the built in <a rel="external" href="http://codeigniter.com/user_guide/libraries/encryption.html">encryption library</a>. Basically, the encrypted string might not be the same thing every time. For example, you might want to encrypt a user&#8217;s email address. The first time you might encrypt it on a sign up form. Now on the login page, I want to compare the value the user typed in with the database. The problem is, if I encrypt the email again, it most likely will not match even though the original string is the same!</p>
<pre class="php">$this-&gt;load-&gt;library('encrypt');
$a = $this-&gt;encrypt-&gt;encode('justin');
$b = $this-&gt;encrypt-&gt;encode('justin');

echo $a == $b ? 'equals' : 'nope!'; //will print nope!</pre>
<p>Behind the scenes, CodeIgniter is basically rotating keys to produce different encrypted strings that decrypt to the same thing. It&#8217;s actually a really cool and secure way of handling the encryption, but for the purpose of comparing values (on a login form for example) it just doesn&#8217;t work.</p>
<h3>Alternatives</h3>
<p>So, if you need to do some comparisons using your encrypted data, you have a few alternatives. If you want to stick with PHP, you can make use of the <a rel="external" href="http://us2.php.net/manual/en/function.mcrypt-encrypt.php">mcrypt_encrypt</a> and <a rel="external" href="http://us2.php.net/manual/en/function.mcrypt-decrypt.php">mycrypt_decrypt</a> functions. If you want a MySQL solution, look into the encryption functions <a rel="external" href="http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html">in their manual</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/07/08/codeigniter-encryption-gotcha/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Some HTML5 links to get you started</title>
		<link>http://somethingcliche.com/2010/06/13/some-html5-links-to-get-you-started/</link>
		<comments>http://somethingcliche.com/2010/06/13/some-html5-links-to-get-you-started/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 22:01:45 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=563</guid>
		<description><![CDATA[I have finally started diving into more HTML5 lately and have some good links to help get you started. The syntax itself is somewhat new, but the hard part in my opinion is knowing what browsers support what. The easy answer seems to be Chrome 5 supports the most, followed by Safari 5, then Firefox, [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-545" title="html5" src="http://somethingcliche.com/wp-content/uploads/2010/05/html5.jpg" alt="" width="120" height="120" />I have finally started diving into more HTML5 lately and have some good links to help get you started. The syntax itself is somewhat new, but the hard part in my opinion is knowing what browsers support what. The easy answer seems to be Chrome 5 supports the most, followed by Safari 5, then Firefox, and lastly Internet Explorer 8 (with almost no support, shocking!). I have moved to Chrome as my default browser now for quite a few months since it just supports so much more of the standards than the others.</p>
<p>The new syntax and tags make a lot of sense one you get the hang of it and see the reasoning behind it. The CSS3 and JavaScript enhancements are also pretty slick. Some of things MooTools offers are now integrated as native functionality. I still plan on using MooTools to ensure cross browser support though.</p>
<p><span id="more-563"></span></p>
<h3>The Links</h3>
<p><a rel="external" href="http://apirocks.com/html5/html5.html">HTML5 Presentation</a><br />
View this page in Chrome and you&#8217;ll get a great overview of HTML5 and what it offers. I knew pieces of this stuff, but this presentation really pulled things together for me and made sense of all the various concepts. There are lots of interactive demos and code snippets for learning by example.</p>
<p><a rel="external" href="http://www.w3avenue.com/2010/05/07/html5-unleashed-tips-tricks-and-techniques/">HTML5 Unleashed: Tips, Tricks and Techniques</a><br />
This post goes into a lot of details for each component of HTML5 and they have a ton of links with more examples and background. Lots of code in this one too, which I find is a great way to understand HTML5.</p>
<p><a rel="external" href="http://html5test.com/">The HTML5 Test</a><br />
Run this in your browser of choice and see how well it stacks up with HTML5 support.</p>
<p><a rel="external" href="http://html5readiness.com/">HTML5 Readiness</a><br />
A great visual representation of all the popular browsers and what HTML5 and CSS3 features they support. I&#8217;d check the <em>fixed browser position</em> checkbox at the bottom to make things a tad more clear.</p>
<h3>More Links</h3>
<p>I add new bookmarks to my delicious quite regularly, so check that out too:<br />
<a rel="external" href="http://delicious.com/barnt/html5">http://delicious.com/barnt/html5</a></p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/06/13/some-html5-links-to-get-you-started/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 pack for Dreamweaver CS5</title>
		<link>http://somethingcliche.com/2010/05/19/html5-pack-for-dreamweaver-cs5/</link>
		<comments>http://somethingcliche.com/2010/05/19/html5-pack-for-dreamweaver-cs5/#comments</comments>
		<pubDate>Wed, 19 May 2010 21:45:16 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Dreamweaver]]></category>
		<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=549</guid>
		<description><![CDATA[Adobe has released a Dreamweaver CS5 extension that adds in support for HTML5 (including CSS3). The WebKit engine itself has been updated to support the new tags and rendering needed to work with HTML5. Live view and design view have these engine updates implement. Also remember since live view runs WebKit, any -webkit css properties [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-557" title="Dreamweaver CS5" src="http://somethingcliche.com/wp-content/uploads/2010/05/dwcs5.jpg" alt="" width="120" height="120" />Adobe has released a Dreamweaver CS5 extension that adds in support for <strong>HTML5</strong> (including <strong>CSS3</strong>). The WebKit engine itself has been updated to support the new tags and rendering needed to work with HTML5. Live view and design view have these engine updates implement. Also remember since live view runs WebKit, any <strong>-webkit</strong> css properties will render just fine. I know Dreamweaver doesn&#8217;t always produce the best code, but this extension still seems pretty cool and should be a great learning tool. Adobe also announced they will <a href="http://techcrunch.com/2010/05/19/webm-google-h-264/" rel="external">support VP8</a> (Google’s new open-source video codec) going forward in its Flash player.</p>
<p>As noted on <a rel="external" href="http://labs.adobe.com/technologies/html5pack/">Adobe Labs</a>, here is what the HTML5 pack offers:</p>
<ul>
<li>Introduces the Multiscreen Preview panel , allowing for Live View display on 3 different screen sizes, with Media Query support. (Window &gt; Multiscreen Preview)</li>
<li>Adds code hinting for the HTML5 Tag Library with new tags, attributes, and properties.</li>
<li>Updates code hinting for new attributes and values in existing HTML tags.</li>
<li>Adds code hinting for the following CSS3 specifications: 2D/3D Transformations; Animations; Background and Border; Basic User Interface; Line Layout; Marquee; Media Queries; MultiColumn; Ruby; Text; and Transitions.</li>
<li>Updates Live View to support &lt;video&gt; and &lt;audio&gt;.<em> (Requires Quicktime installation)</em></li>
<li>Improved rendering for CSS3 in Live View.</li>
<li>Adds HTML5 starter layouts to the New Document Dialog box.</li>
<li>Offers better rendering for new tags in Design View.</li>
</ul>
<p>Here is a video that explains some more. It&#8217;s a flash video though, so that is sort of an epic fail.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="575" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="FlashVars" value="fileID=6593&amp;context=64&amp;embeded=true&amp;environment=production" /><param name="src" value="http://images.tv.adobe.com/swf/player.swf" /><param name="flashvars" value="fileID=6593&amp;context=64&amp;embeded=true&amp;environment=production" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="575" height="350" src="http://images.tv.adobe.com/swf/player.swf" flashvars="fileID=6593&amp;context=64&amp;embeded=true&amp;environment=production" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Download the HTML5 pack:<br />
<a rel="external" href="http://labs.adobe.com/downloads/html5pack.html">http://labs.adobe.com/downloads/html5pack.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/05/19/html5-pack-for-dreamweaver-cs5/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Cross domain messages with postMessage</title>
		<link>http://somethingcliche.com/2010/05/12/cross-domain-messages-with-postmessage/</link>
		<comments>http://somethingcliche.com/2010/05/12/cross-domain-messages-with-postmessage/#comments</comments>
		<pubDate>Thu, 13 May 2010 00:24:00 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=527</guid>
		<description><![CDATA[There is a pretty sweet HTML5 JavaScript function called postMessage. Basically, this function can be used to send simple data (i.e. a string of text) between 2 different domains. I got this working by having an iframe embedded in my main page with the source of another website. Using postMessage, I can send and receive [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://somethingcliche.com/wp-content/uploads/2010/05/html5.jpg" alt="" title="html5" width="120" height="120" class="alignleft size-full wp-image-545" />There is a pretty sweet HTML5 JavaScript function called <strong>postMessage</strong>. Basically, this function can be used to send simple data (i.e. <em>a string of text</em>) between 2 different domains. I got this working by having an iframe embedded in my main page with the source of another website. Using <strong>postMessage</strong>, I can send and receive data from the main page and iframe even though they are different domains! Traditional methods of interacting between a page and an iframe of different domains don&#8217;t work due to security issues. It obviously wouldn&#8217;t be very safe to allow an iframe to arbitrarily call methods of the parent window without the main page&#8217;s permission.</p>
<h3>What is postMessage?</h3>
<p>The <a rel="external" href="https://developer.mozilla.org/en/DOM/window.postMessage">Mozilla developer docs</a> state it pretty well:</p>
<blockquote><p>window.postMessage is a method for safely enabling cross-origin communication. Normally, scripts on different pages are only allowed to access each other if and only if the pages which executed them are at locations with the same protocol (usually both http), port number (80 being the default for http), and host (modulo document.domain being set by both pages to the same value). window.postMessage provides a controlled mechanism to circumvent this restriction in a way which is secure when properly used.</p></blockquote>
<p>The function is called using this syntax:</p>
<pre class="js">otherWindow.postMessage(message, targetOrigin);</pre>
<ul>
<li><strong>otherWindow</strong> is a reference to a window object such as the main page or the embedded iframe</li>
<li><strong>message</strong> is a string (i.e. this could be simple text or a json object)</li>
<li><strong>targetOrigin</strong> is the url that is able to receive this message -  this can be set to * for all domains, but it is more secure to explicity set the origin</li>
</ul>
<p><span id="more-527"></span></p>
<h3>Setting up the main page</h3>
<p>Here is what the main page HTML looks like (just the main body code). Assume this page is hosted on somethingcliche.com which is our main origin. The origin is passed into the iframe PHP page so that we can easily know the origin to send the message back to.</p>
<pre class="html">&lt;iframe id="othersite" src="http://othersite.com/m.php?origin=http://somethingcliche.com"&gt;&lt;/iframe&gt;</pre>
<p>Here is the JavaScript that sets up a message listener for the main page. Once a message is received, it will alert the details.</p>
<pre class="js">var onmessage = function(e) {
  alert(e.data + ' - origin: ' + e.origin);
}

if(typeof window.addEventListener != 'undefined') {
  window.addEventListener('message', onmessage, false);
}
else if(typeof window.attachEvent != 'undefined') {
  window.attachEvent('onmessage', onmessage);
}</pre>
<h3>Setting up the iframe page</h3>
<p>This iframe page is fairly basic. On load of the page, it will use the <strong>postMessage</strong> function to send a message back to the main page. Once the main page receives the message, it will trigger its listener that we defined and alert the message.</p>
<pre class="js">window.onload = function() {
  window.parent.postMessage('from the iframe!', '&lt;?php echo $_GET['origin']; ?&gt;');
};</pre>
<h3>So, what&#8217;s the point?</h3>
<p>This is obviously a very simplified example, but this function has some pretty cool applications. I have used this technique to submit a form on the main page to the iframe (set the target on your form to the iframe&#8217;s name), have the iframe do some verification, then post a message back to the parent indicating success or failure. Some other uses include simple remote authentication, resizing the iframe based on the remote content length, and really anything where you don&#8217;t want to leave the current page but still want to interact with a remote domain staying all client side.</p>
<h3>Browser compatibility</h3>
<p>The <strong>postMessage</strong> function is available in Chrome, Safari 4, Firefox 3, and Internet Explorer 8.</p>
<h3>What about IE6 and IE7?</h3>
<p>Ah yes, what good is a pretty slick implementation without completely destroying the concept to make it work in IE6 (and in this case IE7)?</p>
<p>Since the postMessage function is not supported in IE6 and IE7, we have to code a workaround. In this case, using the hash (stuff after the # in the url) will work. The main page needs to be updated to use this JavaScript. Basically it will use postMessage if it can, otherwise it will create a polling function to look for a change in the url.</p>
<pre class="js">var onmessage = function(e) {
  alert(e.data + ' - origin: ' + e.origin);
}

if(window.postMessage) {
  if(typeof window.addEventListener != 'undefined') {
    window.addEventListener('message', onmessage, false);
  }
  else if(typeof window.attachEvent != 'undefined') {
    window.attachEvent('onmessage', onmessage);
  }
}
else {
  var _origURL = document.location.href;
  var _poller = function() {
    if(document.location.href != _origURL) {
      alert(document.location.href);
      //split on the # to get the message
      clearInterval(_pollerInterval);
    }
  }
  var _pollerInterval = setInterval(_poller, 1000);
}
</pre>
<p>The iframe url also needs an additional parameter passed to it so we can get the original url to append the hash to.</p>
<pre class="html">&lt;iframe id="othersite" src="http://othersite.com/m.php?url=http://somethingcliche.com/page.php&amp;origin=http://somethingcliche.com"&gt;&lt;/iframe&gt;</pre>
<p>The JavaScript in the iframe needs to be updated to have a similar condition.</p>
<pre class="js">window.onload = function() {
  if(window.parent.postMessage) {
    window.parent.postMessage('from the iframe!', '&lt;?php echo $_GET['origin']; ?&gt;');
  }
  else {
    window.parent.location = '&lt;?php echo $_GET['url']; ?&gt;'.replace( /#.*$/, '' ) + '#ie6sucks';
  }
};</pre>
<h3>Code cleanup</h3>
<p>The code above hopefully makes sense and illustrates the <strong>postMessage</strong> function and how you can use it. Some of the values are hard coded since it was more clear that way, so just keep in mind you should clean up the code to use dynamic values where possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/05/12/cross-domain-messages-with-postmessage/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>Get your retirement accounts in order</title>
		<link>http://somethingcliche.com/2010/04/19/get-your-retirement-accounts-in-order/</link>
		<comments>http://somethingcliche.com/2010/04/19/get-your-retirement-accounts-in-order/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 16:00:33 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[Personal Finance]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=509</guid>
		<description><![CDATA[So this is one of those posts that is not about web development, but instead focuses on personal finance. More specifically I want to talk a little about planning for your retirement. You&#8217;re likely a far ways off (I&#8217;m like 35-40 years away myself) but getting this stuff setup now will be really beneficial later [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://somethingcliche.com/wp-content/uploads/2010/04/retirement.jpg" alt="" title="Retirement FTW" width="120" height="120" class="alignleft size-full wp-image-518" />So this is one of those posts that is not about web development, but instead focuses on personal finance. More specifically I want to talk a little about <strong>planning for your retirement</strong>. You&#8217;re likely a far ways off (I&#8217;m like 35-40 years away myself) but getting this stuff setup now will be really beneficial later and you&#8217;ll be super stoked you got it taken care of.</p>
<p>Now you might be saying <em>&#8220;but I don&#8217;t have any extra money to set aside for retirement!&#8221;</em>. That is valid concern. However, as a first step you just need to get something in place. The biggest hurdle is getting something setup. Once you have your system in place, you&#8217;ll be way more likely to contribute &#8211; and once you set this up to be automatic you won&#8217;t even miss the money. You need to start early so your investment returns can pile up over the next 30 to 40 years.</p>
<p><span id="more-509"></span></p>
<h3>401k</h3>
<p>If your job offers a 401k or similar retirement plan, make sure you are enrolled! Check with your HR person if you aren&#8217;t sure and get this started. This is especially important if your company provides a match &#8211; that is basically free money they are contributing on your behalf. They will match your contributions up to a certain limit. For example, they might match the first 3% you put in yourself. So I put in 3% and they put in 3% for a total of 6% of my salary &#8211; that basically doubles my contribution and I&#8217;ve already made an insane return on my investment! Pretty sweet and there is really no excuse to not take advantage of your companies retirement benefits.</p>
<div class="myadvice"><strong>My advice:</strong> Contribute enough to get the maximum match from your company. If they they match 5%, make sure you put in enough to get the full match. It&#8217;s free money!</div>
<h3>IRA</h3>
<p>The next thing I would recommend is setting up a <strong>IRA</strong>. You contribute to a <strong>traditional IRA</strong> on a <em>pre-tax</em> basis while a <strong>Roth IRA</strong> is <em>post-tax</em>. If you want to lower your income for tax purposes, then a traditional IRA might make sense for you. When you take out the money during retirement, you will be taxed on the money. I prefer the Roth IRA myself since you pay taxes now and when you withdraw during retirement it will be tax free since you&#8217;ve already been taxed. Who knows what the tax rates will be in 30 years, I just think it makes a lot more sense to bite the bullet now and not have to worry about taxes later.</p>
<p>A Roth IRA has limits on how much you can contribute, for 2010 the limit is $5000. For more info: <a href="http://en.wikipedia.org/wiki/Roth_IRA" rel="external">http://en.wikipedia.org/wiki/Roth_IRA</a></p>
<div class="myadvice"><strong>My advice:</strong> Signup for a Roth IRA at <a href="http://vanguard.com" rel="external">Vanguard</a>, they have super low fees and are great to work with. I invest in the Target Retirement 2045 Fund (VTIVX) and have $96 per week automatically invested. That puts me at the $5000 limit I can contribute for the year.</div>
<h3>Rollover your old 401k to an IRA</h3>
<p>Employer sponsored programs such as a 401k generally have much higher fees and more limited investment options than an IRA does. This one is confusing to me, but most 401k plans can get away with saying they have no fees, but they are likely gouging you for <strong>2-3%</strong> behind the scenes! As a comparison, my Vanguard Roth IRA has just <strong>.20%</strong> of fees. </p>
<div class="myadvice"><strong>My advice:</strong> Roll over your old 401k into an IRA. This will save you tons in fees and give you a lot more flexibility. Vanguard can help get that going for you.</div>
<p>The first step is just get this stuff setup, then you can worry about how much to contribute.</p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/04/19/get-your-retirement-accounts-in-order/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MooTools selectors using $$()</title>
		<link>http://somethingcliche.com/2010/04/13/mootools-selectors-using/</link>
		<comments>http://somethingcliche.com/2010/04/13/mootools-selectors-using/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 16:00:02 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=494</guid>
		<description><![CDATA[MooTools core has a bundled method $$() &#8211; also referred to as dollars &#8211; that selects and extends DOM elements. This is a very powerful function and will allow you to select 1 or more DOM elements using some pretty clever tricks. When you call $$(), it will return an array of all the elements [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://somethingcliche.com/wp-content/uploads/2010/04/mootools_selectors.jpg" alt="" title="MooTools selectors" width="120" height="120" class="alignleft size-full wp-image-500" />MooTools core has a bundled method <strong>$$()</strong> &#8211; also referred to as <em>dollars</em> &#8211; that selects and extends DOM elements. This is a very powerful function and will allow you to select 1 or more DOM elements using some pretty clever tricks.</p>
<p>When you call <strong>$$()</strong>, it will return an array of all the elements found matching your criteria. In addition to some CSS3 selectors you might have already seen, MooTools implements some custom ones that are very helpful as well.</p>
<p><strong>Note:</strong> even if it only finds a single element, <strong>$$()</strong> will return an array.</p>
<p><span id="more-494"></span></p>
<h3>Simple Usage</h3>
<p>Simple uses cases include specifying a tag name, an elements id, or an element reference. You can comma separate the argument list to have the method search for multiple things. Here are some examples:</p>
<pre class="js">//returns all anchor elements in the page
$$('a');

//returns all anchor and bold tags on the page
$$('a', 'b'); 

//returns an array containing only the element with the id 'myElement'
$$('#myElement');

//returns an array of all anchor tags with the class 'myClass'
//within the DOM element with id 'myElement'
$$('#myElement a.myClass');

//creates an array of all elements and selectors passed as arguments
$$(myelement1, myelement2, 'a', '#myid, #myid2, #myid3');</pre>
<h3>Advanced Selectors</h3>
<p>Now this is where you can really do some cool stuff. If you combine $$() with the built in Selector support in MooTools, you can build an array of the exact DOM elements you want. Check out these example:</p>
<pre class="js">//returns all mailto links
$$('a[href^=mailto:]');

//returns all text fields
$$('input[type=text]');

//return all elements that are checked within #form
$$('#form input:checked');

//returns all paragraphs with my name
$$('p:contains("Justin")');

//all input fields except buttons
$$('input:not([type="submit"])');

//set external links
$$('a[rel=external]').set('target', '_blank');

//get all even table rows for #table
$$('#table td:even');</pre>
<p>Here is a cool example that will allow you to <strong>zebra</strong> stripe a table. This assumes classes are defined called <strong>even</strong> and <strong>odd</strong>.</p>
<pre class="js">$$('table &gt; tr:even').addClass('even');
$$('table &gt; tr:odd').addClass('odd');
</pre>
<h3>Linkage</h3>
<p>As you can see from the above examples, selectors are pretty awesome and give you ultimate power over the DOM. If you come up with some crazy selectors, please leave a comment! For more info on Selectors, check out these links:</p>
<p><a href="http://mootools.net/docs/core/Utilities/Selectors" target="_blank">http://mootools.net/docs/core/Utilities/Selectors</a><br />
<a href="http://www.clientcide.com/code-snippets/manipulating-the-dom/selector-sugar-for-mootools/" target="_blank">http://www.clientcide.com/code-snippets/manipulating-the-dom/selector-sugar-for-mootools/<a><br />
<a href="http://mootools.net/blog/2007/06/11/selectors-on-fire-a-tale-of-pseudoselectors/" target="_blank">http://mootools.net/blog/2007/06/11/selectors-on-fire-a-tale-of-pseudoselectors/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/04/13/mootools-selectors-using/feed/</wfw:commentRss>
		<slash:comments>108</slash:comments>
		</item>
		<item>
		<title>CSS !important keyword</title>
		<link>http://somethingcliche.com/2010/03/30/css-important-keyword/</link>
		<comments>http://somethingcliche.com/2010/03/30/css-important-keyword/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 02:13:13 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=485</guid>
		<description><![CDATA[CSS by nature is cascading and will apply or overwrite styles as it reads top down through any CSS rules you have declared. For example, if you declare something at the top of your CSS and then declare it again later, the last declaration will take precedence. In most cases this is fine, but you [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://somethingcliche.com/wp-content/uploads/2010/03/css_important.png" alt="" title="CSS !important" width="120" height="120" class="alignleft size-full wp-image-491" />CSS by nature is cascading and will apply or overwrite styles as it reads top down through any CSS rules you have declared. For example, if you declare something at the top of your CSS and then declare it again later, the last declaration will take precedence. In most cases this is fine, but you might want to force a CSS rule to be applied no matter where it is located in the CSS. That&#8217;s where <strong>!important</strong> comes into play. If you add <strong>!important</strong> after any of your CSS rules, it will become the highest priority.</p>
<p>Here are a few examples to illustrate it better. This first example has 2 normal CSS rules, the 2nd rule will take precedence and the div will have a blue background.</p>
<pre class="css">div {
  background-color: yellow;
}
div {
  background-color: blue;
}</pre>
<p>However, if we apply the <strong>!important</strong> keyword to the first rule, the div will have a yellow background.</p>
<pre class="css">div {
  background-color: yellow !important;
}
div {
  background-color: blue;
}</pre>
<h3>Everyone&#8217;s favorite browser</h3>
<p>Ah yes, what would a CSS tip be without stating the obvious that Internet Explorer sucks and won&#8217;t necessarily work as intended. IE6 will not respect the <strong>!important</strong> keyword and will just use the standard top down technique when applying the CSS. IE7 and above seem to work ok as long as you use a <strong>doctype</strong> (which you always do, right?!).</p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/03/30/css-important-keyword/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>Getting started with MooTools – Part 2</title>
		<link>http://somethingcliche.com/2010/03/17/getting-started-with-mootools-%e2%80%93-part-2/</link>
		<comments>http://somethingcliche.com/2010/03/17/getting-started-with-mootools-%e2%80%93-part-2/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 16:20:31 +0000</pubDate>
		<dc:creator>justin</dc:creator>
				<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://somethingcliche.com/?p=472</guid>
		<description><![CDATA[This post is the second in a series about getting started with MooTools. Part 1 can be found here. Part 2 of this series on getting started with MooTools provides some more comparisons between vanilla JavaScript and MooTools. The most striking example is the Ajax, just check out how much of a mess traditional JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-434" title="Getting started with MooTools" src="http://somethingcliche.com/wp-content/uploads/2010/03/mootools_gettingstarted.jpg" alt="" width="120" height="120" /><em>This post is the <strong>second</strong> in a series about getting started with <a href="/category/mootools/">MooTools</a>.<br />
Part 1 can be found <a href="/2010/03/09/getting-started-with-mootools-part-1/">here</a>.</em></p>
<p>Part 2 of this series on getting started with MooTools provides some more comparisons between vanilla JavaScript and MooTools. The most striking example is the Ajax, just check out how much of a mess traditional JavaScript is!</p>
<p>Hopefully these examples are illustrating the benefits of using a JavaScript framework and the immense time and effort it can save you in addition to the excellent browser compatibility. Post a comment on what specific MooTools concepts you would like me to focus on for future posts.</p>
<p><span id="more-472"></span></p>
<h3>Ajax</h3>
<h4>JavaScript</h4>
<pre class="js">var xhr = false;
try {
  //Firefox, Opera 8.0+, Safari
  xhr = new XMLHttpRequest();
}
catch(e) {
  //Internet Explorer
  try {
    xhr = new ActiveXObject('Msxml2.XMLHTTP');
  }
  catch(e) {
    try {
      xhr = new ActiveXObject('Microsoft.XMLHTTP');
    }
    catch(e) {
      alert('epic fail!');
    }
  }
}

if(xhr) {
  //onSuccess
  xhr.onreadystatechange = function() {
    if(xhr.readyState == 4 &amp;&amp; xhr.responseText != '') {
      //use responseText
    }
  }

  //open connection
  xhr.open('GET', 'ajax.php?id=1', true);
  xhr.send(null);
}</pre>
<h4>MooTools</h4>
<pre class="js">var xhr = new Request({
  method: 'get',
  url: 'ajax.php',
  onSuccess: function(responseText, responseXML) {
    //use responseText
  }
}).send('id=1');</pre>
<p>Yeah, MooTools is just a tad easier to write Ajax with <img src='http://somethingcliche.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  With traditional JavaScript, the top chunk is just initializing the Ajax object. Modern browsers use <strong>XMLHttpRequest()</strong>, but we need fallback cases to handle old version of Internet Explorer, this the try/catch stuff. It then needs to create a ready state function &#8211; 4 means it was successful. So not the most user friendly JavaScript out there.</p>
<p>MooTools on the other hand is way more straightforward since it handles all the browser issues and abstracts the ready states for us. Check out the <a href="http://mootools.net/docs/core/Request/Request" target="_blank">documentation</a> for the full run down on what you can do with the Request object.</p>
<h3>String manipulations</h3>
<h4>JavaScript</h4>
<pre class="js">var s = 'Jeff Winger';

//does it contain the substring?
if(s.indexOf('Jeff') &gt;= 0) {
  //--
}

//trim whitespace
s = s.replace(/^\s+|\s+$/g, '');

//convert to int
var i = parseInt('10px');

//convert to float
var f = parseFloat('1.2em');</pre>
<h4>MooTools</h4>
<pre class="js">var s = 'Jeff Winger';

//does it contain the substring?
if(s.contains('Jeff')) {
 //--
}

//trim whitespace
s = s.trim();

//convert to int
var i = '10px'.toInt();

//convert to float
var f = '1.2em'.toFloat();</pre>
<p>Nothing too crazy here, but MooTools streamlines the string manipulations and helps avoid needed regular expressions.</p>
<h3>Embedding a Flash SWF</h3>
<h4>JavaScript (actually its HTML)</h4>
<pre class="html">&lt;object width="500" height="400" data="myMovies.swf" type="application/x-shockwave-flash" id="Swiff_1268810590492"&gt;
 &lt;param name="mode" value="opaque"&gt;
 &lt;param name="bicolor" value="#ff3300"&gt;
&lt;/object&gt;</pre>
<h4>MooTools</h4>
<pre class="js">var obj = new Swiff('myMovie.swf', {
  id: 'myBeautifulMovie',
  width: 500,
  height: 400,
  params: {
    wmode: 'opaque',
    bgcolor: '#ff3300'
  }
});
</pre>
<p>The <strong>Swiff</strong> class abstracts the traditional object tag and streamlines the code. This way you don&#8217;t need to remember the exact structure of the object tag because no ones remembers that stuff and just end up copying it from somewhere else and changing the values to what we need.</p>
<h3>Onwards and upwards</h3>
<p>This completes part 2 of the MooTools getting started guide. There might be a part 3 sometime, but before that I&#8217;ll likely delve into specific MooTools topics in more detail.</p>
]]></content:encoded>
			<wfw:commentRss>http://somethingcliche.com/2010/03/17/getting-started-with-mootools-%e2%80%93-part-2/feed/</wfw:commentRss>
		<slash:comments>34</slash:comments>
		</item>
	</channel>
</rss>

