Skip to content

Instantly share code, notes, and snippets.

View MahirMahbub's full-sized avatar
:shipit:

Mahir Mahbub MahirMahbub

:shipit:
  • Bangabandhu Sheikh Mujibur Rahman Digital University, Bangladesh
  • Dhaka,Bangladesh
  • LinkedIn in/mahirmahbub
View GitHub Profile
@tschellenbach
tschellenbach / Django Mock Request Object.py
Created April 18, 2011 12:54
Fake django requests for testing purposes
from django.core.handlers.base import BaseHandler
from django.test.client import RequestFactory
class RequestMock(RequestFactory):
def request(self, **request):
"Construct a generic request object."
request = RequestFactory.request(self, **request)
handler = BaseHandler()
handler.load_middleware()
for middleware_method in handler._request_middleware:
@vinyll
vinyll / models.py
Last active June 3, 2023 17:00
Advanced user inheritance with Django
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import (AbstractBaseUser,
BaseUserManager as DjBaseUserManager)
from model_utils.managers import InheritanceManager
class BaseUserManager(DjBaseUserManager, InheritanceManager):
"""
@ri-sh
ri-sh / ManualHough.py
Last active November 29, 2022 10:40
Hough Lines from scratch using opencv and numpy
# imports
import numpy as np
import cv2
import matplotlib.pyplot as plt
# The Hough Transform is a popular algorithm for detecting any shape that can
# be represented in a parametric mathmatical form in binary images. This
# usually means that images need to be thresholded or filtered prior to running
@vparitskiy
vparitskiy / request.py
Created November 14, 2017 01:04
get Django request everywhere using threading.local
# -*- coding: utf-8 -*-
import logging
from threading import local
from django.contrib.auth.models import AnonymousUser
_thread_locals = local()
logger = logging.getLogger(__name__)