<?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>ZENVERSE &#187; Web Development</title>
	<atom:link href="http://zenverse.net/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://zenverse.net</link>
	<description>Design and Web Development</description>
	<lastBuildDate>Tue, 07 Feb 2012 12:49:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PHP &#8211; Using oEmbed API to Embed Videos</title>
		<link>http://zenverse.net/php-oembed-embed-videos/</link>
		<comments>http://zenverse.net/php-oembed-embed-videos/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 08:53:09 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2445</guid>
		<description><![CDATA[oEmbed is a format for allowing an embedded representation of a URL on third party sites. Which means, if we have a video page's URL, we can easily get the video thumbnail photo, video title, HTML code to embed it in our website and more. But of course, the video site must have oEmbed support in order for us to do that.]]></description>
			<content:encoded><![CDATA[<p>oEmbed is a format for allowing an embedded representation of a URL on third party sites. Which means, if we have a video page&#8217;s URL, we can easily get the video thumbnail photo, video title, HTML code to embed it in our website and more. But of course, the video site must have oEmbed support in order for us to do that. Check out <a rel="nofollow" target="_blank" href="http://oembed.com">http://oembed.com</a> for full documentation.</p>
<h3>Let&#8217;s look at how YouTube oEmbed works</h3>
<p>1. First, send a request to YouTube&#8217;s Oembed API page with a video URL (must be urlencoded) as parameter and we also specified that we want it to be returned in json format.</p>
<blockquote><p><a rel="nofollow" target="_blank" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json</a>
</p></blockquote>
<p>2. You will then see a long json-encoded string which contains all information about the video.</p>
<p>3. Next thing you need to do is just simply json-decode the string using your programming language, then you are free to use the information. We will see how to do that in PHP.</p>
<h3>Using Oembed to Embed Youtube Videos in PHP</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2445code1'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24451"><td class="code" id="p2445code1"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$videourl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.youtube.com/watch?v=gB4nwqNM190'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$json</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.youtube.com/oembed?url='</span><span style="color: #339933;">.</span><a href="http://www.php.net/urlencode"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$videourl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;format=json'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$decode</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$decode</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #000088;">$decode</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//error control here</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$decode</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumbnail_url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$decode</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'html'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>It&#8217;s pretty straightforward and self-explanatory:</p>
<ul>
<li>First, we send a url request to YouTube&#8217;s obembed API page using file_get_contents() function.</li>
<li>Second, we decode the response using json_decode() function which convert json format to array.</li>
<li>Third, if there is no error in decoding, we then assign $thumb and $html and use it in our website or program.</li>
</ul>
<h3>Extra: If you want to limit the embedded video&#8217;s width or height</h3>
<p>You can specify the max height or max width by appending the maxwidth or maxheight parameters to the oembed URL. (Please note that this cannot resize a smaller video to bigger size)</p>
<p>For example, from our example above, to specify max width of 300 pixels:</p>
<blockquote><p><a rel="nofollow" target="_blank" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json&#038;maxwidth=300">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json&#038;maxwidth=300</a></p></blockquote>
<p>You should notice the video embedding code (iframe) is now limited to width of 300 pixels.</p>
<h3>How do I embed videos from other video sites like Vimeo?</h3>
<p>Most of the popular video sites has oEmbed support just like YouTube. For example, by <a target="_blank" href="http://www.google.com/search?q=vimeo+oembed">googling &#8220;vimeo oembed&#8221;</a> we found vimeo oembed documentation.</p>
<p>In vimeo, this is the URL we should send our request to:</p>
<blockquote><p><a rel="nofollow" href="http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/7100569" target="_blank">http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/7100569</a></p></blockquote>
<p>More details about oEmbed API page for other video sites will be covered in our next blog post (coming soon).</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-oembed-embed-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP MySQL &#8211; Get Next Auto Increment Value of a Table</title>
		<link>http://zenverse.net/php-mysql-next-auto-increment-value/</link>
		<comments>http://zenverse.net/php-mysql-next-auto-increment-value/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 06:05:14 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2404</guid>
		<description><![CDATA[We do not often need this but sometimes when we need to retrieve the next auto increment value of a table (without incrementing the auto increment value of course), this solution below will help.]]></description>
			<content:encoded><![CDATA[<p>We do not often need this but sometimes when we need to retrieve the next auto increment value of a table (without incrementing the auto increment value of course), this solution below will help.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2404code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24042"><td class="code" id="p2404code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLE STATUS WHERE name='your_table_name_here'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Auto_increment'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//error</span>
	<span style="color: #666666; font-style: italic;">//error control here</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Just replace &#8220;your_table_name_here&#8221; with your mySQL table name.</p>
<h3>As a Function</h3>
<p>Furthermore, making it a PHP function would make the solution looks clean.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2404code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24043"><td class="code" id="p2404code3"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_next_value<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tablename</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLE STATUS WHERE name='&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/mysql_real_escape_string"><span style="color: #990000;">mysql_real_escape_string</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tablename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Auto_increment'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//error</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//usage</span>
<span style="color: #000088;">$nextval</span> <span style="color: #339933;">=</span> get_next_value<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'your_table_name_here'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-mysql-next-auto-increment-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Smart Date Function &#8211; Display Time Elapsed (Difference) Based on a Given Timestamp</title>
		<link>http://zenverse.net/php-smart-date-function/</link>
		<comments>http://zenverse.net/php-smart-date-function/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 04:43:29 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2371</guid>
		<description><![CDATA[As a web developer, we often need to display dates in our website. As a web user myself, I don't like to read full dates like "26 November 2011 11:30PM" because it takes me a little while to interpret the date. I prefer reading smart dates like "1 hour ago" or "6 months ago". Therefore, here I wrote a quick and simple function in PHP that display the time difference/elapsed based on a given timestamp value.]]></description>
			<content:encoded><![CDATA[<p>As a web developer, we often need to display dates in our website. As a web user myself, I don&#8217;t like to read full dates like &#8220;26 November 2011 11:30PM&#8221; because it takes me a little while to interpret the date. I prefer reading smart dates like &#8220;1 hour ago&#8221; or &#8220;6 months ago&#8221;. Therefore, here I wrote a quick and simple function in PHP that display the time difference/elapsed based on a given timestamp value.</p>
<h3>PHP Smart Date Function</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2371code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23714"><td class="code" id="p2371code4"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
Simple PHP Smart Date Function
by Zen (http://zenverse.net)
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$diff</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$timestamp</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'Now'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' second(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' minute(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' hour(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' day(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' month(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' year(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> grammar_date<span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sentence</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$val</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(s)'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'s'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sentence</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$val</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(s)'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sentence</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Basically I defined 2 functions above:<br />
<strong>smartdate</strong> &#8211; calculates the difference between given timestamp and current time, then returns the correct sentence<br />
<strong>grammar_date</strong> &#8211; modifies the returned sentence to plural form or singular form</p>
<h3>Usage</h3>
<p>The usage is simple and straightforward.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2371code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23715"><td class="code" id="p2371code5"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//example 1</span>
<span style="color: #b1b100;">echo</span> smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourtimestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//example 2</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Posted on '</span><span style="color: #339933;">.</span>smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourtimestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>By default, this function returns the floor() value, i.e: instead of returning &#8220;1.7 years ago&#8221;, it returns &#8220;1 year ago&#8221;. Anyway, the function can be easily modified to suit your specific needs.</p>
<h3>Give users the choice to view the full date</h3>
<p>1 disadvantage of smart date is of course, it reduces the level of detail and granularity of the date information. For example, dates of 13 months ago or 19 months ago will both be displayed as &#8220;1 year ago&#8221;.</p>
<p>The most common way to let user view the full date is to add a &#8220;title&#8221; attribute with full date as the attribute value. Now, when user mouseover your smart date, they can see the full date popping up as tooltip. Facebook uses this approach.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2371code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23716"><td class="code" id="p2371code6"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//from example 2 above</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Posted on &lt;span title=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$originalfulldate</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourtimestamp</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-smart-date-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cannot Access Localhost After Editing etc/hosts and Flushing DNS Cache</title>
		<link>http://zenverse.net/cannot-access-localhost-after-editing-etchosts-flush-cache/</link>
		<comments>http://zenverse.net/cannot-access-localhost-after-editing-etchosts-flush-cache/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 16:23:42 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2354</guid>
		<description><![CDATA[I was developing a new website that uses Facebook Login as the membership system. I came across this situation where I needed to create a "fake" domain by editing the etc/hosts file. Somehow, after editing the etc/hosts file (following an online guide), I cannot seems to browse http://localhost in my browser anymore. However, I can still browse my local apache server using http://127.0.0.1]]></description>
			<content:encoded><![CDATA[<p>I was developing a new website that uses Facebook Login as the membership system. I came across this situation where I needed to create a &#8220;fake&#8221; domain by editing the etc/hosts file. Somehow, after editing the etc/hosts file (following an online guide), I cannot seems to browse http://localhost in my browser anymore. However, I can still browse my local apache server using http://127.0.0.1</p>
<blockquote><p><strong>NOTE:</strong><br />
This is not XAMPP / apache issue<br />
This is not browser-specific issue
</p></blockquote>
<p>In fact, this is a simple problem with simple solution. However, this problem occurs when I am getting frustrated with the Facebook integration problem (after 12 hours of debugging). Therefore, I missed some simple but important steps to solve this problem. Here I list them down below:</p>
<h3>1. Ping Localhost</h3>
<p>For Mac OS users, open up your Terminal. For windows users, open up your command prompt.</p>
<ul>
<li>Type the &#8220;ping localhost&#8221; and press enter.</li>
<li>You should get error messages like &#8220;unknown host&#8221; since you are having this problem.</li>
</ul>
<ul>
<li>Next, type &#8220;ping 127.0.0.1&#8243; and press enter.</li>
<li>If you saw something like this, the ping is successful:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2354code7'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23547"><td class="code" id="p2354code7"><pre class="cmd" style="font-family:monospace;">PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.118 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.171 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.167 ms</pre></td></tr></table></div>

</li>
<li>If you get &#8220;unknown host error&#8221;, please check whether you have started your local server service.</li>
</ul>
<h3>2. Clear your browser cache</h3>
<p>Modern browsers cache a lot of stuff, including DNS cache. They may have cached the erroneous DNS setting in etc/hosts, so you might want to clear your browsers cache and try loading localhost again. Clearing cache alone would already be sufficient, you can skip clearing cookies, saved session, etc.</p>
<p>If it still doesn&#8217;t work, try #3 below.</p>
<h3>3. Did you just flushed the DNS cache?</h3>
<p>I ran this command in terminal (Mac) to flush my cache before I get into this mess: &#8220;dscacheutil -flushcache&#8221;<br />
For some reason, after I flushed the cache, the DNS setting is not being rebuilt &#8211; I cannot ping localhost but I can ping 127.0.0.1</p>
<p>After restarting my laptop (to rebuild the DNS settings &#038; cache) and clearing all browser cache once again, I finally get my localhost displayed again.</p>
<p>Now I hope this helps some of you.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/cannot-access-localhost-after-editing-etchosts-flush-cache/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Legacy Facebook &#8220;Share&#8221; Button Codes (Bubble Count, Box Count and More)</title>
		<link>http://zenverse.net/legacy-facebook-share-button-code/</link>
		<comments>http://zenverse.net/legacy-facebook-share-button-code/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 16:12:32 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2329</guid>
		<description><![CDATA[Few months ago, Facebook removed the page that allow us to generate codes for their official "Share" button. They replaced it with <a href="https://developers.facebook.com/docs/reference/plugins/like" target="_blank">"Like" button</a> instead. While "Like" button is fast and easy but we cannot add our comment along with the "Like" action. Therefore, in some cases, we still need the old Share button. Fortunately, the sharer.php still exists, so we can add the Share button using Facebook's official script.]]></description>
			<content:encoded><![CDATA[<p>Few months ago, Facebook removed the page that allow us to generate codes for their official &#8220;Share&#8221; button. They replaced it with <a href="https://developers.facebook.com/docs/reference/plugins/like" target="_blank">&#8220;Like&#8221; button</a> instead. While &#8220;Like&#8221; button is fast and easy but we cannot add our comment along with the &#8220;Like&#8221; action. Therefore, in some cases, we still need the old Share button. Fortunately, the sharer.php still exists, so we can add the Share button using Facebook&#8217;s official script.</p>
<p>Here are the complete codes for all sizes of Facebook share button for those who are interested:</p>
<h3>Box Count</h3>
<p><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a> &nbsp;*count will only visible when there is at least 1 share</p>
<div class="clear"></div>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code8'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23298"><td class="code" id="p2329code8"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;box_count&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Button Count</h3>
<p><a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a> *count will only visible when there is at least 1 share</p>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code9'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23299"><td class="code" id="p2329code9"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;button_count&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Button only</h3>
<p><a name="fb_share" type="button" href="http://www.facebook.com/sharer.php">Share</a></p>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code10'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232910"><td class="code" id="p2329code10"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;button&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Small Icon only</h3>
<p><a name="fb_share" type="icon" href="http://www.facebook.com/sharer.php">Share</a></p>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code11'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232911"><td class="code" id="p2329code11"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;icon&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Custom URL?</h3>
<p>All codes above &#8220;shares&#8221; the current page. If you want to share another page or a specific page, you need to add a &#8220;share_url&#8221; attribute to the &lt;a> tag. You need this too when you have multiple share buttons in a single page.</p>
<p>Example below shares our main website http://zenverse.net instead of this page.</p>
<p><a name="fb_share" type="button_count" share_url="http://zenverse.net" href="http://www.facebook.com/sharer.php">Share</a></p>
<p>Here&#8217;s how:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code12'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232912"><td class="code" id="p2329code12"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;button_count&quot; share_url=&quot;http://zenverse.net&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Multiple Share Buttons</h3>
<p>If you have multiple share buttons in a single page, you just need to include the &lt;script> element <b>once</b>.</p>
<p>Hope this helps.</p>
<p><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/legacy-facebook-share-button-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>4 Must-Have Google Chrome Extensions for Web Developers</title>
		<link>http://zenverse.net/4-google-chrome-extensions-for-web-dev/</link>
		<comments>http://zenverse.net/4-google-chrome-extensions-for-web-dev/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 09:59:23 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[chrome]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2201</guid>
		<description><![CDATA[Web developers often need to do repetitive works such as taking screenshots, turning off javascript or images, check backlinks or ranking of websites and more. Fortunately, with these 4 totally free Google Chrome extensions, web developers can save a lot of time on these repetitive works, thus increasing productivity.]]></description>
			<content:encoded><![CDATA[<p>Web developers often need to do repetitive works such as taking screenshots, turning off javascript or images, check backlinks or ranking of websites and more. Fortunately, with these 4 totally free Google Chrome extensions, web developers can save a lot of time on these repetitive works, thus increasing productivity.</p>
<h3><a rel="nofollow" target="_blank" href="https://chrome.google.com/webstore/detail/alelhddbbhepgpmgidjdcjakblofbmce">Awesome Screenshot: Capture &#038; Annotate</a></h3>
<p><a href="http://zenverse.net/wp-content/uploads/2011/09/screenshot.jpg"><img src="http://zenverse.net/wp-content/uploads/2011/09/screenshot.jpg" alt="" title="screenshot" width="260" height="147" class="alignnone size-full wp-image-2208" /></a></p>
<p>As the name suggests, this awesome extension can do more than just screenshot. At a glance, it provide 3 ways to capture screenshots: visible area, entire page or selected area. Furthermore, it allows us to crop, annotate the screenshot with shapes and texts as well as blur sensitive info. Most importantly, it comes with undo feature. </p>
<h3><a rel="nofollow" target="_blank" href="https://chrome.google.com/webstore/detail/gbkffbkamcejhkcaocmkdeiiccpmjfdi">Pendule</a></h3>
<p>This is an essential extension for web developers. Below are some key features of Pendule I find it useful:</p>
<p><a href="http://zenverse.net/wp-content/uploads/2011/09/pendule.jpg"><img src="http://zenverse.net/wp-content/uploads/2011/09/pendule.jpg" alt="" title="pendule" width="450" height="308" class="alignnone size-full wp-image-2207" /></a></p>
<ul>
<li>View all css and javascript codes with syntax highlighting</li>
<li>Reload css without refreshing the page.</li>
<li>One-click disable or enable external/inline CSS</li>
<li>One click hide all images / background images</li>
<li>Color picker and ruler to measure an element in pixels</li>
<li>Links to validate html / css / feed</li>
<li>Added &#8220;View Selection Source&#8221; feature (when you right click a highlighted area), just like in Mozilla Firefox.</li>
</ul>
<h3><a rel="nofollow" href="https://chrome.google.com/webstore/detail/idhfcdbheobinplaamokffboaccidbal" target="_blank">Resolution Test</a></h3>
<p><a href="http://zenverse.net/wp-content/uploads/2011/09/screensize.jpg"><img src="http://zenverse.net/wp-content/uploads/2011/09/screensize.jpg" alt="" title="screensize" width="253" height="227" class="alignnone size-full wp-image-2209" /></a></p>
<p>This allows web developers to test their website in all common screen resolutions, as well as user-defined size. With this extension, we do not have to update our screen resolution manually anymore. All common screen size can be applied and tested with only one click, Google Chrome will then changed its windows size, without changing the screen resolution.</p>
<h3><a rel="nofollow" href="https://chrome.google.com/webstore/detail/oangcciaeihlfmhppegpdceadpfaoclj" target="_blank">SEO for Chrome</a></h3>
<p><a href="http://zenverse.net/wp-content/uploads/2011/09/seochrome.jpg"><img src="http://zenverse.net/wp-content/uploads/2011/09/seochrome.jpg" alt="" title="seochrome" width="524" height="310" class="alignnone size-full wp-image-2210" /></a></p>
<p>This extension can display information such as page rank, number of backlinks, social media stats, traffic stats and more within seconds. It can also show all nofollow links, if enabled, by highlighting them with border. The keyword research tool sounds useful too, although I can&#8217;t seems to use it at the moment.</p>
<p>If you know other good extension, feel free to share with us in the comment section.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/4-google-chrome-extensions-for-web-dev/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Fix FTP Login Problem in WordPress in XAMPP for Mac OS (Localhost)</title>
		<link>http://zenverse.net/wordpress-ftp-login-problem-xampp-mac-localhost/</link>
		<comments>http://zenverse.net/wordpress-ftp-login-problem-xampp-mac-localhost/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 15:44:29 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2047</guid>
		<description><![CDATA[If you are using XAMPP for Mac OS like me, and was asked to enter FTP login information when you upgrade Wordpress core and download themes or plugins, then this guide is for you. After searching for solution online, I found that this is a permission problem due to your Mac's username is different compared to the default user name in XAMPP for Mac, called nobody.]]></description>
			<content:encoded><![CDATA[<p>If you are using XAMPP for Mac OS like me, and was asked to enter FTP login information when you upgrade WordPress core and download themes or plugins, then this guide is for you. After searching for solution online, I found that this is a permission problem due to your Mac&#8217;s username is different compared to the default user name in XAMPP for Mac, called nobody.</p>
<p>As far as I understand, this has nothing to do with FTP settings. This problem occurs because the Apache HTTP service was being run as &#8220;nobody&#8221; while your Mac user name is a different name. Thus, it has no permission to add/edit your server files so WordPress attempted to use FTP to perform its job.</p>
<h3>Editing httpd.conf as Admin</h3>
<p>First of all, editing this file is not as easy as using a text editor program and edit it because this read-only file can only be changed by root or superuser, not even administrator. There are 2 or more methods that you use to edit such file:</p>
<blockquote><p>1. Edit using vi editor in sudo mode using Terminal<br />
<strong>2. Run Mac OS TextEditor in sudo mode using Terminal and edit the file</strong></p></blockquote>
<p>- Terminal is a command line tool just like Window&#8217;s CMD.<br />
- Sudo mode refers to running the file as superuser or root.<br />
- Vi editor is a command line editor that is very not user-friendly to use, edit and save (at least for beginner)</p>
<p>Thus we will use Method 2 to perform this task.</p>
<h3>1. Run Mac OS TextEditor application in sudo mode using Terminal and edit the file</h3>
<p>First of all, open up your Terminal by typing &#8220;Terminal&#8221; in your Spotlight search box (upper right corner)</p>
<p>Once the terminal is loaded, type this in: (copy and paste if possible)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2047code13'); return false;">View Code</a> TERMINAL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p204713"><td class="code" id="p2047code13"><pre class="terminal" style="font-family:monospace;">sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /Applications/XAMPP/etc/httpd.conf</pre></td></tr></table></div>

<p>- sudo command will run the TextEdit application as root<br />
- Seperated by a space after the application path, is the path of httpd.conf (the file to edit)</p>
<p>Press enter, a TextEdit window should pop up and you can then freely edit the file as root.</p>
<h3>2. Change the user name and group name</h3>
<p>Now, look for these 2 lines:</p>
<blockquote><p>User nobody<br />
Group admin</p></blockquote>
<p>Change them to:</p>
<blockquote><p>User your-mac-username<br />
Group staff</p></blockquote>
<p>- Staff is the non-admin user group in Mac.<br />
- If you are not sure about your mac username, open Finder > go to Macintosh HD > Users > Look for your folder&#8217;s name.</p>
<p>Now restart your XAMPP apache server and it should be working perfectly.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/wordpress-ftp-login-problem-xampp-mac-localhost/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Access GET Data (Query Strings) in htaccess mod_rewrite</title>
		<link>http://zenverse.net/capture-query-string-get-data-in-htaccess-rewrite/</link>
		<comments>http://zenverse.net/capture-query-string-get-data-in-htaccess-rewrite/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 08:14:44 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2065</guid>
		<description><![CDATA[We were used to use RewriteRule to match a URL, and then rewrite it. However, RewriteRule will always ignore your query string (GET data) so we need to use RewriteCond in order to capture the values in the query string. This is the basic syntax: RewriteCond %{QUERY_STRING} pattern]]></description>
			<content:encoded><![CDATA[<p>If you need to know how to do basic and common URL rewriting, please take a look at our <a href="http://zenverse.net/seo-friendly-urls-with-htaccess/" title="SEO Friendly URLs">SEO Friendly URL Rewriting</a> post. </p>
<h3>Use RewriteCond</h3>
<p>We were used to use RewriteRule to match a URL, and then rewrite it. However, RewriteRule will always ignore your query string (GET data) so we need to use RewriteCond to capture the values in the query string.</p>
<p>This is the syntax:</p>
<blockquote><p>RewriteCond %{QUERY_STRING} ^(.*)$</p></blockquote>
<ul>
<li>%{QUERY_STRING} captures the matched query string into % variable.
<li>%1 will carry the matched content of the first group of brackets.</li>
<li>The second part ^(.*)$ is the pattern you want to match.</li>
<li>^ means &#8220;start with&#8221;</li>
<li>$ means &#8220;end&#8221;</li>
<li>Like regular expressions, the dot in (.*) matches any characters.</li>
<li>The asterisk * inside the brackets is a quantifier that match 0 occurence to infinite occurences.</li>
<li>Therefore, combining them, (.*) matches any characters</li>
<li>So, clearly, in this example, it matches the whole query string part.</li>
</ul>
<h3>Some common ways of capturing query strings</h3>
<h5>Case 1</h5>
<p>This case is for you if you&#8217;ve rewrote your url this way, for example:<br />
FROM <strong style="color:green">site.com/show.php?id=seo</strong> TO <strong style="color:green">site.com/show/seo/</strong></p>
<p>And you <u>WANT</u> to pass or append some GET data using the rewritten URL, like:<br />
<strong style="color:green">site.com/show/seo/?lang=en&#038;source=firefox</strong> you want it to append like <strong style="color:green">site.com/show.php?id=seo<u>&#038;lang=en&#038;source=firefox</u></strong></p>
<p>This is the htaccess rules:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2065code14'); return false;">View Code</a> HTACCESS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p206514"><td class="code" id="p2065code14"><pre class="htaccess" style="font-family:monospace;">RewriteEngine On
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^show/(.*)/$ show.php?id=$1&amp;%1</pre></td></tr></table></div>

<ul>
<li>This RewriteCond captures whole query string (first bracket) into %1</li>
<li>In this case, the captured string %1 is &#8220;lang=en&#038;source=firefox&#8221;</li>
<li>We then do our normal URL rewriting and append the %1 to the URL after a ampersand (&#038;)</li>
</ul>
<h5>Case 2</h5>
<p>This case is for you if you know specifically or want to control what query string you are going to use.</p>
<p>For example, you only want to match lang=xxx and NOTHING ELSE, for example:<br />
<strong style="color:green">site.com/show/seo/?lang=en&#038;more=1</strong> you want it to append like <strong style="color:green">site.com/show.php?id=seo<u>&#038;lang=en</u></strong>, ignoring other unknown query string.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2065code15'); return false;">View Code</a> HTACCESS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p206515"><td class="code" id="p2065code15"><pre class="htaccess" style="font-family:monospace;">RewriteEngine On
RewriteCond %{QUERY_STRING} ^lang=(\w+)$
RewriteRule ^show/(.*)/$ show.php?id=$1&amp;lang=%1</pre></td></tr></table></div>

<ul>
<li>This RewriteCond captures <em>lang</em>&#8216;s GET data (first bracket) into %1</li>
<li>\w matches word characters</li>
<li>The plus + means one occurrence or more</li>
<li>In this case, the captured string %1 is &#8220;en&#8221;</li>
</ul>
<h5>Case 3</h5>
<p>Similar as Case 2, but tis case we have more query to match.</p>
<p>For example, you only want to match lang=xxx and time=000, for example:<br />
<strong style="color:green">site.com/show/seo/?lang=en&#038;time=100</strong> you want it to append like <strong style="color:green">site.com/show.php?id=seo<u>&#038;lang=en&#038;time=100</u></strong></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2065code16'); return false;">View Code</a> HTACCESS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p206516"><td class="code" id="p2065code16"><pre class="htaccess" style="font-family:monospace;">RewriteEngine On
RewriteCond %{QUERY_STRING} ^lang=(\w+)&amp;time=(\d+)$
RewriteRule ^show/(.*)/$ show.php?id=$1&amp;lang=%1&amp;time=%2</pre></td></tr></table></div>

<ul>
<li>This RewriteCond captures <em>lang</em>&#8216;s GET data (first bracket) into %1</li>
<li>This RewriteCond also captures <em>time</em>&#8216;s GET data (second bracket) into %2</li>
<li>\w matches word characters</li>
<li>\d matches decimals</li>
<li>The plus + means one occurrence or more</li>
<li>In this case, the captured string %1 is &#8220;en&#8221; , %2 is &#8220;100&#8243;</li>
</ul>
<h3>Useful Link</h3>
<p><a target="_blank" href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritecond">Mod Rewrite : Rewritecond Documentation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/capture-query-string-get-data-in-htaccess-rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Missing Characters When You View Source in Google Chrome &#8211; An Unnoticed Bug?</title>
		<link>http://zenverse.net/random-missing-characters-when-view-source-in-chrome/</link>
		<comments>http://zenverse.net/random-missing-characters-when-view-source-in-chrome/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 14:35:36 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2054</guid>
		<description><![CDATA[I started to notice this bug when I was playing with my new tool in <a href="http://tools.zenverse.net/">my tools playground</a>, the <a href="http://tools.zenverse.net/html-tags-counter/">HTML Tags Counter</a>. I loaded my site zenverse.net and viewed the HTML source using Google Chrome. Then, I copied and pasted the codes to run an analysis using my own tool. I was "amazed" by the result, I get different errors (different unclosed/unopened tags) almost everytime I reloaded the "view source" page.]]></description>
			<content:encoded><![CDATA[<p>I started to notice this bug when I was playing with my new tool in <a href="http://tools.zenverse.net/">my tools playground</a>, the <a href="http://tools.zenverse.net/html-tags-counter/">HTML Tags Counter</a>. I loaded my site zenverse.net and viewed the HTML source using Google Chrome. Then, I copied and pasted the codes to run an analysis using my own tool. I was &#8220;amazed&#8221; by the result, I get different errors (different unclosed/unopened tags) almost everytime I reloaded the &#8220;view source&#8221; page. Next, of course I tried running same analysis using my site&#8217;s HTML source code gotten from Firefox. For 5 times, they are all perfect with no error. So, I confirmed that the problem is from Google Chrome.</p>
<h3>The Random Missing Characters &#8211; My Case</h3>
<p>It seems that everytime you view source of any pages. Google Chrome would miss out some characters, mostly one of these: &lt; or &gt;</p>
<p>In my case, two examples were shown below:</p>
<p>Notice the &lt;a> tag after &lt;p></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2054code17'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p205417"><td class="code" id="p2054code17"><pre class="html" style="font-family:monospace;">&lt;p&gt;a class=&quot;addthis_button&quot; href=&quot;http://www.addthis.com/bookmark.php?v=250&amp;amp;pub=zenverse&quot;&gt;&lt;img src=&quot;http://s7.addthis.com/static/btn/v2/lg-bookmark-en.gif&quot; width=&quot;125&quot; height=&quot;16&quot; alt=&quot;Bookmark and Share&quot; style=&quot;border:0&quot;/&gt;&lt;/a&gt;&lt;/p&gt;</pre></td></tr></table></div>

<p>Notice the last &lt;/li> tag</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2054code18'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p205418"><td class="code" id="p2054code18"><pre class="html" style="font-family:monospace;">&lt;li&gt;&lt;a href='http://zenverse.net/2009/12/' title='December 2009'&gt;December 2009&lt;/a&gt;&amp;nbsp;(6)&lt;/li&gt; 
&lt;li&gt;&lt;a href='http://zenverse.net/2009/11/' title='November 2009'&gt;November 2009&lt;/a&gt;&amp;nbsp;(10)/li&gt;</pre></td></tr></table></div>

<h3>Reproducing the error</h3>
<p>Using Google Chrome, you can try to load any <strong>validated</strong> site&#8217;s source code, preferably websites with long source codes. You can try it with our site. Next, go to the <a target="_blank" href="http://validator.w3.org/#validate_by_input">W3C Validator</a> and paste them into the textarea and validate. You might notice some error. </p>
<p>Do the same thing again using Firefox.</p>
<p>What is wrong with Google Chrome recently? Last week we just discovered a bug that causes the browser to load very slowly or not to load at all, and now we discovered another new bug here.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/random-missing-characters-when-view-source-in-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Add/Integrate Google +1 Plus One Button into WordPress</title>
		<link>http://zenverse.net/integrate-google-1-plus-one-button-into-wordpress/</link>
		<comments>http://zenverse.net/integrate-google-1-plus-one-button-into-wordpress/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 12:13:11 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2026</guid>
		<description><![CDATA[Google recently introduced their own social button just like those we commonly see, such as Facebook Share, Tweet It, Digg It, etc. Just like Facebook and Twitter button that let you share content to your followers or friends, Google +1 button let people who love your content to recommend it on Google search. ]]></description>
			<content:encoded><![CDATA[<p>Google recently introduced their own social button just like those we commonly see, such as Facebook Share, Tweet It, Digg It, etc. Just like Facebook and Twitter button that let you share content to your followers or friends, Google +1 button let people who love your content to recommend it on Google search. The pages that you plusone-d (+1&#8242;d) can then be useful to your friends and contacts in your Google Account. They can see what you recommended, thus their search results will be something like this:</p>
<p><a href="http://zenverse.net/wp-content/uploads/2011/06/screen-capture.png"><img src="http://zenverse.net/wp-content/uploads/2011/06/screen-capture.png" alt="" title="screen-capture" width="323" height="93" class="alignnone size-full wp-image-2027" /></a></p>
<p>This feature can be turned off though, if you don&#8217;t like this. You can go to Google Account Settings > Under &#8220;+1 on non-Google sites&#8221; > Click &#8220;Edit&#8221; > Select &#8220;Disable&#8221;.</p>
<h3>Integrate Google +1 Button into WordPress Theme</h3>
<p>First of all, Google has its own code generator for the button located at <a target="_blank" href="http://www.google.com/webmasters/+1/button/">here</a>. Now. decide the style and size then come back to here again.</p>
<h5>Loading The Required Javascript</h5>
<p>Open your theme&#8217;s header.php, paste this or similar codes from the generator, ONCE ONLY, into &lt;head> tag:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2026code19'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p202619"><td class="code" id="p2026code19"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;https://apis.google.com/js/plusone.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<h5>Adding The Button To Single Post / Page</h5>
<p>If you want your button to appear in single post or page, first open single.php or page.php, identify The Loop. More information about The Loop at <a target="_blank" href="http://codex.wordpress.org/The_Loop">here</a>. Next, paste this button render codes or the codes generated by google, after <?php the_content(); ?></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2026code20'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p202620"><td class="code" id="p2026code20"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>plusone<span style="color: #339933;">&gt;&lt;/</span>g<span style="color: #339933;">:</span>plusone<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>The code above should make the button nicely, your page URL will be auto detected so nothing we need to change here.</p>
<h5>Adding The Button To Blog Index</h5>
<p>If you want your button to appear in blog index for every post, first open index.php, identify The Loop and paste this button render codes or the codes generated by google, after <?php the_content(); ?> or <?php the_excerpt(); ?></p>
<p>We need to include a href=&#8221;" attribute here because every post has their own URL. like this:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2026code21'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p202621"><td class="code" id="p2026code21"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>g<span style="color: #339933;">:</span>plusone href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span><span style="color: #339933;">&gt;&lt;/</span>g<span style="color: #339933;">:</span>plusone<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>In other words, no matter how your generated render codes looks like, just add the following href attribute into the plusone tag.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2026code22'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p202622"><td class="code" id="p2026code22"><pre class="php" style="font-family:monospace;">href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php the_permalink(); ?&gt;&quot;</span></pre></td></tr></table></div>

<h3>Google Plus One Button, Live</h3>
<p>This is how my Google +1 Button for this page looks like:</p>
<p><script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><br />
<g:plusone></g:plusone></p>
<h3>Useful Links</h3>
<p><a target="_blank" href="http://www.google.com/+1/button/">More Info about Google +1 Button</a><br />
<a target="_blank" href="http://www.google.com/webmasters/+1/button/">Google +1 Button Code Generator</a><br />
<a target="_blank" href="http://code.google.com/apis/+1button/">Google +1 Button API for developer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/integrate-google-1-plus-one-button-into-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

