Skip to content

Instantly share code, notes, and snippets.

View chrisgrieser's full-sized avatar

Chris Grieser chrisgrieser

View GitHub Profile
@chrisgrieser
chrisgrieser / mastodon_redirect-to-home-instance.js
Last active November 23, 2024 19:13
Userscript for [Violent|Tamper|Grease]monkey.
// ==UserScript==
// @name Redirect to Mastodon home instance
// @namespace Violentmonkey Scripts
// @match https://*/@*/*
// @version 1.0
// @author pseudometa
// @description 2024-11-22
// @icon https://mastodon.social/packs/media/icons/favicon-48x48-c1197e9664ee6476d2715a1c4293bf61.png
// ==/UserScript==
@JoosepAlviste
JoosepAlviste / typescript.lua
Last active December 19, 2024 08:06
Automatically add async to function declaration when typing "await"
---@param types string[] Will return the first node that matches one of these types
---@param node TSNode|nil
---@return TSNode|nil
local function find_node_ancestor(types, node)
if not node then
return nil
end
if vim.tbl_contains(types, node:type()) then
return node
@vogler
vogler / clean-url-readme-tab.github.com.tamper.js
Last active February 11, 2025 01:40
GitHub: remove `?tab=readme-ov-file` from URL
// ==UserScript==
// @name GitHub: remove `?tab=readme-ov-file` from URL
// @description GitHub: remove `?tab=readme-ov-file` from URL
// @namespace https://gist.github.com/vogler
// @downloadURL https://gist.github.com/vogler/74edff6de37c3a13eeff8c99c6bed910/raw/clean-url-readme-tab.github.com.tamper.js
// @version 0.1
// @author Ralf Vogler
// @match https://github.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
// @grant none
const execSync = require('child_process').execSync;
const spawnSync = require('child_process').spawnSync;
async function compile(input, context) {
// This is undocumented and could break.
let basePath = context.app.vault.adapter.basePath;
if (!basePath.endsWith("/")) {
basePath = basePath + "/";
}
@chrisgrieser
chrisgrieser / metadata-refactor.sh
Last active May 11, 2024 05:54
Change Wikilinks in YAML Frontmatter from the Breadcrumbs style to the new Obsidian Metadata Style
# macOS
cd "path/to/your/vault"
awk 'FNR <= 1 && /^---$/{print FILENAME}' **/*.md |
xargs -I {} sed -i '' -E '1,/^---$/ s/(\[\[.*]])/"\1"/g' "{}"
# Linux (or macOS users with GNU sed)
cd "path/to/your/vault"
awk 'FNR <= 1 && /^---$/{print FILENAME}' **/*.md |
xargs -I {} sed -i -E '1,/^---$/ s/(\[\[.*]])/"\1"/g' "{}"
body {
/* [...] redacted customizations [...] */
--file-margins: var(--size-4-5);
}
.cm-vimCursorLayer {
animation: none !important;
}
@kylechui
kylechui / dot-repeating.md
Last active March 5, 2025 02:38
A basic overview of how to manage dot-repeating in your Neovim plugin, as well as manipulate it to "force" what action is repeated.

Adding dot-repeat to your Neovim plugin

In Neovim, the . character repeats "the most recent action"; however, this is not always respected by plugin actions. Here we will explore how to build dot-repeat support directly into your plugin, bypassing the requirement of dependencies like repeat.vim.

The Basics

When some buffer-modifying action is performed, Neovim implicitly remembers the operator (e.g. d), motion (e.g. iw), and some other miscellaneous information. When the dot-repeat command is called, Neovim repeats that operator-motion combination. For example, if we type ci"text<Esc>, then we replace the inner contents of some double quotes with text, i.e. "hello world""text". Dot-repeating from here will do the same, i.e. "more samples""text".

Using operatorfunc

@GitMurf
GitMurf / obsidian.templater.pane.send-to-next.js
Created January 8, 2022 04:07
Send the current active line of text or if text is selected, send the selection... to the pane next to the active one
<%*
//OPTIONS: TOP / BOTTOM
const whereToWrite = "TOP";
//OPTIONS: COPY / MOVE
const copyOrMove = "COPY";
//Find leaf next door
const thisLeaf = app.workspace.activeLeaf;
const thisFile = thisLeaf.view.file;
let leafToUse = app.workspace.getAdjacentLeafInDirection(thisLeaf, "right");
if(!leafToUse){leafToUse = app.workspace.getAdjacentLeafInDirection(thisLeaf, "left");}
/* RAINBOW INDENT COLORS */
:root {
/* default */
--font-use-default: var(--default-font);
--font-size-use-default: var(--editor-font-size);
--indent-use-default: 1.8ch;
/* ------- */
/* theme */
--font-use-theme: inherit;