Skip to content

Instantly share code, notes, and snippets.

View OdatNurd's full-sized avatar

Terence Martin OdatNurd

View GitHub Profile
[
// NOTE: The filename in the example is "Default.sublime-keymap, but you
// should put this in your own user and platform specific key bindings,
// such as "Default (Linux).sublime-keymap" or such.
//
// That would be the file that opens when you use the
// "Preferences > Key Bindings" menu item.
// For more details on how this binding works, see: https://youtu.be/1CkAkpNs28M
// Here the binding is using the standard build key; this is different on MacOS,
@OdatNurd
OdatNurd / markdown_password_copy.py
Created August 26, 2023 06:54
Simple plugin that lets you easily copy temporary passwords out of markdown files
import sublime
import sublime_plugin
from urllib.parse import quote, unquote
class SetUpButtonsCommand(sublime_plugin.TextCommand):
"""
When executed, this command checks the current file for all items that
match the regular expression and adds a phantom that alows for copying
@OdatNurd
OdatNurd / log_file_tail.py
Created August 22, 2023 04:54
Sublime Text 4 plugin that will cause reloaded log files to jump to the bottom of the file on new content
import sublime
import sublime_plugin
from fnmatch import fnmatch
# Related Reading:
# https://forum.sublimetext.com/t/auto-scroll-to-bottom-tail-log-files/69156
#
# For any opened file that matches one of the globs set out below, this will
# cause the view of the file to jump to the bottom whenever the file reloads
@OdatNurd
OdatNurd / project_specific_files.py
Last active January 2, 2024 07:19
Sublime Text plugin for making opened files open in the window for the project
import sublime
import sublime_plugin
from os.path import isabs, isfile, normpath, realpath, dirname, join
# Related reading:
# https://forum.sublimetext.com/t/forbid-st-from-opening-non-project-files-in-the-projects-window/68989
# The name of the window specific setting that determines if the functionality
# of this plugin is enabled or not, and an indication of whether the plugin
@OdatNurd
OdatNurd / text_highlight.py
Last active January 17, 2023 19:13
Simple Text Highlight Plugin
import sublime
import sublime_plugin
import functools
import re
# The key the key that we use to add regions for the word currently under the
# cursor (when that is turned on), the style of the regions added, and the
# scope that represents the color to use when words are highlighted.
CURRENT_WORD_KEY='_sel_word'
@OdatNurd
OdatNurd / Default (Linux).sublime-keymap
Created September 19, 2022 03:39
Switch to the next or previous file group in Sublime Text
[
// Add to your own custom key bindings file using 'Preferences > Key Bindings'; set the keys as
// desired for your own use.
{ "keys": ["super+t"],
"command": "switch_group",
"args": {"forward": true }
},
{ "keys": ["super+ctrl+t"],
"command": "switch_group",
@OdatNurd
OdatNurd / Context.sublime-menu
Last active May 14, 2022 00:03
Simple Fold Plugin
[
// You can also include a "caption" key to set what the menu
// text displays.
{ "command": "mark_fold_region" }
]
@OdatNurd
OdatNurd / simple_token_scanner.py
Created March 29, 2022 05:10
Simple example of extracting tokens from a file in Sublime
import sublime
import sublime_plugin
class VariableHoverEventListener(sublime_plugin.EventListener):
def get_hover_token(self, tokens, point):
"""
Given a list of tokens, find the one that's at the point given.
"""
for index, item in enumerate(tokens):
@OdatNurd
OdatNurd / CompletionsPlugin.py
Created February 8, 2022 05:52
Small tweak to Stata Editor plugins to remove words from the buffer from the completion list
import sublime, sublime_plugin
import Pywin32.setup
import win32com.client
import win32api
import os
settings_file = "StataEditor.sublime-settings"
def plugin_loaded():
global settings
@OdatNurd
OdatNurd / eventsub_sample.js
Created January 4, 2022 05:39
Quick example of using Twurple EventSub
const { ClientCredentialsAuthProvider } = require('@twurple/auth');
const { ApiClient } = require('@twurple/api');
const { NgrokAdapter } = require('@twurple/eventsub-ngrok');
const { EventSubListener } = require('@twurple/eventsub');
async function testEventSub() {
// Create an auth provider tied to our application's client ID and secret.
const authProvider = new ClientCredentialsAuthProvider(
process.env.TWITCHBOT_CLIENT_ID,