Skip to content

Instantly share code, notes, and snippets.

View CurtisL's full-sized avatar

Curtis Lawrence CurtisL

  • Sole Graphics
  • Bellingham Wa
View GitHub Profile
@CurtisL
CurtisL / README.md
Last active February 4, 2020 21:27
CSS Selectors Sets

SELECTOR LIBRARY

This is a collection of css selectors organized by various terms. This can be used for reference or to build long selectors as needed

Content Categories

Each HTML element must abide by rules defining what kind of content it can have. These rules are grouped into content models common to several elements. Each HTML element belongs to zero, one, or multiple content models, each setting rules that the element's content must follow in an HTML-conformant document.

@CurtisL
CurtisL / README.md
Last active January 27, 2020 19:34
Observing scoped variables via custom console.observe and chrome live expressions.

console.observe

Sometimes when debugging or testing, you use console.log() in a loop, or in a callback that is fired rapidly. Usefull, but when you only want to see the live value, your console can be flooded with entries. And even though there is the Live Expression option in chrome, your variable is sometimes not accessable in the window scope. This is where console.observe steps in.

console.observe(var, key);

This will create a window object variable window.consoleObserve that will contain updated value of the key you provide. This way you can selectivly create a live expression for your defined key.

<?php
namespace App\Http;
use Illuminate\Http\Request;
class BulkAction
{
public $model;
@CurtisL
CurtisL / README.md
Created July 15, 2019 17:24
Statamic Conditional Grid Fields: A Hack

Statamic Conditional Grid Fields: A Hack

This snippet provides the ability to not only add custom conditions to which grid field columns are visible, but change their order on the fly.

According to the statamic documentation

Important: Conditionals work on top-level fields only, not meta fields (fields that include other fields) like Replicator, Bard, and Grid.

They make it sound like it's just not possible with these field types. Which is mostly true... But with a bit of work you can write your own custom ones by extending Statamic.conditions in your site/helpers/cp/scripts.js

@CurtisL
CurtisL / README.md
Created March 12, 2019 20:40
Dynamic ACF Gutenberg Blocks for v5.8

Dynamic ACF Gutenberg Blocks

When ACF v5.8 drops we'll have the ability to create gutenberg blocks from ACF Field Groups. This set of functions will add additional field group options to dynamcily register blocks with various block customization settings.

All you have to do is create your field groups and template.

Usage

@CurtisL
CurtisL / .htaccess
Last active June 12, 2024 09:21
Better Maintenance Mode .htaccess rules
# BEGIN MAINTENANCE MODE
# ADD your IP address to gain access. Local IPS for local testing
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^192\.168\.0\.0
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [R=503,L]
@CurtisL
CurtisL / out-of-bounds.js
Created March 25, 2016 20:58
Script that logs and highlights elements that are out of bounds and may be causing unexpected horizontal scroll. Requires jQuery and is in no way optimized.
/**
* Sometimes you get horizontal scroll on a page,
* but can't find the element causing it.
*
* This scrapes the DOM and checks to see if any
* right edge of an element is beyond the width
* of a defined container.
*/
(function($){
// change container to the selector to look within
@CurtisL
CurtisL / IndefiniteArticle.md
Last active December 5, 2015 00:47
Indefinite Article Grammar Helper Challenge

Challenge

Write a script that will help determine the indefinite article of a word ('a' or 'an'). The test strings below demonstrate some of the complexities of this grammar rule to be aware of. But test it aginst as many strings as you can think of.

Exceptions:

Some conditions do not need to be considered for this challenge.

  • Don't worry about "Uncountable" words such as "air" or "salt" they don't count (Ha! Pun!).
  • Consider all words to be an "American" accent. "an herb" (American silent H) vs "a herb" (European hard H) when testing. Bonus points (not that there are points or anything) if you have the ability to match based of accent.
@CurtisL
CurtisL / placehold-404.php
Last active December 14, 2015 22:46
Wordpress filter to replace 404'd images with a placeholder, Good for when you're working locally but don't want to copy down the whole uploads directory.
<?php
/**
* Dev Helper for 404'd Images
*/
function placehold_404( $image ) {
if ( file_exists( ABSPATH . str_replace(get_home_url().'/', '', $image[0]) ) ) {
return $image;
}
// Replace the image source with a placeholder at the proper dimensions.
$image[0] = "http://placehold.it/{$image[1]}x{$image[2]}/FF6600/FFFFFF";
@CurtisL
CurtisL / redux-framework-cleaner.php
Last active July 10, 2018 17:19
When including Redux in a theme for a client, this removes the nags and notices.
<?php
/**
* Disable News Blast
*/
$GLOBALS['redux_notice_check'] = false;
/**
* Disable Update Notice
*/
$GLOBALS['redux_update_check'] = false;