<?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>Tue, 27 Jul 2010 16:50:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<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>
<p class="tweet_align"><a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Why+Validation+Is+Important%2C%E2%80%A6+After+All+http://tinyurl.com/23hjoop" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Why+Validation+Is+Important%2C%E2%80%A6+After+All+http://tinyurl.com/23hjoop" title="Post to Twitter">Tweet This!</a></p>]]></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>
<p class="tweet_align"><a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Setting+an+%E2%80%98Active%E2%80%99+Class+for+Dynamic+Navigations+in+WordPress+http://tinyurl.com/39le9g8" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Setting+an+%E2%80%98Active%E2%80%99+Class+for+Dynamic+Navigations+in+WordPress+http://tinyurl.com/39le9g8" title="Post to Twitter">Tweet This!</a></p>]]></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>
<p class="tweet_align"><a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Self+Clearing+Input+Fields+With+Javascript+and+Prototype+http://tinyurl.com/38moono" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Self+Clearing+Input+Fields+With+Javascript+and+Prototype+http://tinyurl.com/38moono" title="Post to Twitter">Tweet This!</a></p>]]></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>
<p class="tweet_align"><a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Last+Tweet+%E2%80%93+A+PHP+Twitter+Class+http://tinyurl.com/y3rr7wu" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Last+Tweet+%E2%80%93+A+PHP+Twitter+Class+http://tinyurl.com/y3rr7wu" title="Post to Twitter">Tweet This!</a></p>]]></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>
<p class="tweet_align"><a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+LSCOLORS+in+OSX+Snow+Leopard%2C+For+Dummies+http://tinyurl.com/y8s3m72" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+LSCOLORS+in+OSX+Snow+Leopard%2C+For+Dummies+http://tinyurl.com/y8s3m72" title="Post to Twitter">Tweet This!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/03/lscolors-in-osx-snow-leopard-for-dummies/feed/</wfw:commentRss>
		<slash:comments>0</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>
<p class="tweet_align"><a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Date+Squashing+with+PHP+and+CodeIgniter+http://tinyurl.com/yeamyr6" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+Date+Squashing+with+PHP+and+CodeIgniter+http://tinyurl.com/yeamyr6" title="Post to Twitter">Tweet This!</a></p>]]></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>
<p class="tweet_align"><a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+How+to+detect+and+avoid+browsers+with+Javascript+http://tinyurl.com/ya69lp9" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+How+to+detect+and+avoid+browsers+with+Javascript+http://tinyurl.com/ya69lp9" title="Post to Twitter">Tweet This!</a></p>]]></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>
		<item>
		<title>PHP Mailer Stuffs FTW</title>
		<link>http://www.napolitopia.com/2010/01/php-mailer-stuffs/</link>
		<comments>http://www.napolitopia.com/2010/01/php-mailer-stuffs/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 03:32:09 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/wp_proof/?p=13</guid>
		<description><![CDATA[It took me almost 5 hours to find a solution to this one simple problem. I don&#8217;t know why this is not more clearly documented, but I figure I will post it up here for everyone to see. Im sure spam mailer people will love it. When useing PHP code to send a mail you [...]]]></description>
			<content:encoded><![CDATA[<p>It took me almost 5 hours to find a solution to this one simple problem. I don&#8217;t know why this is not more clearly documented, but I figure I will post it up here for everyone to see. Im sure spam mailer people will love it.</p>
<p><span id="more-13"></span></p>
<p>When useing PHP code to send a mail you can apply a variety of arguments, the one argument that is rarely seen is the &#8220;Return-Path&#8221; argument. This argument sets where the &#8220;bounced&#8221; email will be delieverd back to. In trying to get this working I discovered that this argument does not work well on all servers so I found a command line that you set under the &#8220;additional_paramaters&#8221; argument to provoke the server into overwriting the default &#8220;Return-Path&#8221; header.</p>
<pre class="brush:php">mail("a@a.com", "Subject", "Message", "From: a@a.com", "<strong>-fa@a.com</strong>");</pre>
<p>Note that &#8220;-f&#8221; is placed before the email address in the additional_paramaters argument.</p>
<p>Anyway, I just felt like sharing because it took me so long to figure it out.</p>
<p>Cheers!</p>
<p class="tweet_align"><a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+PHP+Mailer+Stuffs+FTW+http://tinyurl.com/yeww8nj" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+PHP+Mailer+Stuffs+FTW+http://tinyurl.com/yeww8nj" title="Post to Twitter">Tweet This!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/01/php-mailer-stuffs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YouTube API &#8211; XML Feed Ripper</title>
		<link>http://www.napolitopia.com/2010/01/youtube-api-xml-feed-ripper/</link>
		<comments>http://www.napolitopia.com/2010/01/youtube-api-xml-feed-ripper/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 05:44:21 +0000</pubDate>
		<dc:creator>eightamrock</dc:creator>
				<category><![CDATA[Code Bin]]></category>

		<guid isPermaLink="false">http://www.napolitopia.com/wp_proof/?p=9</guid>
		<description><![CDATA[I created this tool because I could not find a tool that met my needs.  I wanted a simple feed extraction tool that would just post up some dynamic content from YouTube.  It turned into a class which is actually pretty easy to use.]]></description>
			<content:encoded><![CDATA[<p><a href="/downloads/youTube.zip">DOWNLOAD SOURCE (*.ZIP)</a></p>
<p>I created this tool because I could not find a tool that met my needs.  I wanted a simple feed extraction tool that would just post up some dynamic content from YouTube.  It turned into a class which is actually pretty easy to use.</p>
<p><span id="more-9"></span></p>
<p>The Class has 3 main functions:</p>
<ol>
<li>yt_featured();</li>
<li>yt_user();</li>
<li>yt_tag();</li>
</ol>
<p>Each function uses different arguments to extract the videos you want from the YouTube API. All the functions use your dev ID and a return number to pull in however many videos you want to list. If the return number is left blank it will return all relative videos from the API request string. Otherwise if you ask for 25 and only 23 are available it will return on 23. Simple error checking I know, but its important.</p>
<p><strong>Prep</strong></p>
<pre class="brush:php">// first instantiate your class
$yt = new youTube;</pre>
<p><strong>Example 1:</strong></p>
<pre class="brush:php">$yt-&gt;yt_featured("dev_ID", 0);</pre>
<p>In this example it pulls all of the featured videos from the &#8220;youtube.videos.list_featured&#8221; method.</p>
<p><strong>Example 2:</strong></p>
<pre class="brush:php">$yt-&gt;yt_user("dev_ID", "username", 0);</pre>
<p>In this example it pulls all videos from a specific user through the &#8220;youtube.videos.list_by_user&#8221; method.</p>
<p><strong>Example 3:</strong></p>
<pre class="brush:php">$yt-&gt;yt_tag("dev_ID", "tag", 0);</pre>
<p>In this example it pulls all videos that match a specific tag through the &#8220;youtube.videos.list_by_tag&#8221; method.</p>
<p>Well thats pretty much it. Very basic probably poorly coded, but I look forward to seeing what the developer community is going to do with it. I hope that everyone keeps me posted on upgrades to my script. I leave it your hands to do with what you want. Just leave me on the credit somewhere as the originator.</p>
<p><a href="/downloads/youTube.zip">DOWNLOAD SOURCE (*.ZIP)</a></p>
<p class="tweet_align"><a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+YouTube+API+%E2%80%93+XML+Feed+Ripper+http://tinyurl.com/y8k38ts" title="Post to Twitter"><img class="nothumb" src="http://www.napolitopia.com/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" class="tt" href="http://twitter.com/home/?status=@eightamrock+YouTube+API+%E2%80%93+XML+Feed+Ripper+http://tinyurl.com/y8k38ts" title="Post to Twitter">Tweet This!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.napolitopia.com/2010/01/youtube-api-xml-feed-ripper/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
