<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>CatsWhoCode.com - Snippets Feed</title>
	
	<link>http://www.catswhocode.com/blog</link>
	<description>Web Development Blog</description>
	<lastBuildDate>Fri, 24 May 2013 12:24:47 +0000</lastBuildDate>
		<language />
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	
	<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/catswhocode-snippets" /><feedburner:info uri="catswhocode-snippets" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Insert line breaks in HTML buttons</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/kia2mZ8bbHQ/insert-line-breaks-in-html-buttons</link>
		<comments>http://www.catswhocode.com/blog/snippets/insert-line-breaks-in-html-buttons#comments</comments>
		<pubDate>Fri, 24 May 2013 12:24:47 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5341</guid>

		<description><![CDATA[You can use carriage return characters to break the line: &#x00A;]]></description>
	
		<content:encoded><![CDATA[<pre>&lt;input type=&quot;button&quot; value=&quot;Really&amp;#x00A;Tall&amp;#x00A; Button&quot;&gt;</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/kia2mZ8bbHQ" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/insert-line-breaks-in-html-buttons/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/insert-line-breaks-in-html-buttons</feedburner:origLink></item>
	
	<item>
		<title>Count user posts on a WordPress site</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/2gnlEq24g9c/count-user-posts-on-a-wordpress-site</link>
		<comments>http://www.catswhocode.com/blog/snippets/count-user-posts-on-a-wordpress-site#comments</comments>
		<pubDate>Wed, 22 May 2013 15:06:25 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5525</guid>

		<description><![CDATA[A small but usefull snippet which is great for the author page or for open website which have multiple authors and returns a count of author posts... Please note that it currently returns published &#38; pending posts but this can be changed easily by adding the status parameter to get_post request.]]></description>
	
		<content:encoded><![CDATA[<pre>function countUserPosts($userID) {
	$userposts = get_posts('showposts=-1&amp;author='.$userID); 
	return count($userposts);
}

// USAGE
echo 'Author has published'.countUserPosts('1').' Posts';</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/2gnlEq24g9c" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/count-user-posts-on-a-wordpress-site/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/count-user-posts-on-a-wordpress-site</feedburner:origLink></item>
	
	<item>
		<title>Highlight current menu item in PHP</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/vqkotB-TEOc/highlight-current-menu-item-in-php</link>
		<comments>http://www.catswhocode.com/blog/snippets/highlight-current-menu-item-in-php#comments</comments>
		<pubDate>Mon, 20 May 2013 15:03:17 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5435</guid>

		<description><![CDATA[Here another useful snippet for highlight current menu item in PHP]]></description>
	
		<content:encoded><![CDATA[<pre>&lt;ul class=&quot;sub-nav&quot; &gt;
    &lt;?php
        $full_name = $_SERVER['PHP_SELF'];
        $name_array = explode('/',$full_name);
        $count = count($name_array);
        $page_name = $name_array[$count-1];
    ?&gt;
    &lt;li&gt;&lt;a class=&quot;&lt;?php echo ($page_name=='where-to-buy.php')?'active':'';?&gt;&quot; href=&quot;where-to-buy.php&quot;&gt;WHERE TO BUY&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;&lt;?php echo ($page_name=='about.php')?'active':'';?&gt;&quot; href=&quot;about.php&quot;&gt;ABOUT US&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a class=&quot;&lt;?php echo ($page_name=='contact.php')?'active':'';?&gt;&quot; href=&quot;contact.php&quot;&gt;CONTACT US&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/vqkotB-TEOc" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/highlight-current-menu-item-in-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/highlight-current-menu-item-in-php</feedburner:origLink></item>
	
	<item>
		<title>Language Dependent Float</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/vVcAwE_XTuk/language-dependent-float</link>
		<comments>http://www.catswhocode.com/blog/snippets/language-dependent-float#comments</comments>
		<pubDate>Wed, 01 May 2013 11:58:07 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5523</guid>

		<description><![CDATA[When you need to build a theme that support in LTR but also in RTL you need small functions that makes life easier! This couple of function saved my a lot of time and weight on un-needed css code! Use it wisely yound jedi]]></description>
	
		<content:encoded><![CDATA[<pre>function fright() {
    if(is_rtl()) {echo 'fright';} else {echo 'fleft';}
}

function fleft() {
    if(is_rtl()) {echo 'fleft';} else {echo 'fleft';}
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/vVcAwE_XTuk" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/language-dependent-float/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/language-dependent-float</feedburner:origLink></item>
	
	<item>
		<title>Bookmark (aka: Link) Shortcode</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/ECGVV6hZtjc/bookmark-aka-link-shortcode</link>
		<comments>http://www.catswhocode.com/blog/snippets/bookmark-aka-link-shortcode#comments</comments>
		<pubDate>Fri, 22 Mar 2013 11:26:48 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5433</guid>

		<description><![CDATA[I wanted to use the built in WordPress admin link manager (now referred to as bookmarks) on a big site where links (especially external links) may occasionally change and be referred to in many places. Now I can manage my links in one place and by placing this snippet of code in the functions.php file I can use a shortcode to bring up any link by it's id.]]></description>
	
		<content:encoded><![CDATA[<pre>&lt;?php

	// Add Bookmark shortcode

	// Usage: [bookmark linkid=8]
	// Returns: &lt;a title=&quot;Extreme Web Design&quot; href=&quot;http://www.extremewebdesign.biz/&quot; target=&quot;_blank&quot;&gt;Extreme Web Design&lt;/a&gt;

	function bookmark_shortcode($atts, $content = null) {
		extract(shortcode_atts(array(
			'linkid' =&gt; '0'
		), $atts));
		$bookmark = get_bookmark($linkid);
		return '&lt;a title=&quot;' . $bookmark-&gt;link_description . '&quot; href=&quot;' . $bookmark-&gt;link_url . '&quot; target=&quot;' . $bookmark-&gt;link_target . '&quot;&gt;' . $bookmark-&gt;link_name . '&lt;/a&gt;';
	}
	add_shortcode(&quot;bookmark&quot;, &quot;bookmark_shortcode&quot;);

?&gt;</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/ECGVV6hZtjc" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/bookmark-aka-link-shortcode/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/bookmark-aka-link-shortcode</feedburner:origLink></item>
	
	<item>
		<title>Square Search Boxes in WebKit</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/oJjz_NonBAw/square-search-boxes-in-webkit</link>
		<comments>http://www.catswhocode.com/blog/snippets/square-search-boxes-in-webkit#comments</comments>
		<pubDate>Fri, 15 Feb 2013 15:49:16 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5267</guid>

		<description><![CDATA[Using -webkit-appearance: textfield allows developers to use input[type=search] elements that appear as a standard square INPUT. This is especially useful when looking to add a border to your INPUT element!]]></description>
	
		<content:encoded><![CDATA[<pre>input[type=search] {
  -webkit-appearance: textfield;
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/oJjz_NonBAw" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/square-search-boxes-in-webkit/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/square-search-boxes-in-webkit</feedburner:origLink></item>
	
	<item>
		<title>Base64 Encode of a 1*1px “spacer” gif</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/ba1mBtheK1g/base64-encode-of-a-11px-spacer-gif</link>
		<comments>http://www.catswhocode.com/blog/snippets/base64-encode-of-a-11px-spacer-gif#comments</comments>
		<pubDate>Wed, 06 Feb 2013 15:19:26 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5340</guid>

		<description><![CDATA[It's always useful!]]></description>
	
		<content:encoded><![CDATA[<pre>&lt;img src=&quot;data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7&quot;&gt;</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/ba1mBtheK1g" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/base64-encode-of-a-11px-spacer-gif/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/base64-encode-of-a-11px-spacer-gif</feedburner:origLink></item>
	
	<item>
		<title>Stitched elements in CSS3</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/Qq0CeCZ0v-c/stitched-elements-in-css3</link>
		<comments>http://www.catswhocode.com/blog/snippets/stitched-elements-in-css3#comments</comments>
		<pubDate>Wed, 30 Jan 2013 12:50:43 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5342</guid>

		<description><![CDATA[Stitched elements in CSS3]]></description>
	
		<content:encoded><![CDATA[<pre>p {
	padding: 5px 10px;
	margin: 10px;
	background: #ff0030;
	color: #fff;
	font-size: 21px;
	line-height: 1.3em;
	border: 2px dashed #fff;
	border-radius: 3px;
	-moz-border-radius: 3px;
	-webkit-border-radius: 3px;
	-moz-box-shadow: 0 0 0 4px #ff0030, 2px 1px 4px 4px rgba(10,10,0,.5);
	-webkit-box-shadow: 0 0 0 4px #ff0030, 2px 1px 4px 4px rgba(10,10,0,.5);
	box-shadow: 0 0 0 4px #ff0030, 2px 1px 6px 4px rgba(10,10,0,.5);
	text-shadow: -1px -1px #aa3030;
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/Qq0CeCZ0v-c" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/stitched-elements-in-css3/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/stitched-elements-in-css3</feedburner:origLink></item>
	
	<item>
		<title>Restrict wp-admin access to certain users</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/lGLfAuPXGts/restrict-wp-admin-access-to-certain-users</link>
		<comments>http://www.catswhocode.com/blog/snippets/restrict-wp-admin-access-to-certain-users#comments</comments>
		<pubDate>Tue, 22 Jan 2013 15:41:51 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5229</guid>

		<description><![CDATA[Adding this snippet to the functions.php of your wordpress theme will restrict wp-admin access to certain users as defined at

http://codex.wordpress.org/Roles_and_Capabilities

And also still allows for user access to admin-ajax.php , async-upload.php .]]></description>
	
		<content:encoded><![CDATA[<pre>function restrict_access_admin_panel(){
                global $current_user;
                get_currentuserinfo();
	
	if (
			// Look for the presence of /wp-admin/ in the url
			stripos($_SERVER['REQUEST_URI'],'/wp-admin/') !== false
			&amp;&amp;
			// Allow calls to async-upload.php
			stripos($_SERVER['REQUEST_URI'],'async-upload.php') == false
			&amp;&amp;
			// Allow calls to admin-ajax.php
			stripos($_SERVER['REQUEST_URI'],'admin-ajax.php') == false
		) {
	
				// Does the current user fail the required capability level?
                if (!current_user_can('activate_plugins')) {
                        wp_redirect( get_bloginfo('url') );
                        exit;
                }
			}		
        }
        add_action('admin_init', 'restrict_access_admin_panel', 1);</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/lGLfAuPXGts" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/restrict-wp-admin-access-to-certain-users/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/restrict-wp-admin-access-to-certain-users</feedburner:origLink></item>
	
	<item>
		<title>Multi-Line JavaScript Strings</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/LRgbf852ScA/multi-line-javascript-strings</link>
		<comments>http://www.catswhocode.com/blog/snippets/multi-line-javascript-strings#comments</comments>
		<pubDate>Fri, 18 Jan 2013 15:51:09 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5268</guid>

		<description><![CDATA[Adding a backslash at the end of each line tells the JavaScript engine that the string will continue to the next line, thus avoiding the automatic semicolon insertion annoyance.]]></description>
	
		<content:encoded><![CDATA[<pre>var multiStr = &quot;This is the first line \
  This is the second line \
  This is more...&quot;;</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/LRgbf852ScA" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/multi-line-javascript-strings/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/multi-line-javascript-strings</feedburner:origLink></item>
	
	<item>
		<title>Webkit/CSS3 reflection</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/73ZeDsrgpp8/webkitcss3-reflection</link>
		<comments>http://www.catswhocode.com/blog/snippets/webkitcss3-reflection#comments</comments>
		<pubDate>Mon, 17 Dec 2012 21:38:08 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5269</guid>

		<description><![CDATA[Only works with webkit.]]></description>
	
		<content:encoded><![CDATA[<pre>img {  
    -webkit-box-reflect: below 5px;  
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/73ZeDsrgpp8" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/webkitcss3-reflection/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/webkitcss3-reflection</feedburner:origLink></item>
	
	<item>
		<title>Calculate the Distance Between Two Points in PHP</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/z6OduVVoWrA/calculate-the-distance-between-two-points-in-php</link>
		<comments>http://www.catswhocode.com/blog/snippets/calculate-the-distance-between-two-points-in-php#comments</comments>
		<pubDate>Tue, 11 Dec 2012 15:20:46 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5265</guid>

		<description><![CDATA[Function to find the distance between two addresses by taking advantage of the Google Geotargetting API.]]></description>
	
		<content:encoded><![CDATA[<pre>function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) {
    $theta = $longitude1 - $longitude2;
    $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
    $miles = acos($miles);
    $miles = rad2deg($miles);
    $miles = $miles * 60 * 1.1515;
    $feet = $miles * 5280;
    $yards = $feet / 3;
    $kilometers = $miles * 1.609344;
    $meters = $kilometers * 1000;
    return compact('miles','feet','yards','kilometers','meters'); 
}

Usage:
$point1 = array('lat' =&gt; 40.770623, 'long' =&gt; -73.964367);
$point2 = array('lat' =&gt; 40.758224, 'long' =&gt; -73.917404);
$distance = getDistanceBetweenPointsNew($point1['lat'], $point1['long'], $point2['lat'], $point2['long']);
foreach ($distance as $unit =&gt; $value) {
    echo $unit.': '.number_format($value,4).'&lt;br /&gt;';
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/z6OduVVoWrA" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/calculate-the-distance-between-two-points-in-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/calculate-the-distance-between-two-points-in-php</feedburner:origLink></item>
	
	<item>
		<title>Image resizing using jQuery</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/Smkq9OEAf0Y/image-resizing-using-jquery</link>
		<comments>http://www.catswhocode.com/blog/snippets/image-resizing-using-jquery#comments</comments>
		<pubDate>Wed, 05 Dec 2012 18:02:47 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5266</guid>

		<description><![CDATA[jquery fixed image resize]]></description>
	
		<content:encoded><![CDATA[<pre>$(window).bind(&quot;load&quot;, function() {
	// IMAGE RESIZE
	$('#product_cat_list img').each(function() {
		var maxWidth = 120;
		var maxHeight = 120;
		var ratio = 0;
		var width = $(this).width();
		var height = $(this).height();
	
		if(width &gt; maxWidth){
			ratio = maxWidth / width;
			$(this).css(&quot;width&quot;, maxWidth);
			$(this).css(&quot;height&quot;, height * ratio);
			height = height * ratio;
		}
		var width = $(this).width();
		var height = $(this).height();
		if(height &gt; maxHeight){
			ratio = maxHeight / height;
			$(this).css(&quot;height&quot;, maxHeight);
			$(this).css(&quot;width&quot;, width * ratio);
			width = width * ratio;
		}
	});
	//$(&quot;#contentpage img&quot;).show();
	// IMAGE RESIZE
});</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/Smkq9OEAf0Y" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/image-resizing-using-jquery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/image-resizing-using-jquery</feedburner:origLink></item>
	
	<item>
		<title>Pure CSS tooltip</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/UXat5eMdic0/pure-css-tooltip</link>
		<comments>http://www.catswhocode.com/blog/snippets/pure-css-tooltip#comments</comments>
		<pubDate>Mon, 03 Dec 2012 15:11:58 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5123</guid>

		<description><![CDATA[Here is the HTML:
&#60;div class="tip"&#62;
  Lorem ipsum dolor sit amet...
&#60;/div&#62;]]></description>
	
		<content:encoded><![CDATA[<pre>/* base CSS element */
.tip {
  background: #eee;
  border: 1px solid #ccc;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
  position: relative;
  width: 200px;
}

/* arrows - :before and :after */
.tip:before {
  position: absolute;
  display: inline-block;
  border-top: 7px solid transparent;
  border-right: 7px solid #eee;
  border-bottom: 7px solid transparent;
  border-right-color: rgba(0, 0, 0, 0.2);
  left: -14px;
  top: 20px;
  content: '';
}

.tip:after {
  position: absolute;
  display: inline-block;
  border-top: 6px solid transparent;
  border-right: 6px solid #eee;
  border-bottom: 6px solid transparent;
  left: -12px;
  top: 21px;
  content: '';
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/UXat5eMdic0" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/pure-css-tooltip/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/pure-css-tooltip</feedburner:origLink></item>
	
	<item>
		<title>File download with speed limit</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/sdmEGxY94PM/file-download-with-speed-limit</link>
		<comments>http://www.catswhocode.com/blog/snippets/file-download-with-speed-limit#comments</comments>
		<pubDate>Fri, 30 Nov 2012 19:37:16 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5093</guid>

		<description><![CDATA[Simple but efficient code snippet to define a download speed.]]></description>
	
		<content:encoded><![CDATA[<pre>// local file that should be send to the client
$local_file = 'test-file.zip';
 
// filename that the user gets as default
$download_file = 'your-download-name.zip';
 
// set the download rate limit (=&gt; 20,5 kb/s)
$download_rate = 20.5;
 
if(file_exists($local_file) &amp;&amp; is_file($local_file)) {
 
    // send headers
    header('Cache-control: private');
    header('Content-Type: application/octet-stream');
    header('Content-Length: '.filesize($local_file));
    header('Content-Disposition: filename='.$download_file);
 
    // flush content
    flush();
 
    // open file stream
    $file = fopen($local_file, &quot;r&quot;);
 
    while (!feof($file)) {
 
        // send the current file part to the browser
        print fread($file, round($download_rate * 1024));
 
        // flush the content to the browser
        flush();
 
        // sleep one second
        sleep(1);
    }
 
    // close file stream
    fclose($file);
 
}
else {
    die('Error: The file '.$local_file.' does not exist!');
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/sdmEGxY94PM" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/file-download-with-speed-limit/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/file-download-with-speed-limit</feedburner:origLink></item>
	
	<item>
		<title>Download &amp; save a remote image on your server using PHP</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/iDEDAdwz9ss/download-save-a-remote-image-on-your-server-using-php</link>
		<comments>http://www.catswhocode.com/blog/snippets/download-save-a-remote-image-on-your-server-using-php#comments</comments>
		<pubDate>Wed, 28 Nov 2012 14:55:36 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5161</guid>

		<description><![CDATA[Easy way to download and save a remote image on your own server, using php.]]></description>
	
		<content:encoded><![CDATA[<pre>$image = file_get_contents('http://www.url.com/image.jpg');
file_put_contents('/images/image.jpg', $image); //Where to save the image on your server</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/iDEDAdwz9ss" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/download-save-a-remote-image-on-your-server-using-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/download-save-a-remote-image-on-your-server-using-php</feedburner:origLink></item>
	
	<item>
		<title>Redirect non logged in users</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/cABdIx-0mtY/redirect-non-logged-in-users</link>
		<comments>http://www.catswhocode.com/blog/snippets/redirect-non-logged-in-users#comments</comments>
		<pubDate>Thu, 08 Nov 2012 16:24:52 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5214</guid>

		<description><![CDATA[Bung this at the top of your index.php, home.php or custom front page and it will redirect non logged in users to a page called holding.php
An excellent way to develop a site on a live url.]]></description>
	
		<content:encoded><![CDATA[<pre>&lt;?php
/* Template Name: Custom Page */
if ( !is_user_logged_in()) {
get_template_part('holding');
exit(0);
}
get_header();
?&gt;</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/cABdIx-0mtY" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/redirect-non-logged-in-users/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/redirect-non-logged-in-users</feedburner:origLink></item>
	
	<item>
		<title>Custom Scrollbars in WebKit</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/GeC6O3ZcHP0/custom-scrollbars-in-webkit</link>
		<comments>http://www.catswhocode.com/blog/snippets/custom-scrollbars-in-webkit#comments</comments>
		<pubDate>Wed, 17 Oct 2012 14:40:57 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5191</guid>

		<description><![CDATA[Example of scrollbar customization (works in Webkit only)]]></description>
	
		<content:encoded><![CDATA[<pre>::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: none;
}

::-webkit-scrollbar-thumb {
  background: -webkit-linear-gradient(left, #547c90, #002640);
  border: 1px solid #333;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.4);
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/GeC6O3ZcHP0" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/custom-scrollbars-in-webkit/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/custom-scrollbars-in-webkit</feedburner:origLink></item>
	
	<item>
		<title>Easy way to link to your dynamic pages.</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/cZ3wD2qTyxs/easy-way-to-link-to-your-dynamic-pages</link>
		<comments>http://www.catswhocode.com/blog/snippets/easy-way-to-link-to-your-dynamic-pages#comments</comments>
		<pubDate>Mon, 24 Sep 2012 14:09:22 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5173</guid>

		<description><![CDATA[The first code snippet asks the database to get the 'id' wich in this case is the primary key and identifier for our rows. We ask the DB to get the latest added id and ad it to the variable $id.

The second code smippet is the actual link to your dynamic site. In this case my blog page on my site. Here we print out the blog link and HTML. Don't use this html if your links have diffirent html structure. In my case every blog entry have a diffirent ID, wich means the pages will look like this www.bjorngrunde.se/blog?id="xx" where xx is the uniqe identifier for the blog post. 

add the variable to the end of the link and your link always get the latest entry for that page!]]></description>
	
		<content:encoded><![CDATA[<pre>&lt;?php
		$dbc = mysqli_connect ('your_host', 'your_user', ''your_pw', 'your_db');
		$sql=(&quot;SELECT id FROM yourdatabase ORDER BY id DESC LIMIT 1&quot;);
		$result = mysqli_query($dbc, $sql);
		while($row = mysqli_fetch_array($result)) {	
		$id=$row['id'];
		}
?&gt;

//The Link
&lt;?php print (&quot;&lt;li&gt;&lt;a href=&quot;blog.php?id=&quot; . $id . &quot;&quot;&gt;Blog&lt;br /&gt;&lt;small&gt;My stories&lt;/small&gt;&lt;/a&gt;&lt;/li&gt;&quot;); ?&gt;</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/cZ3wD2qTyxs" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/easy-way-to-link-to-your-dynamic-pages/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/easy-way-to-link-to-your-dynamic-pages</feedburner:origLink></item>
	
	<item>
		<title>get_current_template() WordPress function.</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/FJCFsOzapa8/get_current_template-wordpress-function</link>
		<comments>http://www.catswhocode.com/blog/snippets/get_current_template-wordpress-function#comments</comments>
		<pubDate>Fri, 21 Sep 2012 14:09:12 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5157</guid>

		<description><![CDATA[Add this function to your functions.php file and it will return the current template name when called.]]></description>
	
		<content:encoded><![CDATA[<pre>function get_current_template() {
    global $wp_query;
    $template_name = str_replace('.php','',get_post_meta($wp_query-&gt;post-&gt;ID,'_wp_page_template',true));
    if ( $template_name ) return $template_name;
    else return false;
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/FJCFsOzapa8" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/get_current_template-wordpress-function/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/get_current_template-wordpress-function</feedburner:origLink></item>
	
	<item>
		<title>Automatically load content on scroll</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/NGLohN-53DE/automatically-load-content-on-scroll</link>
		<comments>http://www.catswhocode.com/blog/snippets/automatically-load-content-on-scroll#comments</comments>
		<pubDate>Fri, 14 Sep 2012 13:41:13 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5159</guid>

		<description><![CDATA[Simple code snippet to load content on scroll, as Twitter does.]]></description>
	
		<content:encoded><![CDATA[<pre>var loading = false;
$(window).scroll(function(){
	if((($(window).scrollTop()+$(window).height())+250)&gt;=$(document).height()){
		if(loading == false){
			loading = true;
			$('#loadingbar').css(&quot;display&quot;,&quot;block&quot;);
			$.get(&quot;load.php?start=&quot;+$('#loaded_max').val(), function(loaded){
				$('body').append(loaded);
				$('#loaded_max').val(parseInt($('#loaded_max').val())+50);
				$('#loadingbar').css(&quot;display&quot;,&quot;none&quot;);
				loading = false;
			});
		}
	}
});

$(document).ready(function() {
	$('#loaded_max').val(50);
});</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/NGLohN-53DE" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/automatically-load-content-on-scroll/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/automatically-load-content-on-scroll</feedburner:origLink></item>
	
	<item>
		<title>Pure CSS Text gradient</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/qeWKqZJ6-CY/pure-css-text-gradient</link>
		<comments>http://www.catswhocode.com/blog/snippets/pure-css-text-gradient#comments</comments>
		<pubDate>Wed, 12 Sep 2012 09:26:15 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5158</guid>

		<description><![CDATA[Awesome text gradient, made in 100% pure CSS.]]></description>
	
		<content:encoded><![CDATA[<pre>h2[data-text] {
	position: relative;
}
h2[data-text]::after {
	content: attr(data-text);
	z-index: 10;
	color: #e3e3e3;
	position: absolute;
	top: 0;
	left: 0;
	-webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,0)), color-stop(50%, rgba(0,0,0,1)), to(rgba(0,0,0,0)));</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/qeWKqZJ6-CY" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/pure-css-text-gradient/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/pure-css-text-gradient</feedburner:origLink></item>
	
	<item>
		<title>Remove automatic link to WLW manifest file</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/S7M_Vk2rMpI/remove-automatic-link-to-wlw-manifest-file</link>
		<comments>http://www.catswhocode.com/blog/snippets/remove-automatic-link-to-wlw-manifest-file#comments</comments>
		<pubDate>Mon, 10 Sep 2012 08:23:05 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=4904</guid>

		<description><![CDATA[Kind of pointless to include this unless you actually use Windows Live Writer to write your posts. Put this in the theme's functions.php file.]]></description>
	
		<content:encoded><![CDATA[<pre>remove_action( 'wp_head', 'wlwmanifest_link');</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/S7M_Vk2rMpI" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/remove-automatic-link-to-wlw-manifest-file/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/remove-automatic-link-to-wlw-manifest-file</feedburner:origLink></item>
	
	<item>
		<title>CSS Triangles</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/fw9VYI176ag/css-triangles</link>
		<comments>http://www.catswhocode.com/blog/snippets/css-triangles#comments</comments>
		<pubDate>Sat, 08 Sep 2012 14:35:45 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5124</guid>

		<description><![CDATA[Triangles in pure CSS!]]></description>
	
		<content:encoded><![CDATA[<pre>/* create an arrow that points up */
div.arrow-up {
  width:0px; 
  height:0px; 
  border-left:5px solid transparent;  /* left arrow slant */
  border-right:5px solid transparent; /* right arrow slant */
  border-bottom:5px solid #2f2f2f; /* bottom, add background color here */
  font-size:0px;
  line-height:0px;
}

/* create an arrow that points down */
div.arrow-down {
  width:0px; 
  height:0px; 
  border-left:5px solid transparent;
  border-right:5px solid transparent;
  border-top:5px solid #2f2f2f;
  font-size:0px;
  line-height:0px;
}

/* create an arrow that points left */
div.arrow-left {
  width:0px; 
  height:0px; 
  border-bottom:5px solid transparent;  /* left arrow slant */
  border-top:5px solid transparent; /* right arrow slant */
  border-right:5px solid #2f2f2f; /* bottom, add background color here */
  font-size:0px;
  line-height:0px;
}

/* create an arrow that points right */
div.arrow-right {
  width:0px; 
  height:0px; 
  border-bottom:5px solid transparent;  /* left arrow slant */
  border-top:5px solid transparent; /* right arrow slant */
  border-left:5px solid #2f2f2f; /* bottom, add background color here */
  font-size:0px;
  line-height:0px;
}</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/fw9VYI176ag" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/css-triangles/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/css-triangles</feedburner:origLink></item>
	
	<item>
		<title>Get current url with PHP</title>
		<link>http://feedproxy.google.com/~r/catswhocode-snippets/~3/eax1uRV3As0/get-current-url-with-php</link>
		<comments>http://www.catswhocode.com/blog/snippets/get-current-url-with-php#comments</comments>
		<pubDate>Tue, 21 Aug 2012 14:31:55 +0000</pubDate>
		<dc:creator />
		<guid isPermaLink="false">http://www.catswhocode.com/blog/?post_type=snippets&amp;p=5054</guid>

		<description><![CDATA[Useful code snippet to get current url using PHP.]]></description>
	
		<content:encoded><![CDATA[<pre>function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER[&quot;HTTPS&quot;] == &quot;on&quot;) {$pageURL .= &quot;s&quot;;}
 $pageURL .= &quot;://&quot;;
 if ($_SERVER[&quot;SERVER_PORT&quot;] != &quot;80&quot;) {
  $pageURL .= $_SERVER[&quot;SERVER_NAME&quot;].&quot;:&quot;.$_SERVER[&quot;SERVER_PORT&quot;].$_SERVER[&quot;REQUEST_URI&quot;];
 } else {
  $pageURL .= $_SERVER[&quot;SERVER_NAME&quot;].$_SERVER[&quot;REQUEST_URI&quot;];
 }
 return $pageURL;
}
echo curPageURL();</pre>
<img src="http://feeds.feedburner.com/~r/catswhocode-snippets/~4/eax1uRV3As0" height="1" width="1"/>]]></content:encoded>
	
		<wfw:commentRss>http://www.catswhocode.com/blog/snippets/get-current-url-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>

	<feedburner:origLink>http://www.catswhocode.com/blog/snippets/get-current-url-with-php</feedburner:origLink></item>
	
</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

 Served from: www.catswhocode.com @ 2013-05-26 01:12:14 by W3 Total Cache -->
