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 re | |
from django import template | |
class BaseSimpleTag: | |
def __init__(self, context: dict): | |
self.context = context | |
self.request = context["request"] | |
def __str__(self): |
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.checks import register, Warning, Error | |
@register(deploy=True) | |
def check_celery_worker(**kwargs): | |
from celery import current_app | |
errors = [] | |
try: | |
assert current_app.control.inspect().ping(), "could not ping" |
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
#!/usr/bin/env python3 | |
""" | |
Enable or disable ad blocker via /etc/hosts file | |
""" | |
import os | |
import sys | |
import shutil | |
import argparse |
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
export ENV_PATHS=.venv/bin/activate:venv/bin/activate:env/bin/activate:../.venv/bin/activate:../venv/bin/activate:./bin/activate:.envrc | |
activate() { | |
for pos_file in $(echo $ENV_PATHS | tr ":" "\n") | |
do | |
if [ -f "$pos_file" ] | |
then | |
source "$pos_file" | |
fi | |
done |
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 validate_cif(cif): | |
# Remove RO if it was added | |
cif = str(cif).lower().lstrip("ro") | |
if not cif.isnumeric(): | |
# Must be numeric | |
return False | |
if len(cif) >= 10: | |
# Too long | |
return False | |
if len(cif) <= 1: |
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 MySQLdb | |
def task(): | |
try: | |
db = MySQLdb.connect( | |
db="my_db", user=user, passwd=passwd, | |
host=host, | |
ssl={ | |
"key": "/etc/ssl/private/client-key.pem", | |
"cert": "/etc/ssl/private/client-cert.pem", |
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 __future__ import print_function | |
import sys | |
import random | |
import psutil | |
from BTrees import IIBTree | |
from BTrees import IBBTree | |
mem_info = psutil.Process().memory_info() |