This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Vanilla Javascript DropDown Menu Example</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
</head> | |
<body> | |
<div id="menu-dropdown">Menu ▼</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.management import call_command | |
from django.core.management.base import BaseCommand | |
from django.db import connection | |
class Command(BaseCommand): | |
help = 'Delete all tables and run all migrations' | |
def add_arguments(self, parser): | |
parser.add_argument('--seed', nargs='*', help='Run the DB seeders.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def override_method(cls, after=True): | |
def decorator(func): | |
new_parent_method_name = '_' + func.__name__ + '_parent' | |
setattr(cls, new_parent_method_name, getattr(cls, func.__name__)) | |
@wraps(func) | |
def wrapper(self, *args, **kwargs): | |
if after: | |
parent_result = getattr(self, new_parent_method_name)(*args, **kwargs) | |
return func(self, parent_result, *args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.cache import cache | |
from selenium import webdriver | |
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities | |
browser_url = cache.get('user_%d.browser_url' % user_id) | |
is_browser_queued = cache.get('user_%d.browser_queued' % user_id) | |
if browser_url: | |
capabilities = DesiredCapabilities.CHROME.copy() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models import fields | |
__all__ = [ | |
'PositiveBigAutoField', 'PositiveBigIntegerField', | |
] | |
class PositiveBigAutoField(fields.AutoField): | |
def db_type(self, connection): | |
if 'mysql' in connection.__class__.__module__: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.apps import apps | |
from django.apps.config import AppConfig | |
from django.conf import settings | |
from django.core.management import call_command | |
from django.core.management.base import BaseCommand, CommandError | |
class Command(BaseCommand): | |
help = 'Reset and re-run all migrations' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import factory | |
from django.contrib.auth import get_user_model | |
from django.contrib.auth.hashers import make_password | |
User = get_user_model() | |
class UserFactory(factory.django.DjangoModelFactory): | |
class Meta: | |
model = User |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.pyc | |
bin/ | |
include/ | |
lib/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class GatewayGuard implements Guard | |
{ | |
/** | |
* Retrieve the access token if exists. | |
* | |
* @return string|null | |
*/ | |
protected function retrieveAccessToken() |