Skip to content

Instantly share code, notes, and snippets.

View acodesmith's full-sized avatar
💯

Adam Smith acodesmith

💯
View GitHub Profile
@acodesmith
acodesmith / branch-commits.bash
Created October 14, 2021 15:47
List all branch commits with somewhat pretty formatting
git log $(git branch --show-current) --not $(git for-each-ref --format='%(refname)' refs/heads/ | grep -v "refs/heads/$(git branch --show-current)") --pretty=format:"%B"
@acodesmith
acodesmith / angular-material-input-height.scss
Created October 1, 2021 12:48
Angular Material Input Set Height
.mat-form-field {
font-size: 0.74rem;
input {
font-size: 1rem;
}
label.mat-form-field-label {
font-size: 1rem;
top: 1.45em;
@acodesmith
acodesmith / useFocusTrap.tsx
Last active August 19, 2020 20:56
Focus Trap Hook - React TypeScript hook for trapping the focus.
import { useEffect, RefObject } from 'react';
declare global {
interface Window {
focusTrap: { [key: string]: FocusTrap };
}
}
interface FocusTrap {
focusable: HTMLElement[];
@acodesmith
acodesmith / SignalRMiddleWare.js
Created March 28, 2018 18:49
Redux middleware for SignalR websocket library.
import * as types from './state/types';
import { signalRAction } from './MessageHandler';
import {
signalRStart,
signalRTrackErrors,
signalRStop,
connection,
} from './Connection';
/**
@acodesmith
acodesmith / ReduxPromiseChain.js
Created March 28, 2018 18:44
Promise all response mapped to redux actions.
export class ReduxPromiseChain {
constructor({ dispatch, promises = [], dispatchMap = [], catchFunc }) {
this.dispatch = dispatch;
this.promises = promises;
this.dispatchMap = dispatchMap;
this.error = false;
this.catchFunc = catchFunc;
if (!dispatch && typeof dispatch === 'function') {
console.error('ReduxPromiseChain requires the dispatch function!');
@acodesmith
acodesmith / storefront-child-theme-function.php
Created February 19, 2018 15:06
Add version to WooCommerce Storefront Child Theme
<?php
add_action('wp_enqueue_scripts', function() {
global $wp_styles;
if( ! empty( $wp_styles->registered['storefront-child-style'] ) ) {
$wp_styles->registered['storefront-child-style']->ver = '0.0.1';
}
}, 40);
@acodesmith
acodesmith / filter_super_admins.php
Created December 18, 2017 16:34
Filter super admins from WordPress user list for multisite single site.
<?php
/**
* Remove all super admins from a non-main site user list.
**/
filter_super_admins( $args ) {
global $wpdb;
if ( ! is_main_site() ) {
$user_logins = "'" . implode( "', '", get_super_admins() ) . "'";
@acodesmith
acodesmith / web-safe-fonts.json
Created October 31, 2017 16:16
List of web safe fonts with font stack fallback options.
{
"Arial": {
"category": "sans-serif",
"stack": [
"Arial",
"Arial",
"Helvetica",
"\"Helvetica Neue\"",
"sans-serif"
]
@acodesmith
acodesmith / taxonomy_sub_menus.php
Last active March 28, 2018 18:54
Sorted taxonomy list sub menu links. Each taxonomy term generates a link in the admin menu for quick sorting based on terms.
<?php
add_action( 'admin_menu', 'add_taxonomy_sub_menus' );
function add_taxonomy_sub_menus()
{
$custom_post_type = 'shoes';
taxonomy_sub_menus( $custom_post_type );
}
@acodesmith
acodesmith / order_notes.php
Created August 25, 2017 15:48
Add Order Notes to all WooCommerce emails
<?php
function add_order_notes($order)
{
remove_filter('comments_clauses', array('WC_Comments', 'exclude_order_comments'));
$args = array(
'order' => 'DESC',
'approve' => 'approve',
'type' => 'order_note',
'post_id' => 4087