Skip to content

Instantly share code, notes, and snippets.

View sligodave's full-sized avatar

David Higgins sligodave

View GitHub Profile
import sublime
import sublime_plugin
import re
import json
from xml.dom.minidom import *
from os.path import basename
from copy import copy
from xml.sax.saxutils import escape, unescape
var d = document.createElement('div');
d.innerHTML = '\
<style>\
*:not(.icon):not(i), *:not(.icon):not(i):after, *:not(.icon):not(i):before {\
box-shadow: none !important;\
text-shadow: none !important;\
background-image: none !important;\
border-radius: 0 !important;\
}\
*:not(.icon):not(i) {\
@sligodave
sligodave / Default (Linux).sublime-keymap
Last active December 23, 2015 00:28
A simple sublime text plugin to change the syntax of every opened or new file to YAML. Drop the file "SyntaxToYAML.py" into your Sublime Text "Packages/User/" directory. Add the keymaps to the files with the same name in your "Packages/User/" directory too. DON'T overwrite the "Default (XXX).sublime-keymap" files that are already there. Add to t…
[
// Change the syntax of the current file to YAML
{ "keys": ["ctrl+alt+y"], "command": "change_syntax", "args": {"syntax": "Packages/YAML/YAML.tmLanguage"}}
]
@sligodave
sligodave / Default (Linux).sublime-keymap
Last active December 22, 2015 22:39
A sublime text command to reload the current file and bring cursor back to current position.
[
// Reload currently active view key shortcut.
{ "keys": ["ctrl+alt+o"], "command": "reload_view"}
]
@sligodave
sligodave / gist:6539531
Last active November 23, 2023 07:29
Quick example of creating, using and deleting a temp file in python
import os
import tempfile
file_descriptor, file_path = tempfile.mkstemp(suffix='.tmp')
# You can convert the low level file_descriptor to a normal open file using fdopen
with os.fdopen(file_descriptor, 'w') as open_file:
open_file.write('hello')
@sligodave
sligodave / Default (Linux).sublime-keymap
Last active November 20, 2023 17:29
Sublime Text 3, Goto Symbol In Index Command. This brings you to the definition of the symbol currently highlighted or under the cursor in Sublime Text 3. It there are more than one options you will be presented with them to choose from. Just as with the "Goto Symbol" and "Goto Symbol in Project" commands. You must have a project defined and ope…
[
// Goto Symbol
{ "keys": ["ctrl+alt+r"], "command": "goto_symbol_in_index"}
]
import firebirdsql
conn = firebirdsql.connect(
dsn='localhost/3050:PATH_TO_DB.fdb',
user='sysdba',
password='masterkey'
)
cur = conn.cursor()
# Get all rows from a table
@sligodave
sligodave / gist:3801283
Created September 28, 2012 17:59
Register all models that extend a certain base abstract model.
from django.contrib import admin
from django.db.models import get_models, get_app
from models import BaseModel
app = get_app('app_name')
for model in get_models(app):
if issubclass(model, BaseModel):
try:
@sligodave
sligodave / gist:3800648
Created September 28, 2012 15:54
Get all logins since 2pm pacific time based on internal saved time of central.
import datetime
# Time is Central!
d = datetime.datetime(2012, 9, 26, 14, 00)
# So we can convert our times to Pacific time
dt = datetime.timedelta(hours=2)
@sligodave
sligodave / broken_south_migration_bypass_steps.txt
Created September 6, 2012 20:06
Steps to follow when I've broken "south" migrations.
1. Delete DB
2. Create DB
3. Remove south from INSTALLED_APPS
4. syncdb
5. Insert south into INSTALLED_APPS
6. sycndb
7. migrate --fake
8. YAY!