Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Hazledine tomhazledine

View GitHub Profile
@tomhazledine
tomhazledine / birthday.js
Created August 30, 2017 16:19
Instructions for proper conduct at the party
View birthday.js
let now = Date.now() / 1000;
if ( now > 1504051200 && now < 1504137599) {
steve.work = false;
steve.beers++;
}
@tomhazledine
tomhazledine / calculate_reading_time.php
Created November 16, 2016 08:30
Calculate Reading Time (for WordPress content)
View calculate_reading_time.php
<?php
/**
* READING TIME
*
* Calculate an approximate reading-time for a post.
*
* @param string $content The content to be measured.
* @return integer Reading-time in seconds.
*/
function reading_time( $content ) {
@tomhazledine
tomhazledine / convert_number_to_words.php
Last active July 6, 2019 00:34
Convert Numbers Into Words
View convert_number_to_words.php
<?php
/**
* DISPLAY NUMBERS
*
* Convert raw numbers into human-readable words.
*
* Borrowed (and very much simplified) from:
* http://www.karlrixon.co.uk/writing/convert-numbers-to-words-with-php/
* @param integer $number Raw number.
* @return string Number as a word.
@tomhazledine
tomhazledine / SCSS_linter.yml
Created June 19, 2015 09:34
Gulp SCSS Linter
View SCSS_linter.yml
# Default application configuration that all configurations inherit from.
linters:
BorderZero:
enabled: true
CapitalizationInSelector:
enabled: true
ColorKeyword:
enabled: true
View SFAP install.html
<script src="/path/to/styleFreeAudio.min.js"></script>
<script src="/path/to/yourCustom.js"></script>
@tomhazledine
tomhazledine / folderStructure.txt
Last active August 29, 2015 14:22
Basic Gulp setup
View folderStructure.txt
_uncompressed/
icons/ ~ SVG icons go here
scss/
images/
js/
custom/ ~ JS partials live here
static/ ~ "static" files are *not* concatenated into app.min.js
jquery/
vendor/ ~ plugins etc. These are concatenated into app.min.js
@tomhazledine
tomhazledine / gist:2755c26dc685be756a3a
Created May 16, 2014 12:39
Fallback function for Advanced Custom Fields plugin for Wordpress
View gist:2755c26dc685be756a3a
// Fallback if ACF plugin doesn't exist
/**
* Return a custom field stored by the Advanced Custom Fields plugin
*
* @global $post
* @param str $key The key to look for
* @param mixed $id The post ID (int|str, defaults to $post->ID)
* @param mixed $default Value to return if get_field() returns nothing
* @return mixed
* @uses get_field()