Skip to content

Instantly share code, notes, and snippets.

View jhned's full-sized avatar

Josh Nederveld jhned

View GitHub Profile
@jhned
jhned / sticky-test.html
Created July 20, 2017 01:39
Sticky Test
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Sticky Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
@jhned
jhned / createGeoJSONCircle.js
Created June 12, 2017 14:31
Add a circle overlay polygon in Mapbox
var createGeoJSONCircle = function(center, radiusInKm, points) {
if(!points) points = 64;
var coords = {
latitude: center[1],
longitude: center[0]
};
var km = radiusInKm;
@jhned
jhned / gist:fcba58b1434d647663dc168ac33488bc
Created September 21, 2016 14:44
check options AND defaults!
$fpt_options = array();
if ( array_key_exists( $pt_key, $options )
&& is_array( $options[ $pt_key ] )
&& array_key_exists( $post_type, $defaults[ $pt_key ] )
&& is_array( $options[ $pt_key ][ $post_type ] )
) {
$fpt_options = $options[ $pt_key ][ $post_type ];
}
@jhned
jhned / is_news_or_post.php
Last active March 5, 2017 21:31
Cross post-type check
<?php
/**
* is_news_or_post
*
* A custom boolean check for Hexadite so that we can test if we're on a news or post layout without repeating every single check every time we need to.
*
* @return bool
*/
function is_news_or_post() {
@jhned
jhned / interior-clean.php
Last active March 5, 2017 21:00
How to do layout files
<?php
namespace CLIENT;
class Interior {
public static function init() {
add_action( 'wp', function () {
if ( ! is_front_page() ) {
self::hook_wordpress();
@jhned
jhned / layouts-interior.php
Last active June 15, 2016 13:26
Header-int call
<?php
add_action( 'after_header', 'namespace_get_header_int', 20 );
function namespace_get_header_int() {
if ( !is_front_page() ) {
get_header('int');
}
}
@jhned
jhned / messy-code.php
Last active June 14, 2016 17:47
Many conditionals make a muckle
<?php
if (is_archive() || is_search()) :
$url = get_permalink();
if (has_post_thumbnail()) :
print '<a href="'.$url.'">';
the_post_thumbnail('thumbnail');
print '</a>';
endif;
if ( $post->post_type == 'post' ) print '<div itemprop="blogPost">';
@jhned
jhned / flexible-font-sizes-mixin.scss
Created April 19, 2016 21:19
Flexible font sizes
@function strip-unit($value) {
@return $value / ($value * 0 + 1);
}
@mixin flexible_font_sizes( $min-font-size, $max-font-size, $min-width, $max-width ) {
$font-size-difference: strip-unit($max-font-size - $min-font-size);
$viewport-difference: strip-unit($max-width - $min-width);
@media screen and #{breakpoint($min-width)} and #{breakpoint($max-width down)} {
add_filter('intermediate_image_sizes_advanced', function($sizes) {
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
return $sizes;
});
div.module {
.image {
margin: .5em;
}
img {
border: none;
}
.text {
padding: .25em;