Skip to content

Instantly share code, notes, and snippets.

View danklammer's full-sized avatar

Dan Klammer danklammer

View GitHub Profile
@kjbrum
kjbrum / wp-automated-cache-busting.php
Last active January 15, 2022 19:31
Automated Cache Busting. This works by adding the file's change time to the end of the URL (last argument of the call)
<?php
/* For Themes */
wp_enqueue_style('slug', get_template_directory_uri().'/css/slug.css', array(), filemtime(get_template_directory().'/css/slug.css'));
wp_enqueue_script('slug', get_template_directory_uri().'/js/slug.js', array(), filemtime(get_template_directory().'/js/slug.js'));
/* For Plugins */
wp_enqueue_style('slug', plugin_dir_url(__FILE__).'css/slug.css', array(), filemtime(plugin_dir_path(__FILE__).'css/slug.css'));
wp_enqueue_script('slug', plugin_dir_url(__FILE__).'js/slug.js', array(), filemtime(plugin_dir_path(__FILE__).'js/slug.js'));
@danawoodman
danawoodman / 0-react-hello-world.md
Last active March 9, 2024 00:32
React Hello World Examples

React "Hello World" Examples

Below are a small collection of React examples to get anyone started using React. They progress from simpler to more complex/full featured.

They will hopefully get you over the initial learning curve of the hard parts of React (JSX, props vs. state, lifecycle events, etc).

Usage

You will want to create an index.html file and copy/paste the contents of 1-base.html and then create a scripts.js file and copy/paste the contents of one of the examples into it.

@jamesmacwhite
jamesmacwhite / hiding-content-outlook-webmail.html
Last active October 12, 2023 11:05
Hiding content with mso-hide:all; to be more friendly with Outlook.com
<!--
Example 1: Using IF ELSE logic
Works with Outlook (Desktop)?: Yes
Works with Outlook.com?: No
When using IF ELSE logic, Outlook.com will remove content in both conditionals, which is problematic.
-->
<!--[if mso]>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
@tlongren
tlongren / functions.php
Last active September 24, 2018 13:48
Add Open Graph Markup to WordPress Theme
<?php
function add_opengraph_markup() {
if (is_single()) {
global $post;
if(get_the_post_thumbnail($post->ID, 'thumbnail')) {
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_object = get_post($thumbnail_id);
$image = $thumbnail_object->guid;
} else {
// set default image
@DanHerbert
DanHerbert / fix-homebrew-npm.md
Last active February 12, 2024 17:18
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

OBSOLETE

This entire guide is based on an old version of Homebrew/Node and no longer applies. It was only ever intended to fix a specific error message which has since been fixed. I've kept it here for historical purposes, but it should no longer be used. Homebrew maintainers have fixed things and the options mentioned don't exist and won't work.

I still believe it is better to manually install npm separately since having a generic package manager maintain another package manager is a bad idea, but the instructions below don't explain how to do that.

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

@pascalpoitras
pascalpoitras / config.md
Last active April 28, 2024 23:12
My WeeChat configuration

WeeChat Screenshot

Mouse


enable


@zakhardage
zakhardage / Much much simpler option selector for Shopify
Last active July 8, 2022 09:50
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
{% assign used = '' %}
<label for="select-one">{{ product.options[0] }}</label>
<select id='select-one' onchange="letsDoThis()">
{% for variant in product.variants %}
{% unless used contains variant.option1 %}
<option value="{{ variant.option1 }}">{{ variant.option1 }}</option>
{% capture used %}{{ used }} {{ variant.option1 }}{% endcapture %}
@don1138
don1138 / font-stacks.css
Last active April 25, 2024 15:41
CSS Modern Font Stacks
/* Modern Font Stacks */
/* System */
font-family: system, -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
/* System (Bootstrap 5.2.0) */
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
/* Times New Roman-based serif */
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
@windyjonas
windyjonas / wordpress-escaping.md
Last active September 21, 2020 16:10
Most of the escaping functions in WordPress, with a short explanation and example.

WordPress escaping functions

By: Jonas Nordström, @windyjonas
Date: 2013-04-16

esc_attr( $text );
Encodes the <, >, &, " and ' (less than, greater than, ampersand, double quote and single quote) characters. Will never double encode entities.
Example:

@vitalyrotari
vitalyrotari / gestures.js
Last active April 21, 2023 16:35
Vanilla JS Touch Gestures | Original Size: 6.71KB (2.08KB gzipped) | Compiled Size: 2.69KB (1.2KB gzipped)
/*
* Vanilla JS - Touch Gestures
* @version 0.1
* @inspired QuoJS - http://quojs.tapquo.com
*
* Supported Gestures: singleTap, doubleTap, hold,
* swipe, swiping, swipeLeft, swipeRight, swipeUp, swipeDown,
* rotate, rotating, rotateLeft, rotateRight, pinch, pinching,
* pinchIn, pinchOut,
* drag, dragLeft, dragRight, dragUp, dragDown