Skip to content

Instantly share code, notes, and snippets.

# NOTE: This code was extracted from a larger class and has not been
# tested in this form. Caveat emptor.
import django.conf
import django.contrib.auth
import django.core.handlers.wsgi
import django.db
import django.utils.importlib
import httplib
import json
import logging
@metalman
metalman / app.py
Created May 7, 2014 09:31
PyQt4 QTimer and Python GC
from PyQt4 import QtCore, QtGui
def output():
print('timer timeout...')
class Window(QtGui.QDialog):
def __init__(self, parent=None):
mount -o remount,size=1536M tmpfs /tmp/
@metalman
metalman / qapplication_about_to_quit_signal.py
Created April 15, 2014 10:43
QThread graceful exit before QApplication quit.
'''
see: http://pyqt.sourceforge.net/Docs/PyQt4/qcoreapplication.html#aboutToQuit
'''
import threading
from PyQt4 import QtCore, QtGui
class Thread(QtCore.QThread):
@metalman
metalman / rst2pdf_chinese.json
Created April 11, 2014 09:24
Chinese style with WenQuanYi Micro Hei font for rst2pdf.
{
"styles": {
"base": {
"wordWrap": "CJK"
}
},
"embeddedFonts": [
[
"wqy-microhei.ttc",
"wqy-microhei.ttc",
@metalman
metalman / run.py
Created August 28, 2012 09:04
Test altering table in sqlite3.
import sqlite3
'''
TABLE_NAME = 'pets'
OLD_COLUMNS = ('name', 'color')
NEW_COLUMS = ('name', 'kind', 'color')
'''
def get_kind(name):