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
git log --author=<emailregex> --pretty=tformat: --numstat | awk '{ adds += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s, added:deleted ratio:%s\n", adds, subs, loc, adds/subs }' - |
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
/** | |
* Calcula el dígito verificador del RUC utilizando el algoritmo basado en el módulo 11 (Cálculo de la DNIT/SET). | |
* Ref: https://www.dnit.gov.py/documents/20123/224893/D%C3%ADgito+Verificador.pdf/fb9f86c8-245d-9dad-2dc1-ac3b3dc307a7?t=1683343426554.pdf | |
* | |
* @author Marcelo Elizeche Landó | |
* @license MIT | |
* | |
* @param {number} numero - Número base(CI o RUC sin DV) para calcular el dígito verificador. | |
* @param {number} [basemax=11] - Base máxima para los multiplicadores (por defecto 11, ver PDF de la DNIT). | |
* @returns {number} Dígito verificador calculado. |
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 calcular_digito_verificador(numero: int, basemax: int = 11) -> int: | |
""" | |
Calcula el dígito verificador del RUC utilizando el algoritmo basado en el módulo 11. | |
Ref: https://www.dnit.gov.py/documents/20123/224893/D%C3%ADgito+Verificador.pdf/fb9f86c8-245d-9dad-2dc1-ac3b3dc307a7?t=1683343426554.pdf | |
Autor: Marcelo Elizeche Landó | |
Licencia: MIT | |
Args: | |
numero (int): Número base(CI o RUC sin DV) para calcular el dígito verificador. |
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
Postgres Internals | |
Djangocon US 2024 | |
Elizabeth Christensen | |
## psql basics | |
--whoami | |
\conninfo | |
--user list |
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
# BRANCH_PREFIX will match everithing before the first underscore so if your branch name | |
# is ESGCA-9999_my_awesomefeature and your commit message is 'Fixes Changes Rabbits' | |
# your "final" commit message will be: 'ESGCA-9999: Fixes Changes Rabbits' | |
COMMIT_MSG_FILE=$1 | |
BRANCH_PREFIX=$(git branch | grep '*' | sed 's/* //' | cut -d _ -f 1) | |
echo "$BRANCH_PREFIX: $(cat $COMMIT_MSG_FILE)" > "$COMMIT_MSG_FILE" | |
# Copy this file in the .git/hooks/ directory of your local repo and make it executable `chmod +x prepare-commit-msg` |
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
class SampleFilter(filters.FilterSet): | |
start_date = django_filters.DateFilter(name="date", lookup_type='gte') | |
end_date = django_filters.DateFilter(name="date", lookup_type='lte') | |
# How to filter by a foreign key that uses slug as a lookup | |
foo = django_filters.ModelMultipleChoiceFilter( | |
queryset=MyModel.objects.all(), | |
to_field_name='slug', | |
conjoined=True, | |
) | |
class Meta: |
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.db.models import Count, Max | |
from core.models import HelpRequest | |
unique_fields = ['phone', 'title'] | |
actives = HelpRequest.objects.filter(active=True) | |
duplicates = ( | |
actives.values(*unique_fields) | |
.order_by() |
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
# Primero hay que instalar las librerias necesarias | |
# pip install requests beautifulsoup4 | |
import requests | |
from bs4 import BeautifulSoup | |
# Descargamos la pagina del BCP | |
bcp = requests.get('https://www.bcp.gov.py/webapps/web/cotizacion/monedas', | |
headers={'user-agent': 'Mozilla/5.0'}, verify=False) | |
#buscamos todas las etiquetas <td>, elegmos la cuarta, elegimos el texto, reemplazamos el . separador de miles y la coma decimal | |
cotizacion = float(BeautifulSoup(bcp.text).findAll("td")[3].get_text().replace(".","").replace(",",".")) |
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.db import models | |
# Un Autor puede tener varios libros | |
# Un libro puede tener un autor | |
# Un Libro puede tener varios Generos | |
# Un Genero puede pertenecer a varios libros | |
# null=True, blank=True hace que el campo sea opcional | |
class Autor(models.Model): | |
nombre = models.CharField(max_length=120) |
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 python | |
import sys | |
import subprocess | |
diff_requirements = 'git diff ORIG_HEAD HEAD --exit-code -- requirements.txt' | |
exit_code = subprocess.call(diff_requirements.split()) | |
if exit_code == 1: | |
print 'The requirements file has changed! Remember to install new dependencies.' | |
else: |
NewerOlder