Skip to content

Instantly share code, notes, and snippets.

View DV8FromTheWorld's full-sized avatar
💭
Through code, all things are possible.

Austin Keener DV8FromTheWorld

💭
Through code, all things are possible.
View GitHub Profile
// Background:
// Word boundaries are 0 width assertions that are between \w (word characters)
// and \W (non-word characters) or start/end of the string.
// So, in a scenario like "-abc" there are 2 word boundaries:
// 1. between the '-' and the 'a'
// 2. between the 'c' and the end of the string
//
// Regex explanation:
// ^\\b_ -> Start matching by ensuring that we are at the beginning of the match, and that the
// underscore we are using as the sentinel to start the italics boundary is proceeded
copy(temp1.error.data.requestBody.transactions[0].operations
.filter(operation => operation.command === 'set' && Array.isArray(operation.args) && operation.args.length !== 0)
.map(operation => operation.args.flatMap(arg => Array.isArray(arg) ? arg[0] : arg).join(''))
.join('\n'))
;(async () => {
const taskPanelInput = document.querySelector('[aria-label="Task Name"]');
if (!taskPanelInput) {
alert("Could not find task name. Is the sidepanel open?");
return
}
const taskName = taskPanelInput.value;
let url = location.href;
if (!url.endsWith('/f')) {
/* Ensure the url goes to the full-screened task */
@DV8FromTheWorld
DV8FromTheWorld / Github PR image markdown unwrapping.js
Last active October 2, 2023 21:37
The follow script is intended as a browser bookmark and will replace all ![image](...) markdown in a github PR with the HTML <img src=...> versions instead. This is helpful when setting up big tables of images
;(() => {
const el = document.querySelector('[name="pull_request[body]"]');
const markdownImageRegex = /!\[.*?\]\((.*?)\)/gm;
window.__PREVIOUS_PR_CONTENT = el.value;
const newVal = el.value.replaceAll(markdownImageRegex, (match, url) => `<img width="450" src="${url}">`);
el.value = newVal;
alert("Replacements complete. Preview content available in window.__PREVIOUS_PR_CONTENT");
@DV8FromTheWorld
DV8FromTheWorld / extract-unicode-confusables.js
Created June 28, 2023 19:05
Small helper browser console function for pulling info out of the Unicode Confusables site
function getConfusableCharacters() {
const confusableCharactersTable = document.querySelector('table:has(h3)')
const tableRows = confusableCharactersTable.querySelectorAll('tr')
const unicodeRow = Array.from(tableRows[1].children)
const nameRow = Array.from(tableRows[2].children)
let values = ''
for (let i = 0; i < unicodeRow.length; i++) {
const unicode = unicodeRow[i].innerText
@DV8FromTheWorld
DV8FromTheWorld / vs-code-tweaks.md
Last active December 8, 2022 17:36
VS Code tweaks

Settings

Just straight to Complete Settings Files if you just wanna completely copy my setup

Key Bindings

Please note, these are my custom assigned keybindings. The keybinds below are not the default keybinds for these controls.

Name Keybind Description
Go Back Cmd+Opt+LeftArrow Navigates to your previous cursor position. Will also navigate between editor panes. Extremely useful for keeping context while exploring code. 1000% recommend
Go Forward Cmd+Opt+RightArrow Navigates to your next cursor position (after you use GoBack). Will also navigate between editor panes. Extremely useful for keeping context while exploring code.
Reveal Active File in Explorer View Cmd+F1 Scrolls the explorer view to the current editor file for easy context discovery
(() => {
/* Finds the "Viewed" button for each file, selecting only ones marked as already viewed */
const allViewedFiles = Array.from(document.querySelectorAll('[data-ga-click="File viewed, click, value:true"]'));
/* Iterates through the viewed files and closes any that are still open. */
const allOpenViewedFiles = allViewedFiles.forEach(viewedButton => {
const fileContainer = viewedButton.closest('.js-details-container');
if (fileContainer.classList.contains('open')) {
const collapseButton = fileContainer.querySelector('.js-details-target');
collapseButton.click();
@DV8FromTheWorld
DV8FromTheWorld / vue-memoizer.js
Created November 16, 2021 20:56
Possible Vue Compostion Memoizer
/**
* Vue Composition HigherOrderFunction (HOF) that will take a Vue Composition function and return a
* memoized version of that function.
*
* A Memoized function in a function that, when given the same inputs, will skip any calculations done by the function
* and instead return a cached result that matches the inputs. This allows us to skip any duplicate computation
* or other calculations that would occur by calling the function from multiple places but with the same inputs.
*
* It is expected that the resolver function will take the provided inputs and convert them to a keyable value
* that can be used in the internal cache.
@DV8FromTheWorld
DV8FromTheWorld / JDAEntityMixins.md
Last active November 14, 2021 00:43
JDAEntityMixins.md

Entity Mixins

Entity Mixins are a system in JDA that provide the following core functionalities:

  • Code reuse through composition instead of purely through inheritence
  • A way to expose internal state setters and getters without exposing them to the library user

Example Mixin with Usage

//Publicly exposed entity api interface
public interface SomeEntity {
    String getName();
@DV8FromTheWorld
DV8FromTheWorld / SlashCommandConverter.java
Last active January 25, 2022 19:08
JDA SlashCommandConverter
/*
* Copyright 2021 Austin Keener
*
* 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