Skip to content

Instantly share code, notes, and snippets.

View joshbduncan's full-sized avatar

Josh Duncan joshbduncan

View GitHub Profile
@joshbduncan
joshbduncan / spinner_object.py
Last active April 1, 2022 15:37
Progress Spinner Using Objects and Generators
import sys
import time
spinners = {
"angles": ["◢", "◣", "◤", "◥"],
"circle": ["◜", "◠", "◝", "◞", "◡", "◟"],
"dots": ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
"ticks": ["-", "\\", "|", "/"],
}
@joshbduncan
joshbduncan / AiCommandPalette-NO-MENU
Created August 8, 2022 14:37
Ai Command Palette Error Test - Excluded Menu Options
/*
Ai Command Palette
Copyright 2022 Josh Duncan
https://joshbduncan.com
This script is distributed under the MIT License.
See the LICENSE file for details.
*/
// TODO: add the ability to edit custom commands
@joshbduncan
joshbduncan / AiCommandPalette-NO-ACTIONS.jsx
Created August 8, 2022 14:38
Ai Command Palette Error Test - Excluded Actions Options
/*
Ai Command Palette
Copyright 2022 Josh Duncan
https://joshbduncan.com
This script is distributed under the MIT License.
See the LICENSE file for details.
*/
// TODO: add the ability to edit custom commands
@joshbduncan
joshbduncan / day25.py
Created January 13, 2022 16:20
Advent of Code 2021 - Day 25
from collections import defaultdict
data = open("day25.in").read().strip().split("\n")
tracker = defaultdict(str)
rows = len(data)
cols = len(data[0])
for r, line in enumerate(data):
for c, d in enumerate(line):
if d != ".":
@joshbduncan
joshbduncan / day2.py
Created December 2, 2022 15:54
Advent of Code 2022 - Day 2
def score_round(elf_idx, me_idx):
if elf_idx == me_idx: # draw
return me_idx + 1 + 3
elif me_idx % 3 != (elf_idx + 2) % 3: # win
return me_idx + 1 + 6
else:
return me_idx + 1 # lose
data = open("day2.in").read()
@joshbduncan
joshbduncan / InsetShapesCompoundPath.jsx
Created January 19, 2023 21:31
Ai Create Inset Rectangles and Ellipses
// Create inset rectangles and ellipses and place into compound path
var doc = app.activeDocument;
var al = doc.activeLayer;
// type of path
// var type = "rectangle"
var pathType = "ellipse";
// amount of inset paths (max: 4)
@joshbduncan
joshbduncan / GoToArtboardExample.jsx
Created January 20, 2023 21:43
Go To Artboard (hacky example)
// Please note this is a hacky example in response to a question
// on the Adobe forums at the link below.
// https://community.adobe.com/t5/illustrator-discussions/using-artboards-as-an-archive-that-is-searchable/td-p/13504883
var aiVersion = parseFloat(app.version);
var locale = $.locale;
var os = $.os;
var sysOS = /mac/i.test(os) ? "mac" : "win";
var windowsFlickerFix = sysOS === "win" && aiVersion < 26.4 ? true : false;
@joshbduncan
joshbduncan / javascript-table-search-filter.js
Last active February 28, 2023 16:51
Javascript Table Search Filter
//////////////////////////////////////
// Advanced Table Search Filtererrr //
//////////////////////////////////////
// Setup:
// 1. Page **must** include table with the id "search-table" (only one)
// 2. Page **must** include text input with id "search-input" (only one)
// 3. Table **may** include data-attribute "data-search-ignore-cols"
// that will ignore any columns listed in the data attribute.
// Columns to be ignored must be listed by index number (0-based)
@joshbduncan
joshbduncan / UngroupUnclipUncompound.jsx
Last active March 1, 2023 17:42
Clean-up junky Ai files by reducing any selected group, compound path, and clipping mask contents to just paths.
/**
* Clean-up junky files by reducing any group, compound path, and clipping mask contents to just paths.
*
* This works no matter how nested the container object are and works for better for weird
* edge cases than trying to remove each element from each container via the API.
*/
var doc = app.activeDocument; // Get active document
var sel = doc.selection; // Get selected items
@joshbduncan
joshbduncan / textual_data_table_custom_sort.py
Created August 9, 2023 21:10
Custom Sorter for MM-DD-YY Column Type in a Textual DataTable
from operator import itemgetter
from typing import Any, Self
from textual._two_way_dict import TwoWayDict
from textual.app import App, ComposeResult
from textual.events import Click
from textual.widgets import DataTable
from textual.widgets.data_table import CellType, ColumnKey, RowKey
ROWS = [