Skip to content

Instantly share code, notes, and snippets.

View mrroot5's full-sized avatar
🏝️
Relaxing

Adrián mrroot5

🏝️
Relaxing
View GitHub Profile
@mrroot5
mrroot5 / README.md
Last active October 8, 2019 09:13
Dynamic shadow: sombra dinámica que cambia de color según el color de fondo del elemento

Explanation

  • position: relative on the element establishes a Cartesian positioning context for psuedo-elements.
  • z-index: 1 establishes a new stacking context.
  • ::after defines a pseudo-element.
  • position: absolute takes the pseudo element out of the flow of the document and positions it in relation to the parent.
  • width: 100% and height: 100% sizes the pseudo-element to fill its parent's dimensions, making it equal in size.
  • background: inherit causes the pseudo-element to inherit the linear gradient specified on the element.
  • top: 0.5rem offsets the pseudo-element down slightly from its parent.
  • filter: blur(0.4rem) will blur the pseudo-element to create the appearance of a shadow underneath.
@mrroot5
mrroot5 / vue-domcontentloaded.vue
Created September 11, 2019 15:23
Vue DOMContentLoaded: usar vue como si fuera el DOMContentLoaded de JavaScript
<template>
<div>{{ asyncText }}</div>
</template>
<script>
export default {
data: () => ({
asyncText: 'Mi componente'
}),
// Usamos el mounted como punto de inicio
@mrroot5
mrroot5 / vuex-persistedstate.md
Created August 12, 2019 09:04
Nuxt vuex-persistedstate no guarda el estado en el localstorage

Problema

Al actualizar el store de Vuex usando Nuxt con el plugin vuex-persistedstate no se actualiza el LocalStorage del navegador.

Solución

La clave radica en establecer que primero cargue nuxt y después actualice el Storage. Un simil sería el "onReadY" de jQuery para el navegador.

@mrroot5
mrroot5 / cssgrid-avoid-content-overflow.css
Created July 21, 2019 16:51
Evitar desbordamiento del contenido en css grid. Avoid css grid content overflow
.highligth {
color: red;
}
.grid-container {
display: grid;
grid-template-columns: minmax(0, auto) minmax(0, auto) minmax(0, auto);
grid-template-rows: minmax(0, auto);
grid-gap: 0 1rem;
border: 2px solid black;
}
@mrroot5
mrroot5 / dev_environment_install.md
Last active June 5, 2019 11:23
Instalar entorno de desarrollo

SH

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
nvm install --lts
pip3 install docker-compose
pip3 install pylint

SNAP

@mrroot5
mrroot5 / requirements.apt-install.md
Last active May 30, 2019 10:16
Instalar requirements.apt desde la terminal usando apt-get

Introducción

Queremos instalar todos los requirements de un fichero llamado requirements.apt.

Método 1: tr

sudo apt-get -y install $(tr '\n' ' ' < requirements.apt)
# -y: instalacion automatica sin preguntas

Método 2: cat

@mrroot5
mrroot5 / functional_programming.md
Last active May 18, 2019 17:33
What is functional programming?

Explanation

Functional programming is a paradigm in which programs are built in a declarative manner using pure functions that avoid shared state and mutable data. Functions that always return the same value for the same input and don't produce side effects are the pillar of functional programming. Many programmers consider this to be the best approach to software development as it reduces bugs and cognitive load.

  • Cleaner, more concise development experience
  • Simple function composition
@mrroot5
mrroot5 / rgb2hex.js
Created May 14, 2019 06:03
RGB a hexadecimal
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
RGBToHex(255, 165, 1); // 'ffa501'
@mrroot5
mrroot5 / capitalize.py
Created May 8, 2019 09:21
Capitalize string
def capitalize(string, lower_rest=True):
return string[:1].upper() + (string[1:].lower() if lower_rest else string[1:])
capitalize('fooBar') # 'Foobar'
capitalize('fooBar', False) # 'FooBar'
@mrroot5
mrroot5 / ubuntu_maintenance_remove_upgrade.md
Last active September 20, 2024 17:24
Mantenimiento de Ubuntu, actualizar apt, snap y eliminación de paquetes obsoletos

Intro

El objetivo de este snippets es explicar como mantener actualizado tu sistema evitando que queden versiones innecesarias que no uses.

Mantenimiento Ubuntu: Actualización

Actualizar paquetes