Useful (and free!) Code Snippets

I reviewed Coda a few months ago and have been using it ever since. It’s an awesome all-in-one IDE with Transmit for FTP and great plugin support.

My favorite feature of Coda is Coda Clips, a similar feature was also introduced in Dreamweaver CS4. Coda Clips allows you to store snippets of code you use frequently in an attractive window and inserts the code into your open document with one click.

I thought I’d share my snippets with you, organized by type. Please feel free to share some of your in the comments!


Lorem Ipsum Paragraph Generator
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


/****CSS Framework w/ Reset*******/
/*****CSS RESET*******/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code,del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center,dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {  margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; }body { line-height: 1; }ol, ul { list-style: none; }blockquote, q { quotes: none; }blockquote:before, blockquote:after,q:before, q:after { content: ''; content: none; }:focus { outline: 0; }ins { text-decoration: none; }del { text-decoration: line-through; }table { border-collapse: collapse; border-spacing: 0; }
/****BODY STYLES********/
body { font-family: Arial; font-size: 14px; color: #3A454F; }.home { background: url('images/bkgHome.jpg') repeat-x #FFF top; }
p { line-height: 17px; }
h1 { font-size: 30px; }
#container { margin: 0 auto; }.home #container { width: 800px; }
/****HEADER STYLES*******/
/*****NAV STYLES*******/
/*****FOOTER STYLES*******/
/*****SUB CONTENT STYLES*******/
/****CSS3 Rounded Corners*******/
 { -moz-border-radius: 5px; -webkit-border-radius: 5px; }

Hacks & Validation

/****Browser Hacks (For emergencies only!)*******/
/*For Safari*/
html* #div {  }
/*For IE7*/
*+html #div {  }
/*For IE6*/
*html #div {}
<!--IE6 Conditional Stylesheet-->
<!--[if IE 6]>
	<link href="ie6.css" mce_href="ie6.css" type="text/css" rel="stylesheet" media="screen" />
<!--Force IE8 to display as IE7-->
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<!--XHTML 1.0 Strict Valid Flash Script-->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase=",0,40,0"><param name="data" value="flash.swf?path=flash.swf" /><param name="src" value="flash.swf?path=flash.swf" /><embed type="application/x-shockwave-flash" width="400" height="300" src="flash.swf?path=flash.swf" data="flash.swf?path=flash.swf"></embed></object>


/*Automatic New Browser Window*/
$(document).ready( function(){
	$("a[href^='http://'],a[href^='https://']").attr('target', '_blank');


//Template Index (Auto includes header &amp; footer files)
	if ($_GET['p'])
		$p = $_GET['p'];
		$p = "main";
	require_once('tem/' . $p . '.tem.php');
//Automatically Updating Copyright Year
&copy; <?php echo date("Y") ?>


// Loop Based on Custom Fields
 $querydetails = "
   SELECT wposts.*
   FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
   WHERE wposts.ID = wpostmeta.post_id
   AND wpostmeta.meta_key = 'readmoretext'
   AND wpostmeta.meta_value = 'Go check this out'
   AND wposts.post_status = 'publish'
   AND wposts.post_type = 'post'
   ORDER BY wposts.post_date DESC
 $pageposts = $wpdb->get_results($querydetails, OBJECT)
<?php if ($pageposts):
 foreach ($pageposts as $post):
       setup_postdata($post); ?>
               // Make your loop here. For example :
               <div <?php post_class(); ?>> id="post-<?php the_ID(); ?>">
               <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
               <?php the_content(); ?>
 <?php endforeach;
endif; ?>
//Custom login/logout message
<div id="user-details">
   if (is_user_logged_in()) {
      $user = wp_get_current_user();
      echo ‘Welcome back <strong>.$user->display_name.</strong> !;
   } else { ?>
      Please <strong><?php wp_loginout(); ?></strong>
      or <a href="<?php echo get_option(’home’); ?>/wp-login.php?action=register"> <strong>Register</strong></a>
<?php } ?>

Your Turn

What are some of your snippets?

So you like sharing your code snippets?

Then I suggest you also head over to our secret project at and sign up for a beta account 🙂