Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View drainpip's full-sized avatar

Shane Duff drainpip

View GitHub Profile
body {
font-size: 100%;
}
body, caption, th, td, input, textarea, select, option, legend, fieldset, h1, h2, h3, h4, h5, h6 {
font-size-adjust: 0.5;
}
#page {
font-size: 1em;
@drainpip
drainpip / Social-Defs.svg
Last active August 29, 2015 14:18
A snippet to include the most common social networking icons as SVG defs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drainpip
drainpip / wordpress_songkick.php
Last active December 10, 2015 21:58
Raw PHP for Wordpress / Songkick integration. Further work is needed on making this into a more robust function using Wordpress' current features.
<?php
// Artist is custom field key for post
$key_songkick = "Artist";
// Check post to see if Artist custom field exists
if ( get_post_meta($post->ID, $key_songkick, true) ) :
// Need to search by Artist name since we don't know ID, need ID to get the artist calendar.
// Using urlencode since we can't send a space to the Songkick JSON request
$Artist = urlencode(get_post_meta($post->ID, $key_songkick, true));
// Use your API key here
@drainpip
drainpip / last-child-section-padding.js
Last active December 11, 2015 06:39
Updates last section bottom padding inside a sticky footer design. This allows the top of the section to fit into the top of the viewport when the page would end at the top of the footer.
function updateHeight() {
if (($(window).height()) > $("section:last-child").height()) {
$("section:last-child").css("padding-bottom", $(window).height() - ($("section:last-child").height() + $("#footer").height() + 30) + "px"); // adjust the number for extra padding depending upon your site
} else {
$("section:last-child").css("padding-bottom", "0px");
}
}
// call on DOM load
updateHeight();
@drainpip
drainpip / accordion.html
Last active December 16, 2015 07:39
Super simple accordion. Assumes jQuery. Style it for bad ass options. The script as written will close anything that's open upon clicking any .accordion-button object. Adding an extra if statement to check will stop that if you wish, but then it's technically not an accordion.
<style>
.accordion-button {cursor:pointer;} /* visual cue for user */
.accordion-button.on { /* insert style for on state */ }
.accordion-content {display:none; overflow:hidden;} /* Hide on page load, overflow:hidden is to keep things from hopping around */
.accordion-content.open {display:block;} /* allows to set one open on page load
</style>
<ul>
<li class="accordion-button">Title / heading here</li>
<li class="accordion-content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam in nibh eget augue tincidunt elementum nec vel tellus. Fusce vestibulum dictum leo, ac varius nisi sagittis vel. Aenean sed est id arcu adipiscing semper eu vel mi. In bibendum est sit amet urna gravida vel hendrerit sapien pharetra.</li>
@drainpip
drainpip / affix-to-top.js
Created April 19, 2013 22:50
Assumes jQuery. This will detect the position of your ID, check if it's got a margin on the top and remove it. If the ID reaches the top of the screen, then it will add a class fixed. Obviously you would need to make position:fixed; part of the fixed class, plus add in the actual fixed position.
$(function () {
var top = $('#ID').offset().top - parseFloat($('#ID').css('margin-top').replace(/auto/, 0)); // math is there in case the element has margin-top and removes it
$(window).scroll(function (event) {
// what the y position of the scroll is
var y = $(this).scrollTop();
// whether that's below the form
if (y >= top) {
// if so, ad the fixed class
$('#menu').addClass('fixed');
} else {
@drainpip
drainpip / animate-to-object.js
Last active December 16, 2015 10:58
Assumes jQuery. Simply use class slide for any anchor to move to an ID, eg. <a href="#home" class="slide">Back to top</a>. Adjust duration for length of time. You could also do some math on the duration to make the speed constant based on distance. Remove "return false;" if you want to hashtag to show on the URL.
$(document).ready(function() {
$(".slide").click(function() {
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top + "px"
}, {
duration: 500,
easing: "swing"
});
return false;
});
@drainpip
drainpip / wordpress-sharing-meta-tags.php
Created April 25, 2013 22:20
Credit to http://pjrvs.com/ - saving this for later.
<?php if(is_single() || is_page()) { ?>
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="TWITTER_USERNAME">
<meta name="twitter:creator" content="TWITTER_USERNAME">
<meta name="twitter:url" content="<?php the_permalink(); ?>">
<meta name="twitter:title" content="<?php the_title(); ?>">
<meta name="twitter:description" content="<?php the_excerpt_rss(); ?>">
<?php if (has_post_thumbnail()) { ?>
<meta name="twitter:image" content="<?php the_post_thumbnail(); ?>">
<?php } ?>
@drainpip
drainpip / collect-fb-graph.php
Created May 13, 2013 23:50
Class that returns array of Facebook Graph information.
<?php
class facebook_graph_json
{
public function query($page_username) {
$url = file_get_contents('http://graph.facebook.com/'.$page_username);
$json = json_decode($url);
return array(
'page_name' => $json->name,
'page_id' => $json->id,
'page_url' => $json->link,
@drainpip
drainpip / getQueryParameters.js
Created September 26, 2017 14:57
JS get query string as object
getQueryParameters : function(str) {
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
}