Skip to content

Instantly share code, notes, and snippets.

View turboclaw's full-sized avatar

Dan Nixon turboclaw

View GitHub Profile
@turboclaw
turboclaw / gist:3785519
Created September 26, 2012 01:47
Animating height, in "height:auto;" situations
/* Animate max-height instead! */
div {
max-height: 1em;
transition: 1s;
}
div:hover {
max-height: 1000em;
}​
@turboclaw
turboclaw / single.php
Created December 18, 2012 00:54
Single post with an image gallery
<?php get_header(); ?>
<div class="leftside">
<?php while ( have_posts() ) : the_post(); ?>
<h3 class="title"><?php the_title(); ?></h3>
<h4 class="date"> ... </h4>
<div class="description">
<?php the_content(); ?>
<!DOCTYPE HTML>
<html>
<head>
<title><?php bloginfo('name'); ?><?php wp_title('|'); ?></title>
<link rel="icon" href="<?php bloginfo('template_directory'); ?>/favicon.ico" type="image/x-icon">
<link rel="stylesheet" media="all" href="<?php bloginfo('stylesheet_url'); ?>" />
<link href='http://fonts.googleapis.com/css?family=Amatic+SC:400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
<?php if(is_single()) { /* Only load lightbox if on a single post */ ?>
@turboclaw
turboclaw / sidebar.php
Created December 18, 2012 02:00
If you're not worried about having to edit this content from inside Wordpress, you can just leave it hard coded in this file. That's probably what I'd do.
<div class="rightside">
<a href="index.html"><img src="images/bfglogo.png" class="bfglogo"></a>
<p class="name">
Josh A. Weston
</p>
<p class="subhead">
Strategy | Art direction | Design
</p>
<p class="date">
@turboclaw
turboclaw / gist:4324786
Created December 18, 2012 03:39
This example will look for the first image in a post, and, if there is one, will display a 75 x 75 pixel thumbnail of it. You can pass an array with width and height, or a size keyword (see here: http://codex.wordpress.org/Function_Reference/wp_get_attachment_image).
<?php
$images = get_children('post_parent='.$post->ID.'&post_type=attachment&post_mime_type=image&numberposts=1&order=ASC');
if(!empty($images)){
echo wp_get_attachment_image(reset($images)->ID, array(75,75));
}
?>
@turboclaw
turboclaw / localeFormattedDate.js
Created March 3, 2014 20:59
Simple HBS/Moment.js helper
// use in .hbs template: {{localeFormattedDate dateToConvert}}
Handlebars.registerHelper("localeFormattedDate", function( context, block ) {
if ( window.moment ) {
return moment( Date(context) ).format( config.locale.dateFormat );
}else{
return context;
}
});