Skip to content

Instantly share code, notes, and snippets.

View ajpalkovic's full-sized avatar

AJ Palkovic ajpalkovic

View GitHub Profile
@ajpalkovic
ajpalkovic / saveUntitledFile.py
Created June 16, 2011 01:52
Sublime Plugin to Save Auto Save Untitled Tabs
import sublime, sublime_plugin
import time, os
# This class executes a callback function once self.delay seconds have elapsed since the last call to timer.notify()
# This allows a method like on_modified to repeatedly call notify without triggering the event multiple times per second.
class DelayedTimer:
def __init__(self, delay, callback):
self.delay = delay
self.callback = callback
self.lastRequest = 0
@ajpalkovic
ajpalkovic / clipboardHistory.py
Created June 15, 2011 05:19
Sublime Clipboard History Plugin
import sublime, sublime_plugin
import math, time
# two globals store the complete clipboard history and position so that it is shared between all the various actions
_clipboardHistory = ['']
_clipboardIndex = 0
class ClipboardHistoryBase(sublime_plugin.ApplicationCommand):
# gets/sets the sublime clipboard
def clipboard(self, content=None):
@ajpalkovic
ajpalkovic / currentWord.py
Created June 14, 2011 05:12
Sublime Plugin to Highlight the Current Word
import sublime, sublime_plugin
import time
key = "HighlightCurrentWord"
# The search is performed half a second after the most recent event in order to prevent the search hapenning on every keypress.
# Each of the event handlers simply marks the time of the most recent event and a timer periodically executes doSearch
class HighlightCurrentWord(sublime_plugin.EventListener):
def __init__(self):
self.previousRegion = sublime.Region(0, 0)
syntax :html do
# apply this syntax to .html and .htm files
extension "html", "htm"
# color an entire tag green
green :begin => "<", :end => ">" do
#apply the following rules only to the stuff between the <>
# color the tag content yellow (so the <> are green)
yellow /.*/
@ajpalkovic
ajpalkovic / gist:963423
Created May 9, 2011 21:10
Ruco/History
module Ruco
class History
attr_accessor :timeout
def initialize(options)
@options = options
@stack = [@options.delete(:state)]
@timeout = options.delete(:timeout) || 0
clear_timeout
@position = 0