Skip to content

Instantly share code, notes, and snippets.

View jameshibbard's full-sized avatar

James Hibbard jameshibbard

View GitHub Profile
@jameshibbard
jameshibbard / archive_trello.rb
Created May 5, 2015 19:07
Archive Trello cards from a specified list, which are older than a specified date
# Archive Trello Cards Programatically
#
# Get TRELLO_DEVELOPER_PUBLIC_KEY from:
# https://trello.com/1/appKey/generate
#
# Get TRELLO_MEMBER_TOKEN from:
# https://trello.com/1/authorize?key=TRELLO_DEVELOPER_PUBLIC_KEY&name=Arch&expiration=never&response_type=token&scope=read,write
# substituting TRELLO_DEVELOPER_PUBLIC_KEY for your actual key
#
# Get BOARD_ID (alphanumeric string, found in the board's URL):
@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 />";
}
?>
@jameshibbard
jameshibbard / validation_example_2.php
Created July 25, 2012 20:00
Simple HTML form with slightly more complicated PHP validation
<?php
if ($_POST['process'] == 1) {
$first_name = htmlentities($_POST['first_name']);
$last_name = htmlentities($_POST['last_name']);
if (empty($last_name)){
echo "<p class=\"error\">Your last name cannot be blank</p>";
} else {
echo "<p>Hello there, ".$first_name." ".$last_name."</p>";
}
}