Skip to content

Instantly share code, notes, and snippets.

View dario61081's full-sized avatar
🎯
Focusing

Dario Garcia dario61081

🎯
Focusing
View GitHub Profile
@dario61081
dario61081 / consulta_objetos.vue
Created April 23, 2024 16:16
snipped para consulta del item dentro del array
methods: {
get_objetos_gastos() {
this.$service.get('../api/objetos_gastos')
then(response => {
this.objetos_gastos = response.data || [];
})
},
get_objeto(codigo) {
return this.objetos_gastos.find(item => item.codigo === codigo) || {}
}
root = true
[*]
indent_size = 2
indent_style = space
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
max_line_length = off
@dario61081
dario61081 / filters.vue
Created April 4, 2024 21:26
como filtrar registros multiples
computed: {
filtered_list(){
if (!this.filter){
return this.proveedores;
}
function filter01(item, filter){
return item.razon_social?.toString().toLowerCase().includes(filter);
}
@dario61081
dario61081 / backup_utils.py
Created February 26, 2024 14:38
backup utils
class BackupApi(MethodView):
def get(self):
def filesize_humanize(size):
if size < 1024:
return f'{size} bytes'
elif size < 1024 * 1024:
return f'{size / 1024:.2f} KB'
elif size < 1024 * 1024 * 1024:
return f'{size / 1024 / 1024:.2f} MB'
@dario61081
dario61081 / messages.py
Created February 26, 2024 14:22
mensajes del sistema
from flask import flash, session
from core.logs import logger
str_message_success = 'Operación ejecutada con exito'
str_message_error = 'Ha ocurrido un error al ejecutar la operación'
def success_message(msg: str = None):
"""Show positive flash message"""
@dario61081
dario61081 / decorators.py
Created February 26, 2024 14:18
decoradores varios
from functools import wraps
def require_permission(func):
@wraps(func)
def eval_permission(permission: str, *args, **kwargs):
return func(*args, **kwargs)
return eval_permission
@dario61081
dario61081 / encoder.py
Created January 26, 2024 00:00
Encode actualizado para flask
class CustomJsonEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, list):
return [self.default(o) for o in obj]
elif isinstance(obj, datetime.date):
return obj.isoformat()
elif isinstance(obj, datetime.datetime):
return obj.isoformat()
function generateUUID(){
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
let r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
return v.toString(16);
})
}
@dario61081
dario61081 / docker-compose.yml
Created December 25, 2023 21:38
docker-compose para servidor mysql tz=-4
version: '3.3'
volumes:
database:
services:
database:
image: mysql/mysql-server:latest
container_name: database
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
@dario61081
dario61081 / check_requirements_flask.py
Last active December 24, 2023 17:16
Funciones para verificar integridad de datos
# @app.before_first_request
# def before_first_request():
# logger.debug("Verificando modelos")
# models = ModelBase.__subclasses__()
# logger.debug(f"modelos encontrados: {models}")
# check_models_requirements(models)
# def check_models_requirements(models):
# """Check if the models are created in the database, if not, create them."""