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
# -*- 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
_________________________________________________ | |
___ __ _ _ ________ | |
/ _ \___ _/ /_____(_)___(_)__ ____ / _/ _/ | |
/ ___/ _ `/ __/ __/ / __/ / _ `/ _ \ _/ /_/ / | |
/_/ \_,_/\__/_/ /_/\__/_/\_,_/_//_/ /___/___/ | |
_________________________________________________ | |
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
/** | |
* 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!") |
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
.desktop-mode.application { | |
margin: 0 auto; | |
max-width: 1280px; | |
} | |
.desktop-mode.shadow-box { | |
position: fixed; | |
height: 100%; | |
width: 100%; | |
z-index: -99; | |
max-width: 1280px; |
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 django.contrib.sessions.models import Session | |
def yield_user_sessions(user): | |
"""Yield all Sessions associated with the user. | |
Note: This is extremely inefficient, since we have to deserialize | |
all existing Sessions. Consider this a debugging helper, not | |
a production tool. Should we need more frequent access to this | |
information, then adding a separate model to map users to |
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 -*- | |
"""Scrape all historical soccer world cup match results into a JSON file.""" | |
import json | |
import requests | |
from bs4 import BeautifulSoup | |
urls = [ |
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/bash | |
# | |
# Assuming you have a running ngrok session, this snippet fetches the | |
# https URL from ngrok's local API and renders it as a QR code in your | |
# terminal. You can then scan it with a mobile phone to quickly load | |
# that URL. | |
# | |
# Based on: | |
# https://github.com/stedolan/jq/issues/861 | |
# |
OlderNewer