Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Scott Lewis iconifyit

🏠
Working from home
View GitHub Profile
@iconifyit
iconifyit / two-variable-swap.js
Created Dec 5, 2022
Swap two variables set to integers without using a third variable
View two-variable-swap.js
// Swap two variables, set to integers,
// without using a third variable.
// Any language you want, but no Assembly.
// Register swaps are cheating for
// this riddle.
let x = 3
let y = 5
console.log(x, y)
@iconifyit
iconifyit / resize-artboards-dropdown.js
Created Nov 28, 2022
Example Illustrator script to create a pop-up with dropdown list to change artboards to pre-selected sizes.
View resize-artboards-dropdown.js
var docRef = app.activeDocument;
var dialog = new Window("dialog");
dialog.text = "Escolha Cilindro";
dialog.preferredSize.width = 400;
dialog.orientation = "column";
dialog.alignChildren = ["left", "top"];
dialog.spacing = 10;
dialog.margins = 16;
@iconifyit
iconifyit / fn-resize-artboards.js
Created Nov 28, 2022
Function that takes width and height as arguments and resizes all Artboards in an Illustrator document with those dimensions.
View fn-resize-artboards.js
function doResizeArtboards(width, height) {
if (app.documents.length === 0) {
alert("There are no open documents.");
return;
}
var theDoc = app.activeDocument;
try {
for (i = 0; i < theDoc.artboards.length; i++) {
/**
@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 / delete_all_imessage_conversations.applescript
Created Nov 3, 2022 — forked from lexrus/delete_all_imessage_conversations.applescript
Delete all iMessage conversations. Compatible with macOS Monterey. Please check Reduce motion before launch this apple script.
View delete_all_imessage_conversations.applescript
# System Preferences -> Accessibility -> Display -> Reduce motion
tell application "Messages" to activate
tell application "Messages"
set chatCount to (count of chats)
end tell
tell application "System Events"
tell process "Messages"
@iconifyit
iconifyit / icon-contact-sheet.js
Last active Oct 11, 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 / PathSplitter.js
Last active Oct 7, 2022
Split SVG path data into subpaths.
View PathSplitter.js
/**
* 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 / authorize-plugin.sh
Created Aug 12, 2022
Authorize un-signed Adobe Illustrator plugin
View authorize-plugin.sh
# Update the path to Illustrator to match your system.
# This command is Mac OS only.
sudo xattr -r -d com.apple.quarantine /Applications/Adobe\ Illustrator\ 2022/Plug-ins/PlacedItemInfo.aip
@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 / 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.
*/