Skip to content

Instantly share code, notes, and snippets.

View smallevilbeast's full-sized avatar
😂

evilbeast smallevilbeast

😂
View GitHub Profile
package main
import (
"os"
"fmt"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
from PyQt5 import QtCore
def with_metaclass(meta, base=QtCore.QObject):
"""Create a base class with a metaclass."""
return meta("NewBase", (base,), {})
class PropertyMeta(QtCore.pyqtWrapperType):
def __new__(cls, cls_name, cls_bases, cls_dict):
super_new = super(PropertyMeta, cls).__new__
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from PyQt5 import QtCore
class BaseModel(QtCore.QAbstractListModel):
def __init__(self, parent=None):
super(BaseModel, self).__init__(parent)
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2011 ~ 2012 Deepin, Inc.
# 2011 ~ 2012 Hou Shaohui
#
# Author: Hou Shaohui <houshao55@gmail.com>
# Maintainer: Hou Shaohui <houshao55@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
import datetime
import peewee as pw
from playhouse.signals import Model
from dtalk.utils.contextdecorator import contextmanager
from dtalk.utils.xmpp import split_jid, get_email
db = pw.SqliteDatabase('test.db', check_same_thread=False, threadlocals=True)
DEFAULT_GROUP = "我的好友"
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import gtk
class NoteBook(gtk.Window):
def __init__(self):
super(NoteBook, self).__init__()
import urllib2
import threading
from Queue import Queue
import sys, os, re
class ThreadedDownload(object):
REGEX = {
'hostname_strip':re.compile('.*\..*?/', re.I)
}
@smallevilbeast
smallevilbeast / gist:7801180
Last active December 30, 2015 08:09
post gui for PyQt
class postGui(QtCore.QObject):
throughThread = QtCore.pyqtSignal(object, object)
def __init__(self, func):
super(postGui, self).__init__()
self.throughThread.connect(self.onSignalReceived)
self._func = func
self._obj = None
from pyxmpp2.etree import ElementTree
from pyxmpp2.interfaces import StanzaPayload, payload_element_name
'''
def get_vcard(self, jid, callback=None):
if not callback:
callback = self.vcard_callback
q = Iq(
@smallevilbeast
smallevilbeast / gist:8018653
Created December 18, 2013 07:37
pyqt test
import os
import sys
from PyQt4.QtCore import *
def quit():
print "Memory: ", int(os.popen('ps -p %d -o rss | tail -1' % os.getpid()).read())
sys.exit()
class Test(QObject):
@pyqtSlot()