Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Adrián G mrroot5

🏠
Working from home
Block or report user

Report or block mrroot5

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mrroot5
mrroot5 / capitalize.py
Created May 8, 2019
Capitalize string
View capitalize.py
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_upgrade_remove.sh
Last active May 27, 2019
Mantenimiento de Ubuntu, actualización ap, snap y eliminación de paquetes obsoletos
View ubuntu_upgrade_remove.sh
sudo apt update && sudo apt full-upgrade && sudo snap refresh && sudo apt autoclean && sudo apt clean && sudo apt autoremove --purge
# Update packages list
# Upgrade packages
# Upgrade snap packages
# Remove old unnecessary apt packages.
# --purge delete all config files, etc. BECAREFUL!!!
View string_truncate.js
const truncateString = (str, num) =>
str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
truncateString('boomerang', 7); // 'boom...'
@mrroot5
mrroot5 / .zsh_aliases
Created Apr 16, 2019
Zsh alias. Asegúrate de que en .zshrc se hace referencia a este fichero, mira el ejemplo.Ambos ficheros deben estar en la home.
View .zsh_aliases
alias cdh="~/"
@mrroot5
mrroot5 / README_EN.md
Last active Mar 11, 2019
Nigthwatchjs chromedriver configuration
View README_EN.md

Versions

  • Nightwatch: 1.0.18.
  • Selenium standalone: 3.141.59.
  • Chromedriver: 2.46.

Step by step

  • Install chromedriver:
# Inside project
npm install chromedriver --save-dev
@mrroot5
mrroot5 / validate_spanish_id.js
Created Mar 2, 2019 — forked from afgomez/validate_spanish_id.js
Spanish DNI, CIF, NIE validator
View validate_spanish_id.js
/**
* ValidateSpanishID. Returns the type of document and checks its validity.
*
* Usage:
* ValidateSpanishID( str );
*
* > ValidateSpanishID( '12345678Z' );
* // { type: 'dni', valid: true }
*
* > ValidateSpanishID( 'B83375575' );
@mrroot5
mrroot5 / treeview.css
Last active Feb 23, 2019
React treeview
View treeview.css
.tree-element {
margin: 0;
position: relative;
}
div.tree-element:before {
content: '';
position: absolute;
top: 24px;
left: 1px;
@mrroot5
mrroot5 / min_number.py
Created Feb 20, 2019
Número mínimo de una lista de python
View min_number.py
from copy import deepcopy
def min_n(lst, n=1):
numbers = deepcopy(lst)
numbers.sort()
return numbers[:n]
View arrify.js
function arrify(val) {
return val == null ? [] : Array.isArray(val) ? val : [val];
}
@mrroot5
mrroot5 / url_params.js
Created Feb 3, 2019
Añade parámetros query string a una URL desde un objeto JSON. Usable por fetch
View url_params.js
function addParams(url = "", params = {}) {
// Inicializamos la URL
let myUrl = new URL(url);
// Obtenemos todas las keys de los parametros que nos vienen del objeto, en el ejemplo "foo" y "eggs"
// Usamos el foreach para recorrer cada key y extraer su valor con params[key]
// Con searchParams.append agregamos los parametro que queremos
Object.keys(params).forEach(key => openStreetMapReverseGeocodeUrl.searchParams.append(key, params[key]));
// Retornamos la url
return myUrl;
}
You can’t perform that action at this time.