Skip to content

Instantly share code, notes, and snippets.

View gnowland's full-sized avatar
💭
Let's design a world that's thoughtful, considered, and aesthetically pleasing.

Gifford Nowland gnowland

💭
Let's design a world that's thoughtful, considered, and aesthetically pleasing.
View GitHub Profile
@gnowland
gnowland / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/**
* Helvetica Neue Normal
*/
/* Helvetica Neue Black Font Stack */
.{font-family: "HelveticaNeueBlack", "HelveticaNeue-Black", "Helvetica Neue Black", "HelveticaNeue", "Helvetica Neue", 'TeXGyreHerosBold', "Arial Black", sans-serif; font-weight:800; font-stretch:normal;}
/* Helvetica Neue Heavy Font Stack */
.{font-family: "HelveticaNeueHeavy", "HelveticaNeue-Heavy", "Helvetica Neue Heavy", "HelveticaNeue", "Helvetica Neue", 'TeXGyreHerosBold', "Arial Black", sans-serif; font-weight:700; font-stretch:normal;}

Overview

Recently had a client that wanted to customize the layout for a category landing page so that the category's title and description would be displayed above the layered navigation and product grid — essentially creating a full-width section above the left sidebar and main content areas.

NOTE: For reference, this is based off the blog post from Collaboration133.com's Magento - Add Custom Structural Block Reference.

Custom Module (My_LayoutMods)

I created a custom module to help organize and identify that there are some custom modifications to layout templates. Not saying you have to, but it may be easier for other's (or your future self) to recognize and find what customizations were done (and hopefully why).

@gnowland
gnowland / bg-img-cover.php
Last active February 8, 2017 04:28
Function (+ accompanying css) for creating "cover"-like background images with "responsive" srcset via wp_get_attachment_image
<?php
function bg_img_cover($id, $size, $focus = null, $classes = null, $atts = []) {
if ( !empty($focus) ) {
$atts['style'] = "top: {$focus}; -webkit-transform: translate( -50%, -{$focus}); transform: translate( -50%, -{$focus});";
}
$img_src = wp_get_attachment_image($id, $size, false, $atts);
if( !empty($classes) ) {
$img_src = str_replace( 'class="', "class=\"{$classes} ", $img_src );
}
return $img_src;
@gnowland
gnowland / pre-commit_vault
Created August 10, 2017 01:25
Pre-commit to check if there are unencrypted Ansible Vault files in the working directory
#!/bin/sh
#
# Pre-commit hook that verifies if all files containing 'vault' in the name
# are encrypted.
# If not, commit will fail with an error message
#
# File should be .git/hooks/pre-commit and executable
FILES_PATTERN='.*vault.*\.yml$'
REQUIRED='ANSIBLE_VAULT'
@gnowland
gnowland / 01-directory-structure.md
Created October 2, 2018 03:16 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@gnowland
gnowland / favorite-wp-plugins.md
Last active October 23, 2018 18:08
My Favorite WordPress Plugins

Favorite WordPress Plugins

This is a list of my favorite (read: necessary) WordPress plugins. I am generally plugin-averse, but certain situations arise where you just can't do without, or to do so would mean reinventing the wheel. For those cases, these plugins I've personally vetted to ensure that their code is performant and robust.

Images

  • Imsanity - Resizes images on upload to a more reasonable size.
  • EWWW - Image compression/optimization
@gnowland
gnowland / gist:45c3e1c136ee14659059e4fc9fd816d7
Created February 18, 2019 21:04
Blockstack Verification
Verifying my Blockstack ID is secured with the address 1Biwu72jJTKhuaraFbBR9P39ZuWAEq8zR1 https://explorer.blockstack.org/address/1Biwu72jJTKhuaraFbBR9P39ZuWAEq8zR1
@gnowland
gnowland / gist:29d362921e455c8f87b54d7652a2eedf
Created September 12, 2019 22:50
When node is giving you macos firewall trouble
# https://github.com/tj/n/issues/394#issuecomment-359570847
# remove current entry in firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --remove /usr/local/bin/node && \
# copy current node from n
cp -pf /usr/local/n/versions/node/$(node -v | cut -d 'v' -f 2)/bin/node /usr/local/bin && \
# add to firewall
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /usr/local/bin/node
n=0; for f in *.pngx; do echo mv "$f" "${f/_*./_$(($n*7 + 660305562)).}"; ((n++)); done