Skip to content

Instantly share code, notes, and snippets.

View taylorbryant's full-sized avatar
🤖

Taylor Bryant taylorbryant

🤖
View GitHub Profile
@taylorbryant
taylorbryant / purgecss-tailwind-gulp-example.js
Last active February 24, 2023 10:30
Use PurgeCSS with Tailwind & Gulp (Inspired by @andrewdelprete)
const atimport = require("postcss-import");
const { dest, src, task } = require("gulp");
const postcss = require("gulp-postcss");
const purgecss = require("@fullhuman/postcss-purgecss");
const tailwindcss = require("tailwindcss");
const TAILWIND_CONFIG = "./tailwind.config.js";
const SOURCE_STYLESHEET = "./src/style.css";
const DESTINATION_STYLESHEET = "./build/style.css";
@taylorbryant
taylorbryant / default.csscomb.json
Created January 10, 2018 02:40
My personal CSScomb config
{
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "lower",
"block-indent": " ",
"color-shorthand": true,
"element-case": "lower",
"eof-newline": true,
"leading-zero": false,
"quotes": "single",
@taylorbryant
taylorbryant / deep-scan.js
Last active September 25, 2020 21:14
Get all items from a DynamoDB table using the scan operation
function deepScan(scanOperationParams, dynamodbClient) {
return dynamodbClient
.scan({
ConsistentRead: true,
...scanOperationParams,
})
.promise()
.then(async ({ Items, LastEvaluatedKey }) => {
if (!LastEvaluatedKey) {
return Items;
@taylorbryant
taylorbryant / master-details.js
Last active May 20, 2020 03:38
Master details
const PRODUCTS = [
{ id: 1, name: "Potato chips", description: "Deliciousness" },
{ id: 2, name: "Glue", description: "Do not smell" }
]
function Master(props) {
return PRODUCTS.map(product => (
<button onClick={() => props.onClickProduct(product)} key={product.id}>
{product.name}
</button>
@taylorbryant
taylorbryant / purge-from-tailwind.js
Created January 25, 2020 18:30
PurgeCSS V2 Tailwind Extractor
const purgeFromTailwind = content => content.match(/[\w-/:]+(?<!:)/g) || [];
@taylorbryant
taylorbryant / graceful.css
Created March 30, 2018 13:37
Make Slick.js sliders load gracefully
/*
* Make Slick.js sliders load gracefully
*/
.graceful {
visibility: hidden;
-webkit-transition: opacity 1s;
transition: opacity 1s;
opacity: 0;
}
@taylorbryant
taylorbryant / clear-cache.php
Created January 19, 2018 14:06
Clear Autoptimize & W3 Total Cache when 64 MB limit is hit
// Clear Cache (64 MB Limit)
if ( class_exists('autoptimizeCache') ) {
$myMaxSize = 48000;
$statArr = autoptimizeCache::stats();
$cacheSize = round( $statArr[1] / 1024 );
if ($cacheSize > $myMaxSize ) {
autoptimizeCache::clearall();
if ( class_exists('W3_Plugin_TotalCacheAdmin') )
{
@taylorbryant
taylorbryant / reverse-relationship-query.php
Last active March 30, 2018 13:40
Reverse relationship field query for ACF as a function 🔥
function getParents($childPostId, $parentPostType, $acfKey) {
return get_posts(array(
'post_type' => $parentPostType,
'meta_query' => array(
array(
'key' => $acfKey,
'value' => '"' . $childPostId . '"',
'compare' => 'LIKE'
)
)
@taylorbryant
taylorbryant / css-stats-bookmarklet
Last active September 22, 2017 02:15
CSS Stats Bookmarklet - Runs the current page through cssstats.com (uses default user agent)
javascript:location.href='http://cssstats.com/stats?url='+window.location.href+'&ua=Browser Default'