Skip to content

Instantly share code, notes, and snippets.

View KonnorRogers's full-sized avatar

Konnor Rogers KonnorRogers

View GitHub Profile
@KonnorRogers
KonnorRogers / autocmds.lua
Created June 9, 2024 22:03
StandardRB with lazyvim
-- ~/.config/nvim/config/autocmds.lua
-- https://github.com/standardrb/standard/wiki/IDE:-neovim
vim.api.nvim_create_autocmd("FileType", {
pattern = "ruby",
group = vim.api.nvim_create_augroup("StandardRB LSP", { clear = true }), -- also this is not /needed/ but it's good practice
callback = function()
vim.lsp.start {
name = "standard",
cmd = { "~/.asdf/shims/standardrb", "--lsp" },
@KonnorRogers
KonnorRogers / ruby_lsp.lua
Created June 9, 2024 04:18
Lazy vim disable solargraph and use ruby_lsp
return {
-- add ruby_lsp to lspconfig and disable solargraph
{
"neovim/nvim-lspconfig",
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- ruby_lsp will be automatically installed with mason and loaded with lspconfig
ruby_lsp = {},
@KonnorRogers
KonnorRogers / error_dump.txt
Created May 3, 2024 04:46
Tanstack Error Message
Uncaught Error: Minified React error #418; visit https://reactjs.org/docs/error-decoder.html?invariant=418 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
Vs https://tanstack.com/_build/assets/client-1mQvwBVG.js:38
uf https://tanstack.com/_build/assets/client-1mQvwBVG.js:40
sf https://tanstack.com/_build/assets/client-1mQvwBVG.js:40
kh https://tanstack.com/_build/assets/client-1mQvwBVG.js:40
nf https://tanstack.com/_build/assets/client-1mQvwBVG.js:40
S https://tanstack.com/_build/assets/client-1mQvwBVG.js:25
T https://tanstack.com/_build/assets/client-1mQvwBVG.js:25
2 client-1mQvwBVG.js:38:4791
Uncaught Error: Minified React error #422; visit https://reactjs.org/docs/error-decoder.html?invariant=422 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
@KonnorRogers
KonnorRogers / pseudo-morph.js
Created February 5, 2024 17:42
A pseudo-morph algorithm for custom elements
const domParser = new DOMParser()
function morphCustomElement (currentEl) {
const tagName = currentEl.tagName.toLowerCase()
const isRegistered = Boolean(window.customElements.get(tagName))
if (!isRegistered) return
// TODO: This should ideally be a contextualFragment of where the element currently lives so it can have context of
@KonnorRogers
KonnorRogers / create.rb
Created February 5, 2024 05:58
Bulk write files ruby
files = %w[
bad-input-validator.md
custom-error-validator.md
mirror-validator.md
pattern-mismatch-validator.md
range-overflow-validator.md
range-underflow-validator.md
step-mismatch-validator.md
too-long-validator.md
too-short-validator.md
@KonnorRogers
KonnorRogers / doc-generator.js
Last active October 10, 2023 05:39
Generating expanded types
// @ts-check
import ts from "typescript";
import { globSync } from "glob";
import * as fs from "fs";
import path from "path";
/**
* @typedef {Array<string | TypeArray>} TypeArray
*/
@KonnorRogers
KonnorRogers / dynamic-replace.js
Last active September 18, 2023 15:13
Adding "$" before code blocks that isn't selectable by a user
var code = document.querySelector(":is(.language-bash, .language-shell, .language-zsh, .language-sh, .language-console).highlighter-rouge pre.highlight > code")
code.innerHTML = code.innerHTML.split("\n").map((str) => {
return str.replace(/^(\w)/, "<span class='highlight-command-line-start'>$</span>$1")
}).join("\n")
@KonnorRogers
KonnorRogers / debounceable.js
Last active September 3, 2023 23:35
debouncing in a class
class Base {
constructor () {
super()
/**
* @type {null | Map<object | string | number | symbol, ReturnType<typeof setTimeout>>}
*/
this.__debounceMap__ = null
}
@KonnorRogers
KonnorRogers / base-element.js
Last active September 3, 2023 16:47
Automatically assign the proper "this" when using addEventListener
class BaseElement extends HTMLElement {
constructor () {
super()
/**
* @type {Map<(this: HTMLElement, evt: HTMLElementEventMap[keyof HTMLElementEventMap]) => any, {handleEvent: HTMLElementEventMap[keyof HTMLElementEventMap]}> | null}
*/
this.__eventMap__ = null
}
@KonnorRogers
KonnorRogers / git-private-fork.sh
Created August 24, 2023 18:22
Privately fork a repo
#!/usr/bin/env zsh
# Make sure to create a private blank repository to use as the "fork_url"
# https://gist.github.com/0xjac/85097472043b697ab57ba1b1c7530274
# @example
# git-private-fork <upstream-url> <your-fork-url> <directory-name>
# git-private-fork https://github.com/konnorrogers/repo.git https://github.com/billybob/fork.git ./my-fork
#
git-private-fork () {
base_url="$1"