In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:
- Separate big codebases into multiple repositories.
try: | |
from django.utils.deprecation import MiddlewareMixin | |
except ImportError: | |
MiddlewareMixin = object | |
class ForceDefaultLanguageMiddleware(MiddlewareMixin): | |
""" | |
Ignore Accept-Language HTTP headers | |
virtualenv --no-site-packages hodor | |
hodor/bin/pip install simplejson ujson cbor tnetstring msgpack-python | |
curl -s 'http://www.json-generator.com/api/json/get/cvfsLVmKiG?indent=2' > test.json | |
hodor/bin/python shootout.py |
from oscar.apps.catalogue.abstract_models import AbstractProduct, | |
from parler.models import TranslatableModel, TranslatedFields | |
class Product(AbstractProduct, TranslatableModel): | |
""" | |
Add translations to the product model. | |
""" | |
# Provide translated fields. |
NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.
If you are not into long explanations, see [Paolo Bergantino’s answer][2].
#cloud-config | |
--- | |
coreos: | |
fleet: | |
public-ip: "$public_ipv4" | |
units: | |
- name: flanneld.service | |
drop-ins: | |
- name: 50-network-config.conf | |
content: | |
# /etc/fail2ban/jail.local | |
[jupyterhub] | |
enabled = true | |
port = 443 | |
filter = jupyterhub | |
backend = systemd | |
maxretry = 6 |
Using py.test is great and the support for test fixtures is pretty awesome. However, in order to share your fixtures across your entire module, py.test suggests you define all your fixtures within one single conftest.py
file. This is impractical if you have a large quantity of fixtures -- for better organization and readibility, you would much rather define your fixtures across multiple, well-named files. But how do you do that? ...No one on the internet seemed to know.
Turns out, however, you can define fixtures in individual files like this:
tests/fixtures/add.py
import pytest
@pytest.fixture
{% with id=widget.attrs.id %} | |
{% for group, options, index in widget.optgroups %} | |
{% for option in options %} | |
{% with widget=option %} | |
{% include widget.template_name%} | |
{% endwith %} | |
{% endfor %} | |
{% endfor %} | |
{% endwith %} |
#cloud-config | |
repo_update: true | |
repo_upgrade: all | |
package_upgrade: true | |
bootcmd: | |
- test -z "$(blkid /dev/nvme0n1)" && mkfs -t ext4 -L scratch /dev/nvme0n1 | |
mounts: |