Skip to content

Instantly share code, notes, and snippets.

View jlittlejohn's full-sized avatar

Josh Littlejohn jlittlejohn

View GitHub Profile
@jlittlejohn
jlittlejohn / JS: Persistent Navigation
Created October 8, 2012 17:15
JS: Persistent Navigation
$(document).ready(function(){
$(window).scroll(function(){
var h = $('body').height();
var y = $(window).scrollTop();
if( y > (h*.03) && y < (h) ){
$("#header").addClass("compact fade-in-down");
} else {
$('#header').removeClass(' compact fade-in-down');
}
});
@jlittlejohn
jlittlejohn / gist:3853722
Created October 8, 2012 17:21
JS: Add/Remove Active State
$(document).ready(function(){
$("nav.tabs li a").click(function(){
$(" nav.tabs li .active").removeClass("active");
$(this).addClass("active");
});
});
@jlittlejohn
jlittlejohn / gist:3866581
Created October 10, 2012 16:06
WP: Output Custom Field from Post
<?php echo get_post_meta($post->ID, 'my_key', true); ?>
@jlittlejohn
jlittlejohn / gist:3867718
Created October 10, 2012 19:05
WP: Output Posts from Custom Post Type
<?php
$args = array( 'post_type' => 'my_post_type', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<h2>';
the_title();
echo '</h2><p>';
the_excerpt(); // the_content();
echo '</p><a href="';
the_permalink();
@jlittlejohn
jlittlejohn / WP Hide Admin Bar
Created October 11, 2012 21:35
WP: Hide Admin Bar
// ADMIN BAR TO HIDE DURING DEV
html {
margin-top: 0 !important;
}
#wpadminbar {
display: none;
}
@jlittlejohn
jlittlejohn / gist:4008318
Created November 3, 2012 19:11
JS: Utility Function in a Closure
(function( $ ){
$.fn.example = function() {
// some code
};
})( jQuery );
@jlittlejohn
jlittlejohn / gist:4067632
Created November 13, 2012 18:50
RoR: Add Image with Attributes
= image_tag "x.png", :title => 'x', :alt => 'x', :class => 'class-name'
@jlittlejohn
jlittlejohn / gist:4067685
Created November 13, 2012 19:00
RoR: Insert Link with Attributes
= link_to "Link Text", 'www.google.com', :title => 'My Link Title'
@jlittlejohn
jlittlejohn / gist:4083094
Created November 16, 2012 01:28
SCSS: Mixin with Argument
@mixin mixin-name($variable: defaultValue) {
// code: $variable;
}
@jlittlejohn
jlittlejohn / gist:4083103
Created November 16, 2012 01:30
SCSS: Mixin with Variables
@mixin mixin-name {
$variable: value;
// code: $variable;
}