<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>Byte-size Code Snippets for Web Developers</description><title>CodeByte</title><generator>Tumblr (3.0; @codebyte)</generator><link>http://codebyte.dev7studios.com/</link><item><title>CSS Micro Clearfix </title><description>&lt;p&gt;&lt;pre&gt;&lt;code class="css"&gt;/* For modern browsers */
.cf:before,
.cf:after {
    content:"";
    display:block;
}

.cf:after {
    clear:both;
}

/* For IE 6/7 (trigger hasLayout) */
.cf {
    zoom:1;
}&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/4802798033</link><guid>http://codebyte.dev7studios.com/post/4802798033</guid><pubDate>Thu, 21 Apr 2011 11:35:47 +0100</pubDate><category>css</category><category>clearfix</category></item><item><title>Add Browser to Body Class in WordPress</title><description>&lt;p&gt;Put the following in your &lt;code&gt;functions.php&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code class="php"&gt;add_filter('body_class','browser_body_class');
function browser_body_class($classes) {
    global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;
    if($is_lynx) $classes[] = 'lynx';
    elseif($is_gecko) $classes[] = 'gecko';
    elseif($is_opera) $classes[] = 'opera';
    elseif($is_NS4) $classes[] = 'ns4';
    elseif($is_safari) $classes[] = 'safari';
    elseif($is_chrome) $classes[] = 'chrome';
    elseif($is_IE) $classes[] = 'ie';
    else $classes[] = 'unknown';
    if($is_iphone) $classes[] = 'iphone';
    return $classes;
}&lt;/code&gt;&lt;/pre&gt;</description><link>http://codebyte.dev7studios.com/post/4180628671</link><guid>http://codebyte.dev7studios.com/post/4180628671</guid><pubDate>Tue, 29 Mar 2011 08:55:25 +0100</pubDate><category>php</category><category>wordpress</category><category>browser</category></item><item><title>New CSS Clearfix</title><description>&lt;p&gt;&lt;pre&gt;&lt;code class="css"&gt;/* new clearfix */
.clearfix:after {
    visibility: hidden;
    display: block;
    font-size: 0;
    content: " ";
    clear: both;
    height: 0;
    }
* html .clearfix             { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/3344122685</link><guid>http://codebyte.dev7studios.com/post/3344122685</guid><pubDate>Thu, 17 Feb 2011 13:18:37 +0000</pubDate><category>css</category><category>clearfix</category></item><item><title>WordPress is_child() and is_ancestor()</title><description>&lt;p&gt;Put the following in your &lt;code&gt;functions.php&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code class="php"&gt;// Check if page is direct child
function is_child($page_id) { 
    global $post; 
    if( is_page() &amp;amp;&amp;amp; ($post-&amp;gt;post_parent == $page_id) ) {
       return true;
    } else { 
       return false; 
    }
}

// Check if page is an ancestor
function is_ancestor($post_id) {
    global $wp_query;
    $ancestors = $wp_query-&amp;gt;post-&amp;gt;ancestors;
    if ( in_array($post_id, $ancestors) ) {
        return true;
    } else {
        return false;
    }
}&lt;/code&gt;&lt;/pre&gt;</description><link>http://codebyte.dev7studios.com/post/3313452026</link><guid>http://codebyte.dev7studios.com/post/3313452026</guid><pubDate>Tue, 15 Feb 2011 20:35:00 +0000</pubDate><category>wordpress</category><category>php</category></item><item><title>CSS Horizontal and Vertical Center</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;/* Horizontal Center */
#horcntr {
    width: 300px; /* Change this to your container width */
    margin: 0 auto;
}
/* Vertical Center */
#vercntr {
    position: absolute; 
    top: 50%; 
    height: 200px; /* Change this to your container height */
    margin-top: -100px; /* This should be half your container height */
}&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/2622539815</link><guid>http://codebyte.dev7studios.com/post/2622539815</guid><pubDate>Thu, 06 Jan 2011 12:35:00 +0000</pubDate><category>Css</category><category>submission</category></item><item><title>Hide WordPress Login Page Error Feedback</title><description>&lt;p&gt;Put the following in your &lt;code&gt;functions.php&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;add_filter('login_errors',create_function('$a', "return null;"));
&lt;/code&gt;&lt;/pre&gt;</description><link>http://codebyte.dev7studios.com/post/2622507247</link><guid>http://codebyte.dev7studios.com/post/2622507247</guid><pubDate>Thu, 06 Jan 2011 12:30:37 +0000</pubDate><category>php</category><category>wordpress</category></item><item><title>Dynamically Load jQuery using Javascript</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;if(!("jQuery" in window)) {
    var head = document.getElementsByTagName('head')[0],
    script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';
    head.appendChild(script);
}&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/2069425883</link><guid>http://codebyte.dev7studios.com/post/2069425883</guid><pubDate>Thu, 02 Dec 2010 08:58:22 +0000</pubDate><category>javascript</category><category>jquery</category><category>dom</category></item><item><title>Asynchronous Tweet Button</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;a href="http://twitter.com/share" class="twitter-share-button" data-count="vertical"&amp;gt;Tweet&amp;lt;/a&amp;gt;

&amp;lt;!-- Put this JS at the bottom of the page --&amp;gt;
&amp;lt;script id="deferedjs" type="text/javascript"&amp;gt;
var b = document.createElement('script');
b.type = 'text/javascript';
b.src = ('http://platform.twitter.com/widgets.js');
var a=document.getElementById("deferedjs");
a.parentNode.insertBefore(b,a);
&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1678918588</link><guid>http://codebyte.dev7studios.com/post/1678918588</guid><pubDate>Thu, 25 Nov 2010 09:12:25 +0000</pubDate><category>Twitter</category><category>javascript</category><category>async</category></item><item><title>PHP Check if a Number is Odd or Even</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;$num = 10;
echo ($num&amp;amp;1) ? "odd" : "even";
&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1626652631</link><guid>http://codebyte.dev7studios.com/post/1626652631</guid><pubDate>Sat, 20 Nov 2010 11:57:47 +0000</pubDate><category>php</category><category>comparison</category></item><item><title>Simple CSS Reset</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;* {margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; line-height: 1; list-style: none; quotes: none; content: ''; content: none; }&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1626619708</link><guid>http://codebyte.dev7studios.com/post/1626619708</guid><pubDate>Sat, 20 Nov 2010 11:50:20 +0000</pubDate><category>Css</category><category>reset</category><category>submission</category></item><item><title>PHP Format Filesize</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;function filesize_format($size, $sizes = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'))
{
    if ($size == 0) return('n/a');
    return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
}&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1590919646</link><guid>http://codebyte.dev7studios.com/post/1590919646</guid><pubDate>Tue, 16 Nov 2010 12:54:04 +0000</pubDate><category>php</category><category>file</category><category>file size</category><category>formatting</category></item><item><title>PHP: comma_list_ended() function</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;/**
 * comma_list_ended()
 * returns a string list of the items in an array, using
 * a specified last word to substitute the last comma.
 *
 * eg. a, b, c, d and e
 *     1, 2, 3, 4 or 5
 *
 * @author: Andy Thomas (forrst@antom.co.uk)
 * @date: 03/11/2010
 */

function comma_list_ended($arr,$last = 'and') {
        return preg_replace("/,([^,]*)$/", " {$last} $1", join($arr,', '));
}&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1471547127</link><guid>http://codebyte.dev7studios.com/post/1471547127</guid><pubDate>Wed, 03 Nov 2010 16:55:17 +0000</pubDate><category>php</category><category>comma</category><category>list</category></item><item><title>Set CSS Style sheet for IE and IE8</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;&amp;lt;!--[if IE]&amp;gt;
  &amp;lt;link href="css/ie.css" rel="stylesheet" type="text/css" /&amp;gt;
&amp;lt;![endif]--&amp;gt;
 
&amp;lt;!--[if IE 8]&amp;gt;
  &amp;lt;link href="css/ie8.css" rel="stylesheet" type="text/css" /&amp;gt;
&amp;lt;![endif]--&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1471533156</link><guid>http://codebyte.dev7studios.com/post/1471533156</guid><pubDate>Wed, 03 Nov 2010 16:52:00 +0000</pubDate><category>Css</category><category>ie</category><category>submission</category></item><item><title>Simple Javascript Check for Opera Browser</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;var Opera = /opera/i.test(navigator.userAgent);
if (Opera) {
    // Opera specific stuff
}&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1469503104</link><guid>http://codebyte.dev7studios.com/post/1469503104</guid><pubDate>Wed, 03 Nov 2010 09:31:10 +0000</pubDate><category>opera</category><category>browser</category><category>javascript</category></item><item><title>URL Retweet Count Using PHP</title><description>&lt;p&gt;&lt;pre&gt;&lt;code class="php"&gt;function tweetCount($url) {
    $content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url);
    $element = new SimpleXmlElement($content);
    $retweets = $element-&amp;gt;story-&amp;gt;url_count;
    if($retweets){
        return $retweets;
    } else {
        return 0;
    }
}&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1400054206</link><guid>http://codebyte.dev7studios.com/post/1400054206</guid><pubDate>Mon, 25 Oct 2010 20:52:33 +0100</pubDate><category>php</category><category>twitter</category><category>retweet</category></item><item><title>Using @font-face in CSS</title><description>&lt;p&gt;&lt;pre&gt;&lt;code&gt;@font-face {
  font-family: "Your typeface";
  src: url("type/filename.eot"),
       url("type/filename.woff") format("woff"),
       url("type/filename.otf") format("opentype"),
       url("type/filename.svg#filename") format("svg");
}

body {
    font-family: "Your typeface", sans-serif;
}&lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1297589337</link><guid>http://codebyte.dev7studios.com/post/1297589337</guid><pubDate>Tue, 12 Oct 2010 09:01:05 +0100</pubDate><category>css</category><category>font-face</category></item><item><title>PHP Zeroise</title><description>&lt;p&gt;Add leading zeros to a number.&lt;/p&gt;

&lt;pre&gt;&lt;code class="php"&gt;function zeroise($number, $threshold) {
    return sprintf('%0'.$threshold.'s', $number);
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you set the threshold to &amp;#8216;4&amp;#8217; and the number is &amp;#8216;10&amp;#8217;, then you will get back &amp;#8216;0010&amp;#8217;. If you set the number to &amp;#8216;4&amp;#8217; and the number is &amp;#8216;5000&amp;#8217;, then you will get back &amp;#8216;5000&amp;#8217;.&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1269464720</link><guid>http://codebyte.dev7studios.com/post/1269464720</guid><pubDate>Fri, 08 Oct 2010 15:59:37 +0100</pubDate><category>php</category><category>worpdress</category><category>formatting</category><category>zeros</category></item><item><title>C# ?? null coalescing operator</title><description>&lt;p&gt;The&amp;#160;?? operator checks whether the value provided on the left side of the expression is null, and if so it returns an alternate value indicated by the right side of the expression:&lt;/p&gt;

&lt;pre&gt;&lt;code class="cs"&gt;string message = null;
string result = message ?? "Undefined";
// result == "Undefined"&lt;/code&gt;&lt;/pre&gt;</description><link>http://codebyte.dev7studios.com/post/1241554507</link><guid>http://codebyte.dev7studios.com/post/1241554507</guid><pubDate>Mon, 04 Oct 2010 10:02:52 +0100</pubDate><category>C</category><category>null</category></item><item><title>PHP Limit String to Words or Sentences</title><description>&lt;p&gt;To limit a string to only first 3 sentences:&lt;/p&gt;

&lt;pre&gt;&lt;code class="php"&gt;&amp;lt;?php
preg_match('/^([^.!?]*[\.!?]+){0,3}/', strip_tags($text), $abstract);
echo $abstract[0];
?&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To limit a string to only first 30 words:&lt;/p&gt;

&lt;pre&gt;&lt;code class="php"&gt;&amp;lt;?php
preg_match('/^([^.!?\s]*[\.!?\s]+){0,30}/', strip_tags($text), $abstract);
echo $abstract[0];
?&amp;gt;&lt;/code&gt;&lt;/pre&gt;</description><link>http://codebyte.dev7studios.com/post/1221622245</link><guid>http://codebyte.dev7studios.com/post/1221622245</guid><pubDate>Fri, 01 Oct 2010 13:50:53 +0100</pubDate><category>php</category><category>limit</category><category>abstract</category></item><item><title>WordPress Simple Time Ago</title><description>&lt;pre&gt;&lt;code class="php"&gt;Posted &amp;lt;?php echo human_time_diff(get_the_time('U'), current_time('timestamp')); ?&amp;gt; ago &lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(Needs to be used within &lt;a href="http://codex.wordpress.org/The_Loop"&gt;the loop&lt;/a&gt;)&lt;/p&gt;</description><link>http://codebyte.dev7studios.com/post/1209598584</link><guid>http://codebyte.dev7studios.com/post/1209598584</guid><pubDate>Wed, 29 Sep 2010 10:12:51 +0100</pubDate><category>php</category><category>wordpress</category><category>time</category></item></channel></rss>
