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
@DV8FromTheWorld
DV8FromTheWorld / test.md
Created October 16, 2024 15:26
storage

asd

@DV8FromTheWorld
DV8FromTheWorld / blob-to-main-branch.js
Last active July 29, 2024 14:26
JS Bookmark to move from a blob branch to the main trunk of git repo on github.
;(() => {
const url = location.href;
if (!url.includes('github.com/discord/discord')) {
alert("Not on github.com/discord/discord. Not prepared to move to main branch");
return;
}
if (!url.includes("blob/")) {
alert("Not on a git blob/ path.");
return;
// 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'))
@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.