Trevor Atlas

Trevor Atlas

// Name: tiktok-images
// Description: Resize images to fit TikTok's 9:16 aspect ratio and avoid being covered by the UI
// Author: Trevor Atlas
// Twitter: @trevoratlas
// Threads: trevor.atlas
import "@johnlindquist/kit"
const sharp = await npm('sharp');
const { getAverageColor } = await npm('fast-average-color-node');
const width = 1440;
const height = 2400;
const density = 72;
const scale = .8;
const validTypes = new Set(['image/png', 'image/jpeg', 'image/jpg']);
const outputPath = path.join(home(), 'Desktop', 'resized-images');
async function processImage(imageFilepath: string) {
try {
const averageColor = await getAverageColor(imageFilepath);
const image = await sharp(imageFilepath)
.withMetadata({ density })
.resize({ fit: 'inside', width: Math.floor(width * scale), height: Math.floor(height * scale) })
.png({ quality: 100 })
const color = averageColor.hex || 'black';
// Add a matching background
const background = await sharp({
create: {
channels: 4,
background: color,
.withMetadata({ density })
.png({ quality: 100})
const res = await sharp(background)
.composite([{ input: image, gravity: 'centre' }])
.png({ quality: 100 })
return res;
} catch (error) {
throw error;
interface FileInfo {
lastModified: number;
lastModifiedDate: string;//"2023-07-12T17:35:13.573Z"
name: string;
path: string;//"/Users/uname/Desktop/screenshots/Screenshot 2022-01-12 at 1.35.08 PM.png"
size: number;
type: string;//"image/png"
webkitRelativePath: string;
try {
const fileInfos: FileInfo[] = await drop('Drop images to resize');
const imagePaths = fileInfos
.filter(({type}) => validTypes.has(type))
.map(fileInfo => fileInfo.path);
if (!imagePaths.length) {
await notify('No valid images found. Supports .png, .jpg, and .jpeg');
await ensureDir(outputPath);
for (const imagePath of imagePaths) {
const image = await processImage(imagePath);
const [filename] = path.basename(imagePath).split('.');
const finalPath = path.join(outputPath, `${filename}-processed.png`);
await writeFile(finalPath, image);
console.log(`Resized ${finalPath}`);
await notify('Image(s) resized');
} catch (error) {
await notify('Error resizing images. Check the log for details.');
await open(outputPath);

// Menu: De-Acronym-ify
// Description: Replace acronyms with their full names
// Author: Trevor Atlas
// Twitter: @trevoratlas
// Shortcut: cmd ctrl opt shift a
// Group: work
import '@johnlindquist/kit';
let text = '';
const clipboardValue = await paste();
const selection = await getSelectedText();
if (selection) {
text = selection;
console.log('use selection', selection);
if (clipboardValue && !selection) {
text = clipboardValue;
console.log('use clipboard', text);
if (!text) {
text = await arg('Enter text to de-acronym-ify');
console.log('use prompt', text);
const acronyms: Array<[string | RegExp, string]> = [
['PD', 'Product Design'],
['PM', 'Product Management'],
['JS', 'JavaScript'],
['TS', 'TypeScript'],
const result = acronyms.reduce(
(acc, [acronym, expansion]) => acc.replace(acronym, expansion),
if (!selection) {
} else {
await setSelectedText(result);

// Name: humanlike typing
// Description: Type the contents of your clipboard as if you were a human
// Author: Trevor Atlas
// Twitter: @trevoratlas
import "@johnlindquist/kit"
await hide();
await applescript(String.raw`
set texttowrite to the clipboard as text
tell application "System Events"
repeat with i from 1 to count characters of texttowrite
if (character i of texttowrite) is equal to linefeed or (character i of texttowrite) is equal to return & linefeed or (character i of texttowrite) is equal to return then
keystroke return
keystroke (character i of texttowrite)
if (character i of texttowrite) is equal to " " then
delay (random number from 0.01 to 0.1)
else if (character i of texttowrite) is equal to "\n" then
delay (random number from 0.1 to 0.3)
delay (random number from 0.01 to 0.05)
end repeat
end tell

// Name: vpn
// Author: Trevor Atlas
// Twitter: @trevoratlas
// Schedule: */15 * * * *
import "@johnlindquist/kit"
tell application "System Events" to tell process "GlobalProtect"
set connectionStatus to get help of every menu bar item of menu bar 2
if item 1 of connectionStatus = "Not Connected" then
click menu bar item 1 of menu bar 2 -- Activates the GlobalProtect "window" in the menubar
click button "Connect" of window 1
end try
click menu bar item 1 of menu bar 2 -- This will close the GlobalProtect "window" after clicking Connect/Disconnect. This is optional.
end if
end tell

// Menu: Icebreaker
// Description: Get a random icebreaker question
// Author: Trevor Atlas
// Twitter: @trevoratlas
import '@johnlindquist/kit';
const dbvalues = await db('icebreakers');
const icebreakers: string[] =;
const getRandomElement = <T>(arr: T[]) => {
const index = Math.floor(Math.random() * arr.length);
return arr[index];
const item = getRandomElement(icebreakers);
await div(
<div class="w-full h-full text-center flex items-center justify-center">
<h1 :class="responseClass">${item}</h1>
"Show us the weirdest thing you have in the room with you right now.",
"There is a free, round-trip shuttle to Mars. The catch: it will take one year of your life to go, visit, and come back. Are you in?",
"What is your least favorite thing about technology?",
"What superpower would you most want?",
"What food is best with cheese?",
"Would you go in the mother-ship with aliens if they landed on Earth tomorrow?",
"Would you join a community in space if it was permanent?",
"Would you rather live 100 years in the past or 100 years in the future?",
"You are the best criminal mastermind in the world. What crime would you commit if you knew you would get away with it?",
"You can only eat one food again for the rest of your life. What is it?",
"You can visit any fictional time or place. Which would you pick?",
"In your time as a student in K-12, what made an impact on you. Not who, but what? What do you remember that influenced you today?",
"How would you hide a giraffe from the government?",
"If you were an inanimate object, what would you be and why?",
"What is the most trivial thing about which you have a strong opinion?",
"What is the smallest thing for which you are grateful?",
"If you could change one thing about yourself physically, what would you change?",
"What single event or decision do you think most affected the rest of your life?",
"What do you fear, despite having no real reason to do so? Basically, what is an irrational fear you have?",
"Do you have any conspiracy theories? If so, what are they?",
"What scientific or technological advance blows your mind? Is there any technology that seems so futuristic and advanced you're surprised it actually exists?",
"What is something you don't realise is weird until you really think about it?",
"You can transport one furious elephant into any point in history, where would you put it?",
"If you could make one thing that is now legal, illegal, and one thing that is illegal, legal, what laws would change?",
"Would you agree to go without showering, brushing your teeth, and using deodorant for six months to win $500,000? You are not allowed to talk about the deal with anyone until the six months end, or the offer is gone.",
"What's the best trip (traveling wise) you ever had?",
"Does pineapple go on pizza?",
"If you could live anywhere in the world for a year, where would it be?",
"What's your favorite seat on an airplane?",
"What is your spirit animal? (The animal who is most similar to your personality.)",
"What is your favorite thing to do by yourself?",
"Have you ever experienced a natural disaster like a hurricane or tornado?",
"If you had to delete all but 3 apps from your smartphone, which ones would you keep? (Three apps that have changed your life.)",
"If you had to choose between only having a cell phone or a car for the rest of your life, which would you choose?",
"What is your favorite tv series?",
"What is your favorite book?",
"How would you change your life today if the average life expectancy was 400 years?",
"A genie grants you three wishes but none of them can directly benefit you. What would those wishes be?",
"What is your favorite smell and why?",
"According to you, what is the most mind-numbingly dull movie ever made?",
"If given the choice of having a talk show host narrate your life, who would you choose?",
"Which reality TV show is your guilty pleasure?",
"All in all, the movie that had the most significant impact on your life and why?",
"If you could switch your life with any fictional character, who would it be?",
"Decidedly, you must choose a fictional world that'll become the new reality. Which one would you pick?",
"According to you, what is the most monotonous sport to watch?",
"Who would be the first celebrity guest in your very own talk show?",
"Without a doubt, who is the greatest actor that has ever graced the world?",
"If you had the chance to be in the Olympics, which sport would you compete in?",
"Generally, which real life person are you most inspired by?",
"What's the most underrated actor that you know of?",
"What is your 'I wish I had started doing this earlier in my life'?",
"What is the coolest website you've ever visited?",
"What is your favorite polite insult?"