Skip to content

Instantly share code, notes, and snippets.

@lmn3x
lmn3x / code_meli_validator.py
Last active August 23, 2023 05:45
django validator for code meli
from django.core.exceptions import ValidationError
def validate_meli_code(value: str):
if not len(value) == 10:
raise ValidationError("کد ملی باید ۱۰ رقم باشد.")
res = 0
for i, num in enumerate(value[:-1]):
res = res + (int(num) * (10 - i))
@lmn3x
lmn3x / django-pagination.html
Last active October 31, 2021 06:14
bootstrap pagination in django
<div class="d-flex justify-content-center">
<span class="float-right">
{{ page_obj.start_index }}تا{{ page_obj.end_index }} از {{ page_obj.paginator.count }}
</span>
<nav aria-label="Page navigation example">
<ul class="pagination">
{% if page_obj.has_previous %}
<li class="page-item"><a class="page-link" href="?page=1
@lmn3x
lmn3x / wget.sh
Created June 1, 2021 12:09 — forked from crittermike/wget.sh
Download an entire website with wget, along with assets.
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.