Skip to content

Instantly share code, notes, and snippets.

View almazkun's full-sized avatar
🐍
Parseltongue user

Almaz Kunpeissov almazkun

🐍
Parseltongue user
View GitHub Profile

Note you will need to have MySQL server available for it to work, otherwise append to the end of the settings/settings_local.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'mydatabase',
    }
}
@almazkun
almazkun / cloudflare_bulk_delete_dns.py
Last active February 4, 2022 10:30
Cloudflare bulk delete dns
"""
This module is contains a handy tool to bulk delete DNS records from Cloudflare DNS via API
Usage:
```bash
git clone https://gist.github.com/bb15b3fc54ec6cbe7476b52c49e7c4aa.git
cd bb15b3fc54ec6cbe7476b52c49e7c4aa
python3 ./cloudflare_bulk_delete_dns.py your_api_token zone_id
```
"""
# main/models.py
from django.core.validators import MaxValueValidator
class Product(WithSlug):
...
# all the other fields
tax_rate = models.PositiveIntegerField(
default=25,
help_text=_("Tax rate"),
# run the folder (recursively) finds all files of the provided extension
# or all files.
# Counts number of lines in each file.
# prints put the top 10 bigest files, by number of lines
# require python ver.: 3.9+
from pathlib import Path
def all_files(path=".", extention=None):
_ext = "**/*"
vars = ["var", "var1", "var2"]
with open("test.txt", "w+") as f:
for v in vars:
f.write(v + " ")
# test.txt
# var var1 var2
vars = ["var", "var1", "var2"]
with open("test.txt", "w+") as f:
for v in vars:
f.write(v + " ")
# text.txt
var var1 var2
@almazkun
almazkun / models.py
Last active November 23, 2020 09:47
from django.contrib.auth.models import User
class BillingProfile(models.Model):
payer = models.ForeignKey(User, on_delete=models.CASCADE)