Skip to content

Instantly share code, notes, and snippets.

View mick88's full-sized avatar

Michal Dabski mick88

View GitHub Profile
@mick88
mick88 / lazy_view.py
Last active June 21, 2021 09:21
Django: Lazy view
from typing import Callable
from django.utils.module_loading import import_string
from django.views import View
class LazyView:
"""
Wrapper for view class that can be used for urls to avoid loading the view class at the import time.
The view is imported at first access and cached.
@mick88
mick88 / partial_runner.py
Last active September 20, 2020 13:15
Partial test runner
import unittest
from unittest import suite
from unittest.suite import BaseTestSuite
from django.test.runner import DiscoverRunner
from getenv import env
def test_key(suite):
if isinstance(suite, BaseTestSuite):
@mick88
mick88 / mixin.py
Last active November 6, 2016 12:15 — forked from cyberdelia/mixin.py
Django class based view mixins
# -*- coding: utf-8 -*-
import random
from django.contrib.auth.decorators import login_required
from django.utils.cache import patch_response_headers
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page, never_cache
from django.views.decorators.csrf import csrf_exempt
@mick88
mick88 / virtualenv-auto-activate.sh
Created August 31, 2016 09:31 — forked from codysoyland/virtualenv-auto-activate.sh
virtualenv-auto-activate-windows
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.
@mick88
mick88 / url.sh
Created August 15, 2016 10:11
Open url in Android throughy adb
#!/bin/bash
adb shell am start -a android.intent.action.VIEW -d https://www.google.com/
@mick88
mick88 / delete-merged.sh
Created July 26, 2016 10:47
Remove merged branches excluding master
#!/bin/bash
git branch --merged | grep -v "\*" | grep -v master | xargs -n 1 git branch -d
/**
* Radio select toggler
* enables radio buttons to be toggled when clicked
* Created by Michal on 09/05/2016.
*/
var radios = $('input[type=radio]');
/**
* Adds click listeners to all checkboxes to unselect checkbox if it was checked already
@mick88
mick88 / check_migrations.py
Last active November 23, 2015 10:20 — forked from nealtodd/gist:a8f87b0d95e73eb482c5
Django management command to detect missing migration files.
import sys
from django.apps import apps
from django.conf import settings
from django.core.management.base import BaseCommand
from django.db import connections
from django.db.migrations.autodetector import MigrationAutodetector
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.state import ProjectState
from django.db.utils import OperationalError
/**
San Andreas vehicle model definitions
Convoy Trucking
Source: http://gta.wikia.com/Vehicle_ID_List
*/
#if defined _VEHICLE_MODELS_INCLUDED
#endinput
#endif