Skip to content

Commit

Permalink
remove unused commands
Browse files Browse the repository at this point in the history
  • Loading branch information
karsonkalt committed Jul 19, 2024
1 parent 9f4ca1f commit fe896e8
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 152 deletions.
1 change: 1 addition & 0 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ <h1 class="post-title p-name" itemprop="name headline">
<a class="u-url" href="{{ page.url | relative_url }}" hidden></a>
</article>
</main>
<script src="{{ 'assets/js/post.js' | relative_url }}" type="module"></script>
2 changes: 1 addition & 1 deletion assets/js/home.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/index.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions assets/js/post.js

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions assets/js/post.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* chroma.js - JavaScript library for color conversions
*
* Copyright (c) 2011-2019, Gregor Aisch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name Gregor Aisch may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* -------------------------------------------------------
*
* chroma.js includes colors from colorbrewer2.org, which are released under
* the following license:
*
* Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
* and The Pennsylvania State University.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* ------------------------------------------------------
*
* Named colors are taken from X11 Color Names.
* http://www.w3.org/TR/css3-color/#svg-color
*
* @preserve
*/
43 changes: 43 additions & 0 deletions assets/ts/home/addCopyButtons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export const addCopyButtons = () => {
function copyToClipboard(text: string) {
const textarea = document.createElement("textarea");
textarea.value = text;
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
}

function createCopyButton(divElement: HTMLDivElement) {
const button = document.createElement("button");
button.innerHTML = `
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" width="16" height="16" fill="currentColor">
<defs><style>.cls-637647fac3a86d32eae6f204-1{fill:none;stroke:currentColor;stroke-miterlimit:10;}</style></defs>
<polygon class="cls-637647fac3a86d32eae6f204-1" points="16.77 8.18 16.77 22.5 3.41 22.5 3.41 5.32 16.77 5.32 16.77 8.18"></polygon>
<polyline class="cls-637647fac3a86d32eae6f204-1" points="16.77 18.68 20.59 18.68 20.59 4.36 20.59 1.5 7.23 1.5 7.23 5.32"></polyline></svg>
`;
button.classList.add("copy-button");

button.addEventListener("click", () => {
const codeElement = divElement.querySelector("code");
if (codeElement) {
copyToClipboard(codeElement.innerText);
button.innerHTML = `
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" width="16" height="16" fill="currentColor">
<defs><style>.cls-6374f8d9b67f094e4896c627-1{fill:none;stroke:currentColor;stroke-miterlimit:10;}</style></defs>
<polyline class="cls-6374f8d9b67f094e4896c627-1" points="6.27 12 10.09 15.82 17.73 8.18"></polyline>
</svg>
`;
}
});

divElement.style.position = "relative";
divElement.appendChild(button);
}

document
.querySelectorAll<HTMLDivElement>("div.highlight")
.forEach((divElement) => {
createCopyButton(divElement);
});
};
4 changes: 4 additions & 0 deletions assets/ts/home/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import { addGithubStatus } from "./githubStatus";
import { addTabs } from "./tabs";
import { addTerminal } from "./terminal/index";
import { addPingButtonListener } from "./addPingButtonListener";
import { loadLocalStorage } from "./loadLocalStorage";
import { addCopyButtons } from "./addCopyButtons";

document.addEventListener("DOMContentLoaded", () => {
addTabs();
addTerminal();
addGithubStatus();
addPingButtonListener();
loadLocalStorage();
addCopyButtons();
});
6 changes: 6 additions & 0 deletions assets/ts/home/loadLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { updateAccentColor } from "./updateAccentColor";

export const loadLocalStorage = () => {
const bgColor = localStorage.getItem("ACCENT_COLOR");
if (bgColor) updateAccentColor(bgColor);
};
3 changes: 3 additions & 0 deletions assets/ts/home/sendPing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const sendPing = (message: string) => {
if (!message) {
throw new Error("Message is required");
}
fetch("https://api.pushover.net/1/messages.json", {
method: "POST",
headers: {
Expand Down
124 changes: 17 additions & 107 deletions assets/ts/home/terminal/commands.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { updateAccentColor } from "./updateAccentColor";
import { updateAccentColor } from "../updateAccentColor";
import { sendPing } from "../sendPing";

const pingCommand: CommandExecute = (args) => {
const messageCommand: CommandExecute = (args) => {
try {
sendPing(args.join(" "));
return "Message sent to my phone";
Expand All @@ -14,7 +14,7 @@ const restoreCommand: CommandExecute = (args) => {
const promptCharacter = localStorage.getItem("PS1");
if (promptCharacter) exportCommand(["PS1=" + promptCharacter]);
const bgColor = localStorage.getItem("ACCENT_COLOR");
if (bgColor) exportCommand(["ACCENT_COLOR=" + bgColor]);
if (bgColor) bgcolorCommand([bgColor]);
return "Restored terminal settings";
};

Expand All @@ -28,10 +28,6 @@ const clearCommand: CommandExecute = (args) => {
return "Console cleared";
};

const lsCommand: CommandExecute = (args) => {
return "file1.txt\nfile2.txt\nfile3.txt";
};

const helpCommand: CommandExecute = (args) => {
let helpText = "Available commands:\n";

Expand All @@ -48,14 +44,6 @@ const helpCommand: CommandExecute = (args) => {
return formattedHelpText;
};

const dateCommand: CommandExecute = (args) => {
return new Date().toString();
};

const whoamiCommand: CommandExecute = (args) => {
return "Karson, Frontend Developer";
};

const exportCommand: CommandExecute = (args) => {
const arg = args[0];

Expand All @@ -74,56 +62,18 @@ const exportCommand: CommandExecute = (args) => {
return `Prompt character changed to ${newPromptCharacter}`;
}

if (arg.startsWith("ACCENT_COLOR=")) {
const newColor = args.join(" ").slice(13).trim();

const updateSuccessful = updateAccentColor(newColor);

if (updateSuccessful) {
return `Accent changed to ${newColor}`;
}

return "Invalid color. Please provide: #000000, rgb(0, 0, 0) or any valid css color.";
}

return "Invalid export command. Usage: export PS1=$, export ACCENT_COLOR=#";
return "Invalid export command. Usage: export PS1=$";
};

const aboutCommand: CommandExecute = (args) => {
return `I’m a passionate software engineer dedicated to crafting interfaces that delight users and make a difference. Currently, I’m a Software Engineer at <a href="https://www.jupiterone.com/"target="_blank">JupiterOne</a> , where I advocate for user experience and get to build impactful features every day.`;
};
const bgcolorCommand: CommandExecute = (args) => {
const newColor = args.join(" ").trim();
const updateSuccessful = updateAccentColor(newColor);

const skillsCommand: CommandExecute = (args) => {
if (args.includes("--languages")) {
return "TypeScript, JavaScript, CSS";
} else if (args.includes("-l")) {
return "Frontend Development, React, UX Design, TypeScript, JavaScript, Node A11y, Agile, User-Centered Design";
} else {
return "Frontend Development, React, UX Design, TypeScript, JavaScript";
if (updateSuccessful) {
return `Accent changed to ${newColor}`;
}
};

const projectsCommand: CommandExecute = (args) => {
return `Projects: `;
};

const educationCommand: CommandExecute = (args) => {
return `<strong>B.S. Digital Marketing</strong>, <a href="https://www.uvu.edu/"target="_blank">Utah Valley University</a> (2010 - 2014)
<strong>Software Engineering Immersive</strong> Flatiron School (2017)
`;
};

const experienceCommand: CommandExecute = (args) => {
return `<strong>Software Engineer, Applications</strong>, <a href="https://www.jupiterone.com/"target="_blank">JupiterOne</a> (October 2021 - Present)
Natural Language Querying
− Designed and developed the integration of generative AI into our search experience, converting natural language to our query language. Resulted in one of our highest adoption rates and helped accelerate platform time-to-value.
− Implemented a vector database embedding cache, improving query response times and reducing operational costs.
− Implemented Natural Language Processing (NLP) techniques including fuzzy matching and stop word filtering to enhance search precision.
Design System Development
− Spearheaded the development of JupiterOne’s design system, including creation of a comprehensive component library, design tokens, and theming system. Helping to streamline the development process and enabling engineers to focus on core feature development.
− Crafted standardized-yet-customizable component APIs through a mix of composability, customization, and "component slots". Balanced flexibility with ease-of-use, allowing for customization without excessive rigidity. Leveraged standard naming conventions and JSDoc for streamlined development.
`;
return "Invalid color. Please provide: #000000, rgb(0, 0, 0) or any valid css color.";
};

const snarkyResponse: CommandExecute = () => {
Expand Down Expand Up @@ -201,8 +151,8 @@ export type Commands = {
};

const supportedCommands = {
ping: {
execute: pingCommand,
message: {
execute: messageCommand,
description: "Sends a message to the me",
flags: {},
},
Expand All @@ -216,52 +166,15 @@ const supportedCommands = {
description: "Prints back the input received",
flags: {},
},
ls: {
execute: lsCommand,
description: "Lists all available files",
flags: {},
},
about: {
execute: aboutCommand,
description: "Displays about information",
flags: {},
},

help: {
execute: helpCommand,
description: "Shows help information about all commands",
flags: {},
},
date: {
execute: dateCommand,
description: "Displays the current date and time",
flags: {},
},
whoami: {
execute: whoamiCommand,
description: "Displays user information",
flags: {},
},
skills: {
execute: skillsCommand,
description: "Lists all my skills",
flags: {
"--languages": "Lists programming languages I know",
"-l": "Lists all my skills",
},
},
projects: {
execute: projectsCommand,
description: "Lists all my projects",
flags: {},
},
education: {
execute: educationCommand,
description: "Displays my educational background",
flags: {},
},
experience: {
execute: experienceCommand,
description: "Displays my work experience",
bgcolor: {
execute: bgcolorCommand,
description: "Changes the background color",
flags: {},
},
export: {
Expand Down Expand Up @@ -294,6 +207,7 @@ const invalidCommands = {
man: { execute: snarkyResponse },
grep: { execute: snarkyResponse },
find: { execute: snarkyResponse },
ping: { execute: snarkyResponse },
pwd: { execute: snarkyResponse },
df: { execute: snarkyResponse },
du: { execute: snarkyResponse },
Expand All @@ -311,13 +225,9 @@ export type CommandOptions =

const snarkyResponses = [
"Nice try, but this isn't a real terminal!",
"You're not fooling anyone.",
"Did you really think that would work?",
"You must think you're pretty clever, huh?",
"You must be new here.",
"I'm sorry, Dave. I'm afraid I can't do that.",
"You must be mistaken, this isn't a real terminal.",
"That command is about as useful here as a chocolate teapot.",
];

const executeCommand = (cmd: string, args: string[]) => {
Expand Down
2 changes: 1 addition & 1 deletion assets/ts/home/themeButton.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { updateAccentColor } from "./terminal/updateAccentColor";
import { updateAccentColor } from "./updateAccentColor";

export const insertThemeButton = () => {
const themeButton = document.createElement("input");
Expand Down
File renamed without changes.
42 changes: 0 additions & 42 deletions assets/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,4 @@ If you're interested in connecting, please reach out to me via LinkedIn at:
http://linkedin.com/in/kaltkarson
`);

function copyToClipboard(text: string) {
const textarea = document.createElement("textarea");
textarea.value = text;
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
}

function createCopyButton(divElement: HTMLDivElement) {
const button = document.createElement("button");
button.innerHTML = `
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" width="16" height="16" fill="currentColor">
<defs><style>.cls-637647fac3a86d32eae6f204-1{fill:none;stroke:currentColor;stroke-miterlimit:10;}</style></defs>
<polygon class="cls-637647fac3a86d32eae6f204-1" points="16.77 8.18 16.77 22.5 3.41 22.5 3.41 5.32 16.77 5.32 16.77 8.18"></polygon>
<polyline class="cls-637647fac3a86d32eae6f204-1" points="16.77 18.68 20.59 18.68 20.59 4.36 20.59 1.5 7.23 1.5 7.23 5.32"></polyline></svg>
`;
button.classList.add("copy-button");

button.addEventListener("click", () => {
const codeElement = divElement.querySelector("code");
if (codeElement) {
copyToClipboard(codeElement.innerText);
button.innerHTML = `
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" width="16" height="16" fill="currentColor">
<defs><style>.cls-6374f8d9b67f094e4896c627-1{fill:none;stroke:currentColor;stroke-miterlimit:10;}</style></defs>
<polyline class="cls-6374f8d9b67f094e4896c627-1" points="6.27 12 10.09 15.82 17.73 8.18"></polyline>
</svg>
`;
}
});

divElement.style.position = "relative";
divElement.appendChild(button);
}

document
.querySelectorAll<HTMLDivElement>("div.highlight")
.forEach((divElement) => {
createCopyButton(divElement);
});

insertThemeButton();
Loading

0 comments on commit fe896e8

Please sign in to comment.