Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Scott Lewis iconifyit

🏠
Working from home
View GitHub Profile
@iconifyit
iconifyit / htaccess-ab-test
Last active Jun 21, 2022
A/B Testing with htaccess
View htaccess-ab-test
# ############################### #
# A/B TESTING (START) #
# ############################### #
# (1) Check if our cookie is already set.
# If so, redirect to the previously-viewed page.
RewriteCond %{HTTP_COOKIE} ab_test_vers=([^;]+)
RewriteRule ^THE-PAGE-BEING-TESTED$ HTTP://YOUR-DOMAIN.COM/tracking/%1 [cookie=ab_test_vers_match:true:YOUR-DOMAIN.COM,L]
@iconifyit
iconifyit / icon-contact-sheet.js
Last active May 23, 2022
Adobe Illustrator JSX plugin to create a contact sheet from a folder or vector icons.
View icon-contact-sheet.js
/**
* Name that script.
*/
#script "Contact Sheet";
#target Illustrator
var originalInteractionLevel = userInteractionLevel;
userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
@iconifyit
iconifyit / ExportOptionsSVG.js
Created Dec 20, 2019
Adobe Ilustrator JSX export as SVG with all ExportOptionsSVG object properties
View ExportOptionsSVG.js
function getExportOptionsSVG() {
var exportOptions = new ExportOptionsSVG();
/**
* A range of artboards to save, if saveMultipleArtboards is true. A comma-delimited list of artboard names., or the empty string to save all artboards. Default: empty String.
* {string}
*
* NOTE: Set to an empty string to export all. Be sure `saveMultipleArtboards` is set to true to use this.
*/
@iconifyit
iconifyit / download-from-s3.sh
Created Jan 18, 2022
Script to download files from AWS S3 to a specified location.
View download-from-s3.sh
#!/usr/bin/env bash
# Replace the text PATH_TO_YOUR_DROPBOX_FOLDER with the path to your Dropbox folder (e.g. /home/user/Dropbox)
DROPBOX_FOLDER="PATH_TO_YOUR_DROPBOX_FOLDER"
# DO NOT CHANGE ANYTHING BELOW THIS LINE
# ======================================
PDF_MERGE_WORK_FOLDER="$HOME/pdfmerge"
@iconifyit
iconifyit / AdobeIllustratorMenuCommands.js
Created Sep 6, 2021
Simple function to execute menu commands in an Adobe Illustrator JSX script.
View AdobeIllustratorMenuCommands.js
/**
* MenuCommand object for executing Adobe Illustrator menu commands.
* @param {String} kCommandStr
* @param {Boolean} runImmediately
* @constructor
*/
function doMenuCommand(kCommandStr) {
/**
* The Command string
@iconifyit
iconifyit / rgb-to-hex.js
Created Aug 29, 2021
RGB-to-Hexadecimal and Hexadecimal-RGB conversion
View rgb-to-hex.js
const hexToRgb = (hex) => {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
module.exports.hexToRgb = hexToRgb;
@iconifyit
iconifyit / javascript-singleton.js
Last active Aug 25, 2021
Example of how to implement a Singleton pattern in JavaScript.
View javascript-singleton.js
/*
* The instance symbol should be defined in the scope
* in which you want the singleton to exist. This does
* not necessarily mean globally. Just within your
* execution context.
*/
let instance
const Singleton = (() => {
const createInstance = () => {
@iconifyit
iconifyit / wordpress-bootstrap.sh
Created Aug 19, 2021
Bootstrap script for basic Wordpress install
View wordpress-bootstrap.sh
#!/bin/bash
yum update -y
yum install httpd php php-mysql -y
cd /var/www/html
echo "healthy" > healthy.html
wget https://wordpress.org/wordpress-latest.tar.gz
tar -xzf wordpress-latest.tar.gz
cp -r wordpress/* /var/www/html/
rm -rf wordpress
rm -rf wordpress-*.tar.gz
@iconifyit
iconifyit / DragNDropFromIllustratorPanel.js
Last active Jul 13, 2021
Two simple methods for enabling Drag-n-Drop of SVG images from a CEP Panel to the Illustrator canvas.
View DragNDropFromIllustratorPanel.js
/**
* What is going on here?
* The Event.dataTransfer object can be set with JavaScript. When the start of a drag event is
* detected, we capture the SVG code as a string and set it to the EventTarget.dataTransfer object
* as a string. Illustrator handles the rest.
*/
/**
* Add drag start callback. Add this method to the <img/> element like so:
*
* <img src="path/to/image.svg" onDragStart="onDragStart" />
View serverless-example.yaml
app: aws-pdf-merge
org: iconify
service: pdf-workflow
custom: ${file(./yml/custom.yml)}
# ================================================================================================
# PROVIDER
# ================================================================================================
provider: