Skip to content

Instantly share code, notes, and snippets.

View iconifyit's full-sized avatar
🏠
Working from home

Scott Lewis iconifyit

🏠
Working from home
View GitHub Profile
@iconifyit
iconifyit / add-leading-zeroes.js
Last active March 11, 2019 03:59
Pad an integer with X number of zeroes
/**
* Add leading zeroes to an integer.
* @param {int} num The number to which to add leading zeros.
* @param {ing} zeros The length of the resulting string.
* @returns {str}
*/
function addLeadingZeros(num, width) {
return String(Math.pow(10, width) + num).slice(-width) ;
}
@iconifyit
iconifyit / restrict-wordpress-login
Created March 20, 2019 13:32
Black list and white list WordPress login
# Add the following block to your WordPress .htaccess just above the section labeled 'BEGIN WordPress'
<IfModule mod_rewrite.c>
# Restrict login to my IP
RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
# Your IP address goes below. Escape the dots with a backslash.
# Whitelist multiple IP addresses by copying and pasting the line below and
# changing the IP address to the one you want to whitelist.
@iconifyit
iconifyit / Google Sheet Colorize Row by Cell Value
Last active April 15, 2019 22:44
A custom Google Sheets conditional formatting rule to colorize an entire row based on column/cell value
# Select the rows to which you want the rule to apply
# Go to Format > Conditional Formatting
# Add a new formatting rule to the tool bar in the right-hand column
# Select 'Custom Formula' from the drop down
# Enter the formula below and modify the column name as needed
=(AND(NOT(INDIRECT("C" & ROW()) = ""), INDIRECT("C" & ROW()) = 0))
# Select the formatting styles youw ant to apply
@iconifyit
iconifyit / PathSplitter.js
Last active December 27, 2024 12:43
Split SVG path data into subpaths.
/**
* This script was taken from a discussion on Google Groups.
* I'm not taking credit for it but sharing it because it is very useful for splitting
* discontinuous absolute paths into continuous subpaths. Where this is particularly
* useful is for importing SVG files into applications like Figma, Sketch, InVision, XD, etc.
*/
/**
* Split discontinuous absolute paths into continuous sub-paths.
*
* Example:
@iconifyit
iconifyit / cep-module-example.jsx
Last active June 20, 2019 11:38
This is an example of using a module pattern and closure together to build client-side CC/CEP extension modules.
/**
* @see https://github.com/Adobe-CEP/Samples/blob/master/XmpSamplePanel/js/xmp_bridge.js
*/
/*
* ADOBE SYSTEMS INCORPORATED
* Copyright 2014 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
@iconifyit
iconifyit / site-speed-htaccess
Last active July 2, 2019 20:35
Typical Expires, Etag, and Cache-control for Google Site Speed Test best results
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
@iconifyit
iconifyit / htaccess
Last active July 19, 2019 11:33
Simple whole-site A/B test rules for htaccess
# The rules below allow you to A/B test any page on your site by splitting traffic to one of two
# sub-pages depending on the timestamp when they visit. If the millisecond is an even number,
# they are redirect to /a/ if the millisecond is odd they go to /b/. This ensures a statisticaly
# even split since the probability of the second being even or odd is about 50/50.
#
# You will need to create 3 sub-pages on your site: @, a, b so you'll end up with :
#
# https://yourdomain.com/@/any-page-name
# https://yourdomain.com/a/any-page-name
# https://yourdomain.com/b/any-page-name
#https?://(www.)?(MyDomain.com|MyInstall.wpengine.com|MyCDNcrazyness1234567890(.wpengine|-wpengine).netdna-(ssl|cdn).com)/(wp-content|wp-includes)# => https://MyCDNcrazyness1234567890-wpengine.netdna-ssl.com/$5
{
"multipass" : true,
"plugins": [
{"removeTitle": false},
{"cleanupAttrs": true},
{"inlineStyles": {"onlyMatchedOnce": false}},
{"removeDoctype": true},
{"removeXMLProcInst": true},
{"removeComments": true},
{"removeMetadata": true},
@iconifyit
iconifyit / Group-Layers-in-Adobe-Illustrator.js
Last active December 13, 2019 16:42
JSX function for Adobe Illustrator to group layers based on a matching substring in the layer names. See code comment for more details.
/**
* Group layers in Adobe Illustrator into sub-layers based on a substring
* of the layer names. For instance, given layers named with the pattern:
* 'Icon-set-01-some-keywords-here'
* Call:
* groupLayers('Icon-set-01');
*
* The result will be to create a new parent layer named 'Icon-Set-01' and
* to group any layer whose name starts with 'Icon-Set-01' under that layer.
* @param nameStem