Skip to content

Instantly share code, notes, and snippets.

Working from home

Scott Lewis iconifyit

Working from home
View GitHub Profile
iconifyit / valid-number.js
Created Jan 31, 2020
Solution to "Is it a valid number coding test". See the first comment below for test cases.
View valid-number.js
* The main function.
* @param s
* @returns {boolean}
function isNumber(s) {
s = s.trim();
var chars = new Set(s);
iconifyit / JsonToModel.js
Created Jan 25, 2020
Dynamically create a JavaScript class (POJSO) with getters and setters from a JSON object.
View JsonToModel.js
* Creates Javascript Model class with getters and setters for each property in a JSON object.
* For instance, if you call :
* var model = JsonToModel({name : 'Scott'});
* You will get back:
* function() {
* this.instance = 'Model@000-000000';
iconifyit / DragNDropFromIllustratorPanel.js
Created Jan 24, 2020
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(event)" />
iconifyit / DialogWrapper.js
Last active Jan 24, 2020
A wrapper class for dialogs created with the Script UI Dialog Builder by Joonas -
View DialogWrapper.js
* @author Scott Lewis <>
* @copyright 2020 Scott Lewis
* @version 1.0.0
* @url
* @url
* This JS class is a wrapper for dialogs created with the Script UI Dialog Builder by Joonas Pääkkö.
iconifyit / SVGExportAction.jsx
Last active Jan 20, 2020
Creates an Adobe Illustrator action to export to SVG on-the-fly.
View SVGExportAction.jsx
* This script creates an Adobe Illustrator action, on-the-fly, to export to SVG. The main thing to
* understand is that the `name` values in the action code are hexadecimal-encoded strings. The number
* that immediately preceeds the encoded name are the length of the hex string divided by 2.
* Usage:
* Change the `basePath` variable to match your file system. This can be set to any folder you like.
* Credits:
iconifyit / SVGWriterTest.jsx
Last active Apr 9, 2020
Experimental code sending JSX message to com.adobe.svgwriter (internal CEP extension). Not currently working.
View SVGWriterTest.jsx
* Adds JSON library support for engines that do not include it natively.
"object"!=typeof JSON&&(JSON={}),function(){"use strict";function f(t){return 10>t?"0"+t:t}function quote(t){
return escapable.lastIndex=0,escapable.test(t)?'"'+t.replace(escapable,function(t){var e=meta[t];
return"string"==typeof e?e:"\\u"+("0000"+t.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}
function str(t,e){var n,r,o,f,u,i=gap,p=e[t];switch(p&&"object"==typeof p&&"function"==typeof p.toJSON&&(p=p.toJSON(t)),
"function"==typeof rep&&(,t,p)),typeof p){case"string":return quote(p);case"number":return isFinite(p)?String(p):"null";
case"boolean":case"null":return String(p);case"object":if(!p)return"null";if(gap+=indent,u=[],"[object Array]"===Object.prototype.toString.apply(p)){
iconifyit / SelectionExporter.js
Created Jan 20, 2020
JavaScript Extension class for exporting a selection in Illustrator as SVG.
View SelectionExporter.js
* Usage :
* new SelectionExporter(
* app.activeDocument.selection[0],
* '/tmp/somefolder/',
* 'My File'
* );
View Enregistrer la selection en SVG.jsx
* Export selection to SVG - export_selection_as_SVG
* (Adapted from Layers to SVG 0.1 - export_selection_as_SVG.jsx, by Rhys van der Waerden)
* @author SebCorbin
// Variables
var ignoreHidden = true,
svgExportOptions = (function () {
iconifyit / react-error-boundary.js
Created Jan 17, 2020
Example of React ErrorBoundary (by Dan Abramov)
View react-error-boundary.js
class ErrorBoundary extends React.Component {
constructor(props) {
this.state = { error: null, errorInfo: null };
componentDidCatch(error, errorInfo) {
// Catch errors in any components below and re-render with error message
error: error,
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.
You can’t perform that action at this time.