<?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>Napolitopia.com &#187; Code Bin</title>
	<atom:link href="http://www.napolitopia.com/category/code-bin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.napolitopia.com</link>
	<description>Someday Came Suddenly</description>
	<lastBuildDate>Fri, 23 Dec 2011 14:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Holy Crap!</title>
		<link>http://www.napolitopia.com/2011/12/holy-crap/</link>
		<comments>http://www.napolitopia.com/2011/12/holy-crap/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 14:44:54 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=70</guid>
		<description><![CDATA[So I took a look at my blog this morning and realized that I haven&#8217;t written a single post since December 2010&#8230; Thats a whole year! What a waste for such a perfectly awesome blog! So much has been happening in my life that I just haven&#8217;t had time, but I promise now to be [...]]]></description>
			<content:encoded><![CDATA[<p>So I took a look at my blog this morning and realized that I haven&#8217;t written a single post since December 2010&#8230; Thats a whole year! What a waste for such a perfectly awesome blog! So much has been happening in my life that I just haven&#8217;t had time, but I promise now to be more on top of it.</p>
<p>So whats been happening? Well the most important change is that I have made a career transition to work for <a title="AOL" href="http://www.aol.com" target="_blank">AOL</a> in NY. I&#8217;ve taken a step back from leadership to start working on ground breaking social implementations at the <a title="Huffington Post" href="http://www.huffingtonpost.com" target="_blank">Huffington Post </a>(a now AOL company). Im currently leading social development and have launched some really cool things like the <a title="Huffington Post Facebook App" href="http://apps.facebook.com/huffpost/" target="_blank">Huffington Post Facebook App</a>.</p>
<p>I continue to work closely with the Facebook and Twitter engineers on some really cool and exciting stuff. I am extremely happy and proud to be employed by AOL. They are the single best company I have ever worked for and I look forward to being there for a long time.</p>
<p>I also recently released a new wordpress plugin on <a title="CodeCanyon" href="http://codecanyon.net/?ref=eightamrock" target="_blank">CodeCanyon.net</a>. <a title="WPToWord Plugin" href="http://codecanyon.net/item/wptoword-wordpress-to-word-doc-plugin/508046?ref=eightamrock" target="_blank">WPToWord</a> is a content export tool that takes your posts or pages and exports them to a downloadable word document. A lot of writers have found it really useful and I continue to develop on it.</p>
<p>In October I spoke at <a title="WordCamp Boston" href="http://2011.boston.wordcamp.org/speakers/#sam-napolitano" target="_blank">WordCamp Boston</a> about user management, and in November I spoke at <a title="WordCamp Philly" href="http://2011.philly.wordcamp.org/speakers/#sam-napolitano" target="_blank">WordCamp Philly</a> about HTML5. Its been a really great experience speaking at these conference and I really look forward to doing more of them. <a title="WordPress" href="http://wordpress.org/news/2011/12/sonny/" target="_blank">WordPress 3.3 (Sonny)</a> was release this month, I was also named in the credits having done some bug fixes for some multisite functions.</p>
<p>I moved and sadly I no longer have my recording studio :( but I am trying to fill the void with really awesome development work. Look forward to some really cool stuff coming this  year.</p>
<p>Merry Christmas and Happy Holidays!</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Holy+Crap%21+http%3A%2F%2Fwww.napolitopia.com%2F2011%2F12%2Fholy-crap%2F" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Holy+Crap%21+http%3A%2F%2Fwww.napolitopia.com%2F2011%2F12%2Fholy-crap%2F" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2011/12/holy-crap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top 10 Web Development Faux Pas</title>
		<link>http://www.napolitopia.com/2010/12/top-10-web-development-faux-pas/</link>
		<comments>http://www.napolitopia.com/2010/12/top-10-web-development-faux-pas/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 20:36:28 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=65</guid>
		<description><![CDATA[We have all been there... just starting out and don't know any better or trying to get a quick hack in to fix a site that just went live.... these are situations that many of us have faced and done the unthinkable, we commit a web development faux pa. It's scarily more common than not so hopefully this article will help bring salvation to all those web sinners out there. Without further ado I present the Top 10 Web Development Faux Pas to avoid while building or maintaining websites. ]]></description>
			<content:encoded><![CDATA[<p>We have all been there&#8230; just starting out and don&#8217;t know any better or trying to get a quick hack in to fix a site that just went live&#8230;. these are situations that many of us have faced and done the unthinkable, we commit a web development faux pa. It&#8217;s scarily more common than not so hopefully this article will help bring salvation to all those web sinners out there. Without further ado I present the Top 10 Web Development Faux Pas to avoid while building or maintaining websites. </p>
<p><span id="more-65"></span></p>
<h3>Number 10: Using tables to layout a site design.</h3>
<p>While this practice is slowly going the way of the dodo, I feel that for continuity it has to have a place on this list. So coming in at number 10, please please please don&#8217;t ever use tables to layout a site design. Do it right, do it wrong, but do it with elements.</p>
<h3>Number 9: iFrames</h3>
<p>There is a time and a place for everything, it will rarely ever be the time or place for an iFrame. Web apps are about the ONLY place I have ever seen an iFrame used properly&#8230; So if your not developing web apps for Google or Apple, leave this  element at the curb with the rest of the trash.</p>
<h3>Number 8: Using Images for Text</h3>
<p>For the vast majority of basement web designers doing this for the first time, it is extremely common to pitch a site with an unsupported font for a header or body content. Come development time you realize that you can&#8217;t put that font in real text and your client absolutely loved it! In fact it&#8217;s so unique they&#8217;d never seen a site do that before (for a reason), you&#8217;re a hero! We&#8217;ll guess what ::fail::&#8230; now you have to put all that great content in an image and none of the engines will ever get to read it.. Stay away from this mistake, learn the difference between a web safe font and a non-web safe font. If you still really need to go that extra mile, check out one of the terrific font serving services like <a href="http://typekit.com" target="_blank">typekit.com</a> or <a href="http://fonts.com" target="_blank">fonts.com</a>.</p>
<h3>Number 7: Flash Based Websites</h3>
<p>Wow, that people are still doing this is amazing to me. It has always been my opinion that Flash should be used to enhance a site not build one. If you find your self in the Flash application for more the 5% of your total development allotment you are probably doing something wrong. Pay attention to the industry, when the leading edge computer company is not shipping ANY of it&#8217;s devices with flash support&#8230;. then something is changing. Tell your clients that all that moving and shaking is great&#8230;as long as they don&#8217;t care if no one ever see&#8217;s it.</p>
<h3>Number 6: Unnecessary Scrolling (of ANYTHING)</h3>
<p>When I load a site in my 19&#8243; monitor I should NEVER see a horizontal scroll bar, especially when it just scrolls dead space caused by an over abundance of empty &lt;p&gt; tags or non-breaking spaces &amp;nbsp;</p>
<h3>Number 5: Using &amp;nbsp; To Align Elements</h3>
<p>Number 6 leads us nicely into number 5, never ever ever use &#8216;&amp;nbsp;&#8217; to align elements. We have such great tools in CSS that add no weight to the web page, why would you resort to the unpredictability of spaces. Margin, padding, line-height, word-spacing, text-align and letter-spacing are all proper ways to space your content.</p>
<h3>Number 4: Optimizing for One Browser</h3>
<p>Get off your highhorse, people use IE and people use Firefox, Safari, Opera and Chrome. Saying that you won&#8217;t support or gracefully degrade your site for browsers other than your favorite is just cocky and ridiculous. Clients like their sites to be viewed, that&#8217;s why they are paying you to make them viewable. Is it really that big of a deal to spend 15 minutes creating an IE only style sheet that removes all of your rounded corners and drop shadows that you&#8217;ve probably overused anyway?</p>
<h3>Number 3: Declaring CSS or JS inline or on page.</h3>
<p>This is great for a one page site, but when you want to change the font across your ecommerce store, this practice becomes quite a big headache. Not to  mention that all the extra weight your adding to your HTML page by typing those long strings of styling in your element property tags.</p>
<p>The same is said for Javascript&#8230; a little hint most engines cut off reading your site after the first 5-600 characters of CODE, not CONTENT. Filling the entire &lt;head&gt; with JS eats up all this space. Not that you should be putting JS in the &lt;head&gt; of your doc anyway it should really go at the bottom.</p>
<p>Either way, keep your styles and JS in separate external files, its just the right thing to do&#8230;. unless you want kittens to die.</p>
<h3>Number 2: Terminating lines of code JS or CSS</h3>
<p>I see this as the web developers tripwire. Leave a line of code un-terminated and sit back and watch as the next developer struggles to figure out why his code is breaking as you snicker in amusement. Terminate your lines&#8230; leaving off that last semi-colon does not make you cool nor does it save anything when it comes to page load therefore making it a pointless and irritating habit.</p>
<h3>Number 1: Using 3 different JS Frameworks on the same page</h3>
<p>I like to call this a side affect of GCP or Google Copy Paste. Too many front end developers go out and search Google for the needed slide show, fading UL, or form validation scripts and end up compiling 3 or 4 different Javascript frameworks on a single page. This then escalates into conflicts in the code, endless hours of trolling forums for help and overall a page that is so heavy it could crush a Volkswagon. Learn one library and stick to it, if you don&#8217;t have the patience or technical expertise to learn Javascript then at least stick to solutions that all use the same framework making it easier for people to help you when you are trying to figure out why nothing is rotating, sliding or fading.</p>
<h3>Runners Up: A few practices that make honorable mention&#8230;.</h3>
<p>A. <strong>Empty property tags:</strong> if your going to leave them empty, why bother putting them in at all?<br />
B. <strong>Negative Margins: </strong>Although there are a few good tutorials that show you how to achieve results from difficult designs using these, try seeing if you can change the design first<br />
C. <strong>Non-repeating Backgrounds: </strong>It&#8217;s great that the 1280&#215;1024 picture of your cat fits perfectly in your browser window, but when I view it on my 1650&#215;1040 resolution, the added white space looks really unprofessional. Not that I would like your site anyway if a cat is your background image&#8230;. #justsayin</p>
<p>Well that concludes my list of the top 10 (or 13) web development faux-pas. Go forward and be well knowing that someone out there is meticulous judging you and your work while snickering behind your back.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Top+10+Web+Development+Faux+Pas+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F12%2Ftop-10-web-development-faux-pas%2F" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Top+10+Web+Development+Faux+Pas+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F12%2Ftop-10-web-development-faux-pas%2F" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/12/top-10-web-development-faux-pas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My First Approved Script on CodeCanyon.net</title>
		<link>http://www.napolitopia.com/2010/09/my-first-approved-script-on-codecanyon-net/</link>
		<comments>http://www.napolitopia.com/2010/09/my-first-approved-script-on-codecanyon-net/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 15:25:23 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=61</guid>
		<description><![CDATA[So a few months ago, the Envato network put out a call to all HTML5 developers to help them fill out their new HTML5 category on CodeCanyon.net. I decided to convert one of my existing drop down menu scripts to an HTML5 powerhouse that used some new entities and CSS3 properties. ]]></description>
			<content:encoded><![CDATA[<p><a href="http://bit.ly/azEuE7"><img class="alignnone size-large wp-image-63" title="Drop-o-matic" src="http://www.napolitopia.com/wp-content/uploads/2010/09/thumbnail-530x269.png" alt="My HTML5 Drop Menu System" width="530" height="269" /></a></p>
<p>So a few months ago, the <a href="http://envato.com/" target="_blank">Envato network</a> put out a call to all HTML5 developers to help them fill out their new HTML5 category on <a href="http://codecanyon.net?ref=eightamrock" target="_blank">CodeCanyon.net</a>. I decided to convert one of my existing drop down menu scripts to an HTML5 powerhouse that used some new entities and CSS3 properties.</p>
<p>After one simple revision my HTML5, CSS3 and Javascript drop menu system was approved for sale. <a href="http://bit.ly/azEuE7" target="_blank">Check it out here! </a></p>
<p><span id="more-61"></span>I have to give mad props to the guys over at <a href="http://envato.com/" target="_blank">Envato</a>, especially <a href="http://jeffrey-way.com/" target="_blank">Jeffrey Way</a>. These guys take a lot of pride in their work and ensure that all the code that gets submitted to their site is thoroughly reviewed and is top notch.</p>
<p>Thanks Guys, I plan to post a lot more snippets now that I am comfortable with the process!!!</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+My+First+Approved+Script+on+CodeCanyon.net+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F09%2Fmy-first-approved-script-on-codecanyon-net%2F" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+My+First+Approved+Script+on+CodeCanyon.net+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F09%2Fmy-first-approved-script-on-codecanyon-net%2F" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/09/my-first-approved-script-on-codecanyon-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Validation Is Important,&#8230; After All</title>
		<link>http://www.napolitopia.com/2010/07/why-validation-is-important-after-all/</link>
		<comments>http://www.napolitopia.com/2010/07/why-validation-is-important-after-all/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 16:35:03 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=57</guid>
		<description><![CDATA[HTML and CSS Validation has been the center of an intense debate for years; some web developers believe that validation is pointless since many of the specs change on various DOCTYPE&#8217;s and DTD&#8217;s, while others believe that your website is not truly valid and accessible unless you are in 100% compliance with whatever DOCTYPE you [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.napolitopia.com&amp;charset=%28detect+automatically%29&amp;doctype=Inline&amp;group=0"><img class="alignnone" title="Validation Success" src="http://grab.by/5BVd" alt="Validate it" width="516" /></a></p>
<p>HTML  and CSS Validation has been the center of an intense debate for years;  some web developers believe that validation is pointless since many of  the specs change on various DOCTYPE&#8217;s and DTD&#8217;s, while others believe  that your website is not truly valid and accessible unless you are in  100% compliance with whatever DOCTYPE you use. I will not begin to  pretend that I can fairly and accurately mitigate both sides of this  argument, what I want to do is take a look at it from a different  perspective.</p>
<p><span id="more-57"></span></p>
<p>About 10 years ago while I was attending a small  technical college in New Jersey, I began freelancing web design. At that  time standards were pretty low, and there hadn&#8217;t been too many  companies or individuals doing it as a business. As a result, pricing  was erratic often ending up only at &#8220;well it works and the client likes  it so how much can I milk them for!&#8221;. Without today&#8217;s convenience of  jQuery or Prototype and certainly very few frameworks, almost everything  was from scratch. You never really knew how long it was going to take  you to complete a job.</p>
<p>Shortly after the big internet boom and the collapse  of the job market, the community of web designers and developers was  flooded with what I like to call &#8216;myspace coders&#8217; and overseas  application developers who all considered themselves to be top notch  when it came to markup and the development of websites. Individuals who  could change the CSS on their Myspace page started applying for entry  level jobs at large corporations, setting a new curve of salaries that  we are still fighting today. What made things worse, is that companies  were still trying to figure out the web and had no idea who to hire to  help them do it.</p>
<p>Resume&#8217;s started to read every keyword under the  sun&#8230; IE( EXPERT AT PHP, RUBY, ASP, XML, XHTML, JSP, JAVASCRIPT, HTML,  CSS, PHOTOSHOP, DREAMWEAVER, PYTHON, PERL, C++).. etc. As a hiring  manager for an agency I will tell you that the first thing I do is throw  these resumes away. I know that when this person comes in, you can ask  them to code something in any of these languages and the response will  be &#8216;<em>I can try but I am rusty</em>&#8216; or &#8216;<em>I have modified it, but not from scratch</em>&#8216;.  Alas, most companies don&#8217;t test people and will just hire you based on  what you say you know. So the infiltration was a success.</p>
<p>So what does all this angry rambling mean, at first I  viewed this as what would be the death of the real web developer. Real  developers like myself would get frustrated and give up, while these  half time hero&#8217;s would slowly creep in and take over the industry  producing nothing more than poorly modified templates from some  outsourced vendor. Even &#8216;my neighbors 15 year old son&#8217; was in on the  action building websites for the price of a new skateboard.</p>
<p>As we begin to move into what I like to call the  golden age of the web, we have an opportunity to flush the market and  rid the community of these impostors. With the sudden interest in and  finite definition of web standards, along with the growing community of  industry idols like Eric Meyer, Jeremy Keith, Jeff Way, and Jeffery  Zeldman, we now have the tools to solidify our future and the industry.</p>
<p>This all brings me to my point, Validation!  Validation gives us a baseline for the quality of our medium. Validation  can help us filter out the impostors and quantify our costs to deliver.  A successfully marked up and validated piece of code can not be argued  or refuted. It is industry standard and is something that we should all  be taking advantage of. This can be the first step to reclaiming the  business that should belong to those that have the necessary training  and education to properly build a web presence. I know validation is  heavily debated, but I think it stands to reason that there are many  ways to build the same site, and as long as it validates its safe to say  it was done correctly.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Why+Validation+Is+Important%2C%E2%80%A6+After+All+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F07%2Fwhy-validation-is-important-after-all%2F" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Why+Validation+Is+Important%2C%E2%80%A6+After+All+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F07%2Fwhy-validation-is-important-after-all%2F" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/07/why-validation-is-important-after-all/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting an &#8216;Active&#8217; Class for Dynamic Navigations in WordPress</title>
		<link>http://www.napolitopia.com/2010/05/setting-an-active-class-for-dynamic-navigations-in-wordpress/</link>
		<comments>http://www.napolitopia.com/2010/05/setting-an-active-class-for-dynamic-navigations-in-wordpress/#comments</comments>
		<pubDate>Sun, 09 May 2010 22:01:50 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=55</guid>
		<description><![CDATA[I recently got a project that required a really dynamic navigation.  The client wanted the ability to add and remove pages at will with no interaction from a developer. This is generally a pretty simple request, but the client has a very specific set of style guidelines. Here is a php function that I wrote [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got a project that required a really dynamic navigation.  The client wanted the ability to add and remove pages at will with no interaction from a developer. This is generally a pretty simple request, but the client has a very specific set of style guidelines. Here is a php function that I wrote to do the job.</p>
<p><span id="more-55"></span></p>
<p>This script is intended for people who already know about themes in wordpress, and kn0w how to use the &#8216;functions.php&#8217; file.</p>
<p>Its pretty simple. First you have to globalize the &#8216;posts&#8217; variable within the function or <a href="http://codex.wordpress.org/Function_Reference/get_pages" target="_blank">get_pages()</a> wont work. There are number of params you can pass to get_pages() however I only really need to use 3. The first is what pages to exclude. I pass this in via the template files. I am only doing this because I need to exclude a particular custom page from all the navigations on the site.</p>
<p>Lets take a look at the others..</p>
<pre class="brush:php">$pages = get_pages("exclude=$exclude&amp;parent=0&amp;child_of=0&amp;sort_column=menu_order");
</pre>
<p>In order to only display the top level pages of my site, I am passing in parent=0, this means top level, and child_of = 0, this means no children of the parent page. So now I am free to add a bunch of sub pages and know that they wont automatically blow up our custom nav, but top level pages will be added.</p>
<p>The next item is sort_column=menu_order&#8230; just a side note, these variable are passed like a query string so always remember to use your ampersands :) The sort_column has a few options, I manually manage the page order in the WP CMS, thats what I am using.</p>
<p>Here is the rest of the function.</p>
<pre class="brush:php">	function active_nav($exclude){
 global $post;
 $pages = get_pages("exclude=$exclude&amp;parent=0&amp;child_of=0&amp;sort_column=menu_order");
 foreach ($pages as $row) {
 if(is_page($row-&gt;ID)){
 echo "&lt;li&gt;&lt;a href=\"".get_page_link($row-&gt;ID)."\" class=\"current\"&gt;".$row-&gt;post_title."&lt;/a&gt;&lt;/li&gt;";
 }else{
 echo "&lt;li&gt;&lt;a href=\"".get_page_link($row-&gt;ID)."\"&gt;".$row-&gt;post_title."&lt;/a&gt;&lt;/li&gt;";
 }
 }

 }
</pre>
<p>Its pretty simple, it just checks what the current page is, then applies a class 0f &#8220;current&#8221; to that navigation item, giving us a custom active class.</p>
<p>Now all you do is call the class in the theme files like so:</p>
<pre class="brush:html">&lt;div id="nav"&gt;
 &lt;ul&gt;                                   
 &lt;?php 

 active_nav(your_page_id_int);

 ?&gt;
 &lt;/ul&gt;
 &lt;/div&gt;</pre>
<p><a href="http://github.com/eightamrock/WordPress-Active-Class-Navigation" target="_blank">Here is a link to my github with this script. </a></p>
<p>Cheers</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Setting+an+%E2%80%98Active%E2%80%99+Class+for+Dynamic+Navigations+in+WordPress+http%3A%2F%2Ftinyurl.com%2F39le9g8" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Setting+an+%E2%80%98Active%E2%80%99+Class+for+Dynamic+Navigations+in+WordPress+http%3A%2F%2Ftinyurl.com%2F39le9g8" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/05/setting-an-active-class-for-dynamic-navigations-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Self Clearing Input Fields With Javascript and Prototype</title>
		<link>http://www.napolitopia.com/2010/04/self-clearing-input-fields-with-javascript-and-prototype/</link>
		<comments>http://www.napolitopia.com/2010/04/self-clearing-input-fields-with-javascript-and-prototype/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 16:59:43 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=53</guid>
		<description><![CDATA[I wrote this little script to just create some self clearing input fields. Its pretty simple but it does the job.]]></description>
			<content:encoded><![CDATA[<p>I wrote this little script to just create some self clearing input fields. Its pretty simple but it does the job.</p>
<p><span id="more-53"></span></p>
<p><strong>Updated: </strong>A new version of this script can be found on my GitHub Account&#8230; its much sleeker and requires nothing to be put on the input fields. <a href="http://github.com/eightamrock/Self-Clearing-Inputs" target="_blank">Heres a link to my new self clearing input script</a></p>
<p>First you have the js</p>
<pre class="brush:js">//This can go in the main js or whatever...
function clearInput(staticValue, id){
	if($(id).value == staticValue){
		$(id).value = '';
		$(id).observe('blur', function(){
			if($(id).value == ''){
				$(id).value = staticValue;
			}
		});
	}
}
</pre>
<p>Just make sure you download and include prototype.</p>
<p>Here is a sample of the html!</p>
<p>Each Input field must have a unique ID for this to work. 	The first argument in the clearInput() function is the static value of the input field.</p>
<pre class="brush:html">
<input id="footest1" name="test" type="text" value="foo bar" />
</pre>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Self+Clearing+Input+Fields+With+Javascript+and+Prototype+http%3A%2F%2Ftinyurl.com%2F38moono" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Self+Clearing+Input+Fields+With+Javascript+and+Prototype+http%3A%2F%2Ftinyurl.com%2F38moono" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/04/self-clearing-input-fields-with-javascript-and-prototype/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Last Tweet &#8211; A PHP Twitter Class</title>
		<link>http://www.napolitopia.com/2010/04/last-tweet-a-php-twitter-class/</link>
		<comments>http://www.napolitopia.com/2010/04/last-tweet-a-php-twitter-class/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 17:52:47 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=51</guid>
		<description><![CDATA[Sometimes doing something simple should be just that, simple. Thanks to Twitters excellent restful API, I am easily able to grab my last tweet plus some bonus data about my account and display it on my website. So Here it is, simple and clean.]]></description>
			<content:encoded><![CDATA[<p>Sometimes doing something simple should be just that, simple. Thanks to <a href="http://apiwiki.twitter.com/" target="_blank">Twitters excellent restful API</a>, I am easily able to grab my last tweet plus some bonus data about my account and display it on my website. So Here it is, simple and clean.</p>
<p><span id="more-51"></span></p>
<p>First we have the PHP class file:</p>
<pre class="brush:php">class last_tweet{

// The Base URL to Use
protected $base_url = "http://twitter.com/";

// Grab the URL
protected function get_url($uri)
{
// Start the cURL Connection
$connection = curl_init();

// Set Options
curl_setopt($connection, CURLOPT_HEADER, 1);
curl_setopt($connection, CURLOPT_RETURNTRANSFER,1);

// Set the URL to Grab
$fetch_url = $this-&gt;base_url . $uri;
curl_setopt($connection, CURLOPT_URL, $fetch_url);

// Get the Page
$page = curl_exec($connection);

// Close the Connection
curl_close($connection);

return $page;
}

// Parses the XML
protected function parse_xml($xml_string)
{
$xml_string = strstr($xml_string, 'get_url($api_call);
$xml = $this-&gt;parse_xml($page);

// Return the XML Object
return $xml;
}

public function show_tweet($username, $num)
{
// Grab the tweet
$tweet = $this-&gt;get_tweet($username, $num);

//all your display code can go here if you want, Im just returning the array from the simplexmlelement

return $tweet;
}

}
</pre>
<p>Its pretty simple, nice number of functions to set the cURL transfer, send the request to twitter and return the XML. So the next step is just instantiating the class and doing something with the data from twitter:</p>
<pre class="brush:php">include_once('class.last_tweet.php');

//instantiate
$last_tweet = new last_tweet;

//Your Username
$username = 'Your Username';

// number of tweets returned, can be as many as you like. I think twitter limits at 200
$num = '1';

// Grab the Tweet XML
$tweet = $last_tweet-&gt;get_tweet($username, $num);
</pre>
<p>Here I just spit it out on an empty HTML page. You can decided how you want to disseminate the data.</p>
<pre class="brush:php">print_r($tweet);
</pre>
<p>Thats it, get your last tweet info from twitter. Use it wisely, twitter only allows 100 calls an hour to the restful API.</p>
<p>Here is the source code: <a href="http://github.com/eightamrock/Last-Tweet" target="_blank">Last Tweet PHP Class</a></p>
<p>Cheers!</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Last+Tweet+%E2%80%93+A+PHP+Twitter+Class+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F04%2Flast-tweet-a-php-twitter-class%2F" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Last+Tweet+%E2%80%93+A+PHP+Twitter+Class+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F04%2Flast-tweet-a-php-twitter-class%2F" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/04/last-tweet-a-php-twitter-class/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LSCOLORS in OSX Snow Leopard, For Dummies</title>
		<link>http://www.napolitopia.com/2010/03/lscolors-in-osx-snow-leopard-for-dummies/</link>
		<comments>http://www.napolitopia.com/2010/03/lscolors-in-osx-snow-leopard-for-dummies/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 19:23:41 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>
		<category><![CDATA[Unix Pie]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=49</guid>
		<description><![CDATA[So after cruising the web for a few hours trying to find &#8216;dummy&#8217; style documentation on changing colors in terminal using .bashrc, I finally stumbled across a site that got me half way there. After playing around a bit I found a few little tricks and things that no one really likes to share. So [...]]]></description>
			<content:encoded><![CDATA[<p>So after cruising the web for a few hours trying to find &#8216;dummy&#8217; style documentation on changing colors in terminal using .bashrc, I finally stumbled across a site that got me half way there. After playing around a bit I found a few little tricks and things that no one really likes to share. So here it is.</p>
<p><span id="more-49"></span></p>
<h2>LSCOLORS A bash Command</h2>
<p>The first thing you should know is that this is not as straight forward as most people like to make you believe. I am a total n00b when it comes to bash so I really need to start at the beginning.</p>
<p><strong>Step 1: Make sure .bashrc is being used by terminal</strong></p>
<p>This is the easiest step. In terminal navigate to your home directory. This is usually accomplished by typing &#8216;<em>cd ~</em>&#8216; and executing. Then do a quick directory listing showing all hidden files &#8216;<em>ls -al</em>&#8216;. Once you do this, you should see both a &#8216;<em>.bashrc</em>&#8216; and a &#8216;<em>.bash_profile</em>&#8216;. If you don&#8217;t, no need to panic we can create them easily and Snow Leopard is smart enough to know what to do with them.  So if they don&#8217;t exist, execute these 2 commands in terminal &#8216;<em>touch .bashrc</em>&#8216; &#8216;<em>touch .bash_profile</em>&#8216;. If you re-run your &#8216;<em>ls -al</em>&#8216; again you should now see the files.</p>
<p><strong>Step 2: Link .bashrc to .bash_profile</strong></p>
<p>Using your favorite editor, in my case Textmate, open<em> &#8216;.bash_profile&#8217;</em>. This file needs one line.</p>
<pre class="brush:bash">source ~/.bashrc</pre>
<p><strong>Update</strong>: A good friend of mine at <a href="http://blog.ubrio.us" target="_blank">blog.ubrio.us</a> just gave me the scoop on &#8216;<em>bashrc</em>&#8216; vs &#8216;<em>bash_profile</em>&#8216;. The gist of it is that <em>bashrc</em> is read when you open a new tab in terminal locally and <em>bash_profile</em> is read when you are SSHing into the environment. So choose whichever works for you. I just link them because I want the same view no matter how I am connecting.</p>
<p>Next open the <em>&#8216;.bashrc</em>&#8216; file, this is where we can have some fun.</p>
<p><strong>Step 3: Colors LSColors and more LS_Colors</strong>&#8230;</p>
<p>The first thing we have to do is prepare bash to receive the colors, in order to do that you need to enter these 3 lines.</p>
<pre class="brush:bash">export LS_OPTIONS='--color=auto'
export CLICOLOR='Yes'
export LSCOLORS=''
</pre>
<p>This should be pretty straight forward, we are exporting the LS_OPTIONS and saying to use colors and to automatically choose them for us if I have not chosen them. CLICOLOR=&#8217;YES&#8217; is telling bash to force color output and LS_COLORS is where we will start to define our scheme.</p>
<p>Here are the colors that are available:</p>
<ul>
<li> a = black</li>
<li>b = red</li>
<li>c = green</li>
<li>d = brown</li>
<li>e = blue</li>
<li>f = magenta</li>
<li>g = cyan</li>
<li>h = light gray</li>
<li>x = default</li>
</ul>
<p>It is important to note how the color codes pair up. Basically each entry will be a Foreground | Background pair. so &#8216;<em>ex</em>&#8216; means foreground blue background default. The &#8216;default&#8217; color will be whatever you have set in your command line app&#8217;s preferences. Most default to a white background and black foreground. By simply upper-casing any of the color codes you can bold your text, this really on works on foregrounds. Example: Bx means bold red foreground and default background.</p>
<p>The next thing that I found difficult to find was how these color codes were ordered. So it&#8217;s like this&#8230;.</p>
<ol>
<li>DIR</li>
<li>SYM_LINK</li>
<li>SOCKET</li>
<li>PIPE</li>
<li>EXE</li>
<li>BLOCK_SP</li>
<li>CHAR_SP</li>
<li>EXE_SUID</li>
<li>EXE_GUID</li>
<li>DIR_STICKY</li>
<li>DIR_WO_STICKY</li>
</ol>
<p>Wow that&#8217;s a lot, but that&#8217;s the order..</p>
<p><strong>Step 4: Putting it all together</strong></p>
<p>So now you have the order and you have the colors, lets put it all together. I use a default background of black and a foreground of white, so I use a lot of default color settings.</p>
<pre class="brush:bash">export LSCOLORS='Bxgxfxfxcxdxdxhbadbxbx'
</pre>
<p>Here is the break down:</p>
<ol>
<li>DIR = Bx #Bold red text with default background</li>
<li>SYM_LINK = gx #cyan text with default background</li>
<li>SOCKET = fx #magenta text with default background</li>
<li>PIPE = fx #magenta text with default background</li>
<li>EXE = cx #green text with default background</li>
<li>BLOCK_SP = dx #brown text with default background</li>
<li>CHAR_SP = dx #brown text with default background</li>
<li>EXE_SUID = hb #light grey text with red background</li>
<li>EXE_GUID = ad #black text with brown background</li>
<li>DIR_STICKY = bx #red text with default background</li>
<li>DIR_WO_STICKY = bx #red text with default background</li>
</ol>
<p><strong>Step 5: Wrap UP</strong></p>
<p>So your done, save your bash files and restart terminal. You should now have colors.</p>
<p>Well that&#8217;s it, I hope this helps you figure out your bash color profile: :) cheers!</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+LSCOLORS+in+OSX+Snow+Leopard%2C+For+Dummies+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F03%2Flscolors-in-osx-snow-leopard-for-dummies%2F" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+LSCOLORS+in+OSX+Snow+Leopard%2C+For+Dummies+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F03%2Flscolors-in-osx-snow-leopard-for-dummies%2F" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/03/lscolors-in-osx-snow-leopard-for-dummies/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Date Squashing with PHP and CodeIgniter</title>
		<link>http://www.napolitopia.com/2010/02/date-squashing-with-php-and-codeigniter/</link>
		<comments>http://www.napolitopia.com/2010/02/date-squashing-with-php-and-codeigniter/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 03:37:56 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=35</guid>
		<description><![CDATA[I was working on a little attendance tracking system today and I used PHP and some native CodeIgniter functions to get it to play nice with my APP. I'm using one of my favorite new scripts CalendarView to pass the dates into this function from a simple form post.]]></description>
			<content:encoded><![CDATA[<p>I was working on a little attendance tracking system today and I used PHP and some native <a href="http://codeigniter.com/user_guide/helpers/date_helper.html" target="_blank">CodeIgniter</a> functions to get it to play nice with my APP. I&#8217;m using one of my favorite new scripts <a href="http://calendarview.org/" target="_blank">CalendarView</a> to pass the dates into this function from a simple form post.</p>
<p><span id="more-35"></span></p>
<pre class="brush: php">
	//Posted values are strings like "2010-01-26"
	//Parse dates as unix
	$start_date = mysql_to_unix($_POST['start_date']);
	$end_date = mysql_to_unix($_POST['end_date']);

	//now get the date details
	$start_date_array = getdate($start_date);
	$end_date_array = getdate($end_date);

	//now lets get all the days and get ready to put it in the DB.
	for ($i=$start_date; $i <= $end_date; $i = round($i + 86400)) {
		$day = getdate($i);
		if($day['weekday'] !== 'Saturday' &#038;&#038; $day['weekday'] !== 'Sunday'){
			$days[$i] = $day;
		}
	}

	print_r($days);
</pre>
<p>So that's it pretty simple and straight forward. It just returns an array of 'day' data for each day between the 2 posted dates. I have a lot of sanity testing going on etc, but took a while to figure out so I felt like I should post it up and share.</p>
<p>Too often I find a little snippet like this on an obscure site that is the answer to a problem I have been trying to figure out all day. So maybe I can be that helping hand for someone else.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Date+Squashing+with+PHP+and+CodeIgniter+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F02%2Fdate-squashing-with-php-and-codeigniter%2F" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+Date+Squashing+with+PHP+and+CodeIgniter+http%3A%2F%2Fwww.napolitopia.com%2F2010%2F02%2Fdate-squashing-with-php-and-codeigniter%2F" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/02/date-squashing-with-php-and-codeigniter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to detect and avoid browsers with Javascript</title>
		<link>http://www.napolitopia.com/2010/01/how-to-detect-and-avoid-browsers-with-javascript/</link>
		<comments>http://www.napolitopia.com/2010/01/how-to-detect-and-avoid-browsers-with-javascript/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 18:11:10 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/?p=33</guid>
		<description><![CDATA[This has been beaten death time and time again, so I am not going to list all the reasons why we should drop it, I am just going to tell you how to make sure that users with IE6 are properly handled on your site.]]></description>
			<content:encoded><![CDATA[<p><a rel="shadowbox" href="http://www.napolitopia.com/wp-content/uploads/2010/01/sam9-logo-noIE.jpg"><img class="alignnone size-medium wp-image-34" title="sam9-logo-noIE" src="http://www.napolitopia.com/wp-content/uploads/2010/01/sam9-logo-noIE-300x247.jpg" alt="" width="300" height="247" /></a></p>
<p>I am going to go ahead a regurgitate what everyone has been saying for years now, that IE6 is just well past its prime and its time to retire it. This has been beaten death time and time again, so I am not going to list all the reasons why we should drop it, I am just going to tell you how to make sure that users with IE6 are properly handled on your site.</p>
<p><span id="more-33"></span></p>
<p>Its actually very simple. First you drop in this bit of Javascript.</p>
<pre class="brush:javascript">
//Nothing special here... just telling javascript to kick IE users out
var browser=navigator.appName;
if(browser == "Microsoft Internet Explorer"){
window.location = "no_ie.html";
}else{
//you can remove this, I just like to see what browser we ARE seeing
//alert(browser);
}
</pre>
<p>This should stop IE users, if you are trying to detect some other browser or you are curious what the navigator.appName is returning just un comment the alert above. You can also change the window.location to be any URL you like. In my case I redirect them to <a title="We Hate IE" href="http://napolitopia.com/no_ie.html" target="_blank">a page that thoroughly insults IE6</a>.</p>
<p>Add this to your sites and support<a title="IE Death March" href="http://iedeathmarch.org" target="_blank"> IEDeathMarch.org</a></p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+How+to+detect+and+avoid+browsers+with+Javascript+http%3A%2F%2Ftinyurl.com%2Fya69lp9" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/intent/tweet?text=%40eightamrock+How+to+detect+and+avoid+browsers+with+Javascript+http%3A%2F%2Ftinyurl.com%2Fya69lp9" title="Post to Twitter">Tweet This!</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/01/how-to-detect-and-avoid-browsers-with-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

