This file contains 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
# :coding: utf-8 | |
"""Replace tokens in strings.""" | |
import re | |
DOUBLE_CURLY_BRACED_TOKEN = r"{{\s*(\w+)\s*}}" # E.g.: '{{ token }}' | |
This file contains 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
# !/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
Generate Django boilerplate code to expose models via a REST API. | |
Will generate code for the view, serialization and url routing. Results | |
are written to stdout; redirect them to a file and integrate them into | |
your project (views.py, serializers.py, urls.py) to get started quickly. |
This file contains 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
// Now officially integrated into Vuetify: | |
// | |
// https://github.com/vuetifyjs/vuetify/blob/master/src/components/VApp/mixins/app-breakpoint.js | |
// https://github.com/vuetifyjs/vuetify/blob/master/src/components/VApp/mixins/app-breakpoint.spec.js | |
/** | |
* A Vue mixin to get the current width/height and the associated breakpoint. | |
* | |
* Useful to e.g. adapt the user interface from inside a Vue component | |
* as opposed to using CSS classes. The breakpoint pixel values and |
This file contains 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 datetime import timedelta | |
from django.conf import settings | |
from django.utils import timezone | |
from rest_framework.authentication import TokenAuthentication | |
from rest_framework.authtoken.models import Token | |
from rest_framework.exceptions import AuthenticationFailed | |
def is_token_expired(token): |
This file contains 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
# -*- coding: utf-8 -*- | |
""" | |
A simple script to batch-create Toggl time entries for a vacation. | |
Note: Time zones and offsets are not handled here. | |
# Prerequisites |
This file contains 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
# Prerequisites: | |
# | |
# $ pip install colorama colorlog | |
LOGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'formatters' : { | |
'colored': { | |
'()': 'colorlog.ColoredFormatter', |
This file contains 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
_________________________________________________ | |
___ __ _ _ ________ | |
/ _ \___ _/ /_____(_)___(_)__ ____ / _/ _/ | |
/ ___/ _ `/ __/ __/ / __/ / _ `/ _ \ _/ /_/ / | |
/_/ \_,_/\__/_/ /_/\__/_/\_,_/_//_/ /___/___/ | |
_________________________________________________ | |
You should buy in this town: | |
beer for max. 52 |
This file contains 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 pytest_addoption(parser): | |
parser.addoption( | |
"--only-fixtures", | |
action="store", | |
help=( | |
"Execute the given fixture(s) and hold that state until " | |
"manually cancelled (Ctrl+C)." | |
), | |
) |
This file contains 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
/** | |
* A Vue mixin to map local component state to URL query. | |
* | |
* Uses vue-router's $route.query to get/set the query params. | |
* | |
* Useful e.g. to store and restore filters to/from the URL. | |
* | |
*/ | |
var urlState = { | |
data() { |
This file contains 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 .hook import register_module_excepthook | |
from .hook import install_global_excepthook | |
def some_module_function_that_may_fail(): | |
raise ValueError("whoops!") | |
def module_excepthook(type_, value, tb): | |
print("Gosh, " + __name__ + " has produced an error!") |
OlderNewer