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 / 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 / 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 / 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