Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
On the way

soroush safari coci

:octocat:
On the way
View GitHub Profile
@coci
coci / BaseThreading
Created Mar 18, 2020 — forked from amirasaran/BaseThreading
Python threading with callback function (callback function run after thread is finished)
View BaseThreading
import time
import threading
class BaseThread(threading.Thread):
def __init__(self, callback=None, callback_args=None, *args, **kwargs):
target = kwargs.pop('target')
super(BaseThread, self).__init__(target=self.target_with_callback, *args, **kwargs)
self.callback = callback
self.method = target
@coci
coci / models.py
Created May 22, 2019 — forked from mrob11/models.py
Simple follower/following relationship in Django
View models.py
$ ./manage.py shell
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from followers.models import *
>>> john = User.objects.create_user('john', 'lennon@thebeatles.com', 'password')
>>> paul = User.objects.create_user('paul', 'mccartney@thebeatles.com', 'password')
>>> george = User.objects.create_user('george', 'harrison@thebeatles.com', 'password')
>>> ringo = User.objects.create_user('ringo', 'starr@thebeatles.com', 'password')