Skip to content

Instantly share code, notes, and snippets.

View nathansh's full-sized avatar
🏠

Nathan Shubert-Harbison nathansh

🏠
View GitHub Profile
@nathansh
nathansh / useMediaQuery.js
Last active September 11, 2019 23:41
React Hook Media Query
View useMediaQuery.js
// const small = useMediaQuery('900px');
// return ( <h3>{small ? 'Small' : 'Large'}</h3> );
const useMediaQuery = (size, bound = 'max') => {
const query = `(${bound}-width: ${size})`;
const [matches, setMatches] = useState(window.matchMedia(query).matches);
useEffect(() => {
const mediaQuery = window.matchMedia(query);
@nathansh
nathansh / readme.md
Last active June 20, 2016 19:13
JavaScript module for a generic toggler
View readme.md

JavaScript module for a generic toggler. Main element is '.js-toggler, clicking child element .js-toggler__header adds and .is-open class to open the content (control this with CSS). Escape key and outside clicks close the most recently opened item.

View Package Control.sublime-settings
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"AutoWrap",
"Color Highlighter",
"EditorConfig",
View Preferences.sublime-settings
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ofv",
"*.ttf",
"*.tga",
@nathansh
nathansh / acf_api.php
Created August 2, 2015 22:44
Add ACF fields to WP JSON API V2
View acf_api.php
<?php
function d7_add_acf_to_json_api_v2($object, $field_name, $request){
if ( function_exists('get_fields') ) {
return get_fields($object['id']);
}
}
if ( is_plugin_active('rest-api/plugin.php') ) {
add_filter('rest_api_init', function(){
@nathansh
nathansh / nathansh-ascii-banner.html
Created June 21, 2015 07:34
nathansh.com ascii name banner
View nathansh-ascii-banner.html
<!--
_ _ _
| | | | | |
_ __ __ _| |_| |__ __ _ _ __ ___| |__ ___ ___ _ __ ___
| '_ \ / _` | __| '_ \ / _` | '_ \/ __| '_ \ / __/ _ \| '_ ` _ \
| | | | (_| | |_| | | | (_| | | | \__ \ | | || (_| (_) | | | | | |
|_| |_|\__,_|\__|_| |_|\__,_|_| |_|___/_| |_(_)___\___/|_| |_| |_|
@nathansh
nathansh / default.settings.php
Created June 10, 2015 20:12
Drupal 6 settings.php (sites/default/default.settings.php)
View default.settings.php
<?php
/**
* @file
* Drupal site-specific configuration file.
*
* IMPORTANT NOTE:
* This file may have been set to read-only by the Drupal installation
* program. If you make changes to this file, be sure to protect it again
* after making your modifications. Failure to remove write permissions
@nathansh
nathansh / tile.svg
Created June 9, 2015 17:42
Allow for background svg tile in IE
View tile.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nathansh
nathansh / apigen_command
Created March 31, 2015 20:42
apigen with multiple sources and options we should use
View apigen_command
apigen generate -s wp-content/themes/mount-baker-theatre/includes -s wp-content/plugins/mount-baker-theatre/includes/ -d docs --todo --deprecated --internal --template-theme=bootstrap --title='Mount Baker Theatre'
@nathansh
nathansh / docblock3.php
Created March 31, 2015 20:41
Another docblock
View docblock3.php
/**
* Generates markup for the show highlight tile, used on the homepage and
* show single pages.
*
* @uses mbt_show_single_date
* @uses mbt_get_acf_image
* @uses mbt_get_show_badges
* @uses mbt_get_show_venue_link
* @uses mbt_get_show_dates
* @uses mbt_get_show_presenter