Skip to content

Instantly share code, notes, and snippets.

View mmtechslv's full-sized avatar
Coding

Farid MUSA mmtechslv

Coding
View GitHub Profile
@dropwhile
dropwhile / install-setup.txt
Last active February 28, 2020 05:43
python serialization speed comparison
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
@vdboor
vdboor / catalogue | models.py
Last active February 25, 2021 12:29
A quick overview how to combine django-parler with django-oscar. This assumes you are familliar with the "Customising Oscar" topics (https://django-oscar.readthedocs.org/en/latest/topics/customisation.html). A screenshot of the integration was shown at DjangoConEU 2014 (http://django-fluent.org/blog/2014/05/lightning-talk-djangocon-eu-2014/)
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.
@esseti
esseti / checkbox.html
Created March 30, 2018 15:27
Beautiful widget for django multiple select
{% 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 %}
@aussielunix
aussielunix / aws_nvme-cloud-init.yml
Last active September 21, 2021 00:07
simple cloud-init for mounting an ephemeral nvme store in AWS. This is to be used as user-data.
#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:
#cloud-config
---
coreos:
fleet:
public-ip: "$public_ipv4"
units:
- name: flanneld.service
drop-ins:
- name: 50-network-config.conf
content: |
@vstoykov
vstoykov / force_default_language_middleware.py
Last active August 8, 2023 08:24
Force Django to use settings.LANGUAGE_CODE for default language instead of request.META['HTTP_ACCEPT_LANGUAGE']
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
MiddlewareMixin = object
class ForceDefaultLanguageMiddleware(MiddlewareMixin):
"""
Ignore Accept-Language HTTP headers
@mpetroff
mpetroff / jail.local
Last active December 19, 2023 12:06
JupyterHub PAM Authentication Fail2ban Configuration
# /etc/fail2ban/jail.local
[jupyterhub]
enabled = true
port = 443
filter = jupyterhub
backend = systemd
maxretry = 6
@vtrifonov-esfiddle
vtrifonov-esfiddle / cloud-init.yaml
Last active January 5, 2024 17:42
cloud-init config for ubuntu host with docker & docker-compose
#cloud-config
groups:
- docker
users:
- default
# the docker service account
- name: docker-service
groups: docker
package_upgrade: true
packages:
@peterhurford
peterhurford / pytest-fixture-modularization.md
Created July 28, 2016 15:48
How to modularize your py.test fixtures

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
@linderd
linderd / README.md
Last active March 13, 2024 19:06 — forked from timlinux/README.md
Linux on Thinkpad P14s Gen2 AMD / T14 Gen2 AMD

Linux (Fedora 35) on a Thinkpad P14s [T14] Gen2 AMD

These are my installation-tricks and notes for running Linux on a 2021 Thinkpad P14s Gen2 with AMD Ryzen 7 5850U. It should also be suitable for the Thinkpad T14 Gen2 AMD as they are technically the same modell.
Meanwhile there is also a good test on youtube and an entry in the arch-wiki, which also comments some points mentioned here.

Detailed specs

Shipped: