Skip to content

Instantly share code, notes, and snippets.

View mrroot5's full-sized avatar
🏠
Working from home

Adrián mrroot5

🏠
Working from home
View GitHub Profile
@mrroot5
mrroot5 / git_branch_remove_merged_branches_to_master.md
Created May 11, 2020 06:55
Eliminar las ramas que ya han sido mergeadas a master. Keywords: merged, release, branch, merged brances

Intro

A veces podemos acumular muchas ramas de git en nuestro repositorio local. Se asume el uso de [git flow o similar][git-flow].

Eliminar ramas en local

Para poder eliminarlas sin eliminarlas en el repositorio remoto podemos usar este comando:

@mrroot5
mrroot5 / python_list_differences.md
Created April 27, 2020 09:19
Python obtener las diferencias entre dos listas. Keywords: python, python diff, python differences, python list, python list diff, python list differences

Intro

En este snippet vamos a ver como poder obtener las diferencias entre doos listas de dos formas diferentes.

Obtener todas las diferencias entre las dos listas

En este caso se devuelven todas las diferencias entre las dos listas.

list0 = ["foo", "bar", "goku"]
@mrroot5
mrroot5 / temporal_model_django_test.md
Created April 16, 2020 11:02
Crear un model temporal para test en Django: Keyworkds: Django, test, model test, modelo temporal django test

Intro

Sacado de aquí: https://stackoverflow.com/a/503435/3377046.

Post

You can put your tests in a tests/ subdirectory of the app (rather than a tests.py file), and include a tests/models.py with the test-only models.

Then provide a test-running script ([example][1]) that includes your tests/ "app" in INSTALLED_APPS. (This doesn't work when running app tests from a real project, which won't have the tests app in INSTALLED_APPS, but I rarely find it useful to run reusable app tests from a project, and Django 1.6+ doesn't by default.)

(NOTE: The alternative dynamic method described below only works in Django 1.1+ if your test case subclasses TransactionTestCase - which slows down your tests significantly - and no longer works at all in Django 1.7+. It's left here only for historical interest; don't use it.)

@mrroot5
mrroot5 / Flex.md
Last active April 11, 2020 12:24
Flex snippets. Keywords: flex, flexbox, flex grid, flex snippets, flex autosize, flex fijo, flex 100%, flex full width, flex width 100%, flex fixed size, flex tamaño fijo
@mrroot5
mrroot5 / json_schema_validator.py
Last active April 1, 2020 15:10 — forked from saadullahaleem/jsonschemafield.py
Django json schema validator
import json
import os
from django.contrib.postgres.fields import JSONField
from django.core.exceptions import ValidationError
from django.utils.deconstruct import deconstructible
from jsonschema import validate, exceptions as jsonschema_exceptions
@deconstructible
@mrroot5
mrroot5 / get_file_absolute_path.md
Created March 27, 2020 08:45
Obtener el path absoluto de un fichero relativo al fichero que estamos ejecutando. Keywords: path, dirname, realpath, join, path join, file, absolute, absolute path.

Intro

Pretendemos obtener la ruta absoluta real del sistema en base a la ubicación actual del fichero en el que estamos trabajando.

Obtener el directorio donde nos encontramos.

En este gist tienes explicado completamente el comando que usaremos a continuación: https://gist.github.com/mrroot5/0a3aff9d758beb44d77814eb74a59e49

@mrroot5
mrroot5 / node_nvm_install.nd
Created March 21, 2020 10:27
Instalación node con múltiples versiones usando nvm
# Intro
Pretendemos tener la opción de una instalación de múltiples versiones de node usando el mismo programa.
Para ello vamos a usar el magnífico NVM. Para mayor compatabilidad expondremos enlaces a documentos oficiales.
## Instalación
Para el primer paso necesitaremos tener instalado `curl` o `wget` para descargar e instalar el script de instalación.
Hay más métodos de instalación pero este es el más simple de todos:
@mrroot5
mrroot5 / add-markdown-index.md
Last active March 1, 2024 18:23
Agregar indice a markdown en wiki gitlab. Keywords: markdown, markdown index, index, gitlab, gitlab wiki, gitlab wiki index

Table of contents:

[[_TOC_]]

Intro

Diferentes formas de generar índices en Markdown.

GitLab

@mrroot5
mrroot5 / remove_merged_branches.md
Last active March 25, 2020 10:55
Eliminar ramas mergeadas a master

Intro

Elimina las ramas que han sido mergeadas a master asumiendo que el nombre del respositor de desarrollo es develop:

git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d
@mrroot5
mrroot5 / python_get_dirname_path_file.md
Last active May 29, 2020 07:09
Python obtener carpeta donde se ejecuta el fichero actual. Keywords: path, dirname, file, directory, directories, log, logs

Intro

Pretendemos obtener el path actual de un fichero concreto. Es muy útil para cargar ficheros de forma absoluta en base a la ruta actual donde estamos trabajando.

Obtener path completo

os.path.dirname(os.path.realpath(__file__))