Skip to content

Instantly share code, notes, and snippets.

Nathan Smith nathansmith

Block or report user

Report or block nathansmith

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
nathansmith /
Last active Jan 10, 2020
An attempt to document common WordPress comment class="…" names.

WordPress comment classes

Recently, I've endeavored to understand the comment class="…" name output from WordPress.

While it's possible to override everything at the theme level, I was curious what WP seems to want to output by default.

To that end, I have attempted to document all the commonalities I could find between the following themes.

  • Twenty Twenty
  • Twenty Nineteen
nathansmith / _has-css-animation.scss
Last active Jan 9, 2020
Prevent CSS animations before page load.
View _has-css-animation.scss
Inspired by this post…
I didn't want to have to add something to
the page initially, only to remove it later.
Instead, I'm adding a "positive" flag via JS
and am simply ignoring all animations and
nathansmith / font-override-example.scss
Last active Jan 8, 2020
Sass font override example
View font-override-example.scss
// ==================
// In variables file.
// ==================
$font-size-h1: 2.2rem !default;
$font-family-h1: inherit !default;
$font-weight-h1: inherit !default;
// =================
// In headings file.
nathansmith / storage.js
Created Dec 23, 2019
Helper for working with `window.localStorage`
View storage.js
// ================================
// Flag for `localStorage` support.
// ================================
const flag = (() => {
// Assume no support.
let bool = false;
// Used in the `try`.
const key = 'TEST_KEY';
View InputNumber.js
import React from 'react'
import PropTypes from 'prop-types'
const InputNumber = (props = {}) => {
const {
handleChange = () => {},
} = props
const onKeyDown = (e = {}) => {
nathansmith / get_method_names.ts
Created Aug 5, 2019
Get method names, from object or class instance.
View get_method_names.ts
export function getMethodNames(
apiObject: object = {}
): string[] {
// Assume class instance.
let list = Object.getOwnPropertyNames(
// Detect plain object.
if (list.includes('__proto__')) {
nathansmith / deep_freeze.ts
Created Aug 5, 2019
Recursively freeze an object.
View deep_freeze.ts
export function deepFreeze (
obj: any
): any {
const props = Object.getOwnPropertyNames(obj);
props.forEach(prop => {
const value = obj[prop];
if (
value !== null &&

React 101™

All these examples do essentially the same thing.

return (

10x Developer Code

I came across some code awhile ago that, though I can't share exactly, I wanted to document as a "foot gun."

You should never have a class that can be used both as a parent with helper methods and can be instantiated.

Even if you did, there should never be static and public methods — by the same name — that do different things.

View crunchbase_console.js
Paste this into the console on to remove the
extra overlay upsell stuff.
Example page:
You can’t perform that action at this time.