This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
######################################### | |
# Set up the django environment | |
######################################### | |
from django.core.management import setup_environ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# saved from: http://pastie.org/private/bclbdgxzbkb1gs2jfqzehg | |
import sublime | |
import sublime_plugin | |
import subprocess | |
class RunExternalCommand(sublime_plugin.TextCommand): | |
""" | |
Runs an external command with the selected text, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
import time | |
from os import getpid | |
def worker(): | |
pid = getpid() | |
print 'START %d' % pid | |
time.sleep(3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
[ | |
// Goto Symbol | |
{ "keys": ["ctrl+alt+r"], "command": "goto_symbol_in_index"} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
// Reload currently active view key shortcut. | |
{ "keys": ["ctrl+alt+o"], "command": "reload_view"} | |
] |
OlderNewer