hashFiles() {
local files=("$@")
if [[ ${#files[@]} -eq 0 ]]; then
echo "Error: No files provided" >&2
return 1
This file contains 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 celery import Celery | |
from celery.signals import worker_shutdown, task_postrun | |
from django.db import connections | |
app = Celery() | |
... | |
This file contains 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
atom dimension { | |
width: int? | |
height: int? | |
depth: int? | |
} | |
atom money { | |
amount: int | |
currency: string | |
} |
This file contains 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 | |
from django.contrib.postgres.indexes import GinIndex | |
from django.db.models.functions import Lower | |
class SearchableCharField(models.CharField): | |
def contribute_to_class(self, cls, name, **kwargs): | |
super().contribute_to_class(cls, name, **kwargs) | |
# Add a GIN index with trigram operations for fast search |
This file contains 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
""" | |
TODO: Use an strict environment like SandboxedEnvironment | |
TODO: Create an "allowed list" of filters and functions to use in the expression | |
TODO: Make or check the context object is inmutable (Prevent thread-safe situations) | |
""" | |
import json | |
from datetime import datetime | |
from jinja2 import Environment, meta, sandbox |
This small snippet can be implemented in your Django project to handle locks. It is particularly useful for replacing Redis locks, reducing dependency overhead. To use this snippet, simply copy and adapted to your Django project.
The hash_string function is used to convert a string value into a numerical hash value, as PostgreSQL advisory lock mechanism requires an integer.
Tested on Python3.11 and Django4
Learn more about advisory locks in:
This file contains 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
exclude = ["docs/*", "*/migrations/*", ".git/*"] | |
line-length = 100 | |
indent-width = 4 | |
target-version = "py311" | |
[lint] | |
select = [ | |
"E", # pycodestyle errors | |
"W", # pycodestyle warnings | |
"N", # pep8-naming |
This file contains 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 argparse | |
import shlex | |
from typing import List, Optional, TypedDict | |
class Command(TypedDict): | |
prefix: str | |
name: str | |
args: List[str] |
Adjunto encontrarás un script de Python llamado script.py y un archivo CSV llamado data.csv.
- El archivo data.csv contiene datos de productos con las siguientes columnas: product_id, name, category_name, price, quantity.
- El script script.py carga los datos del archivo CSV, calcula la media, el promedio y la moda de los precios de los productos agrupados por categoría, y muestra los resultados en la consola.
- Tu tarea es revisar el código del script script.py y proponer cambios, mejoras o identificar cualquier problema, similar a lo que harías en una revisión a un Merge Request.
- Prepara tus comentarios, sugerencias y mejoras propuestas para discutirlas durante la siguiente entrevista.
El objetivo de este ejercicio es evaluar tus habilidades para identificar problemas, proponer mejoras y más que todo comunicar tus ideas de manera efectiva.
This file contains 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
-3502362900466137214 |
NewerOlder