Skip to content

Instantly share code, notes, and snippets.

View OdatNurd's full-sized avatar

Terence Martin OdatNurd

View GitHub Profile
@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,
@OdatNurd
OdatNurd / never_not_sidebarred.py
Created October 26, 2021 18:14
Sublime Text 4 plugin that forces the SideBar to be visible when windows are opened
import sublime
import sublime_plugin
class SideBarEventListener(sublime_plugin.EventListener):
"""
Ensures that the side bar is always enabled in every window by making sure
that whenever a window is opned or a project is opened, the side bar is
turned on in that window.