Skip to content

Instantly share code, notes, and snippets.

View jameshibbard's full-sized avatar

James Hibbard jameshibbard

View GitHub Profile
@jameshibbard
jameshibbard / gist:3074765
Created July 9, 2012 07:16
Two column HTML template with basic styling
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple template</title>
<style type="text/css">
<!--
*{
margin: 0;
padding: 0;
@jameshibbard
jameshibbard / gist:3076112
Created July 9, 2012 12:09
Sample header file for WordPress site
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php wp_title('|', 1, 'right'); ?> <?php bloginfo('name'); ?></title>
<link rel="Stylesheet" type="text/css" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" />
<?php wp_head(); ?>
</head>
<body>
@jameshibbard
jameshibbard / gist:3076124
Created July 9, 2012 12:12
Sample sidebar file for WordPress site
<div class="sidebar">
<?php if ( !function_exists('dynamic_sidebar') || dynamic_sidebar('Sidebar') ) : ?>
<?php endif; ?>
</div>
<div class="content">
@jameshibbard
jameshibbard / gist:3076165
Created July 9, 2012 12:23
Sample footer file for WordPress site
</div> <!-- end .content-->
<div class="footer">
<p>Footer text here.</p>
</div> <!-- end .footer -->
</div> <!-- end .container -->
</body>
</html>
@jameshibbard
jameshibbard / gist:3076252
Created July 9, 2012 12:41
Sample index file for WordPress site
<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content('Read more...'); ?>
<?php endwhile; endif; ?>
<?php get_footer(); ?>
@jameshibbard
jameshibbard / gist:3076320
Created July 9, 2012 12:51
Sample functions.php file for WordPress site
<?php
if ( function_exists('register_sidebar') ) {
register_sidebar(array('name' => 'Sidebar',
'description' => 'Sidebar for navigation',
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '',
'after_title' => ''));
@jameshibbard
jameshibbard / gist:3106998
Created July 13, 2012 19:50
Simple ruby class
class Person
attr_accessor :name, :age
def initialize(name, age)
@name, @age = name, age
end
end
bob= Person.new("Robert DeNiro", 68)
p bob
@jameshibbard
jameshibbard / gist:3107044
Created July 13, 2012 20:00
Inspect an object in PHP
<?php
// get_term_by returns an object
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$array = get_object_vars($term);
while (list($key, $val) = each($array)) {
echo "$key => $val"."<br />";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form validation example</title>
<style>
input{display:block; margin-bottom:10px;}
</style>
</head>
@jameshibbard
jameshibbard / validation_example_1.php
Created July 25, 2012 19:45
Simple HTML form with basic PHP validation
<?php
if ($_POST['process'] == 1) {
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
if (empty($first_name) && empty($last_name)){
echo "Howdy, stranger";
}else{
echo "Hello there, ".$first_name." ".$last_name;
}
}