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 / string_truncate.js
Created April 24, 2019 09:41
Truncate string
const truncateString = (str, num) =>
str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
truncateString('boomerang', 7); // 'boom...'
@mrroot5
mrroot5 / .zsh_aliases
Last active October 4, 2022 14:17
Zsh alias. Asegúrate de que en .zshrc se hace referencia a este fichero, mira el ejemplo.Ambos ficheros deben estar en la home.
# Functions
#
# System functions
#
find_kill_process() {
# This function shows the process list and search on it
# Requires fzf available
pid=$(ps -ef | sed 1d | eval "fzf $FZF_DEFAULT_OPTS -m --header='[kill:process]'" | awk '{print $2}')
if [ ! -z "$pid" ]
then
@mrroot5
mrroot5 / README_EN.md
Last active March 11, 2019 11:27
Nigthwatchjs chromedriver configuration

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 March 2, 2019 18:04 — forked from afgomez/validate_spanish_id.js
Spanish DNI, CIF, NIE validator
/**
* 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 February 23, 2019 11:22
React treeview
.tree-element {
margin: 0;
position: relative;
}
div.tree-element:before {
content: '';
position: absolute;
top: 24px;
left: 1px;
@mrroot5
mrroot5 / min_number.py
Created February 20, 2019 12:09
Número mínimo de una lista de python
from copy import deepcopy
def min_n(lst, n=1):
numbers = deepcopy(lst)
numbers.sort()
return numbers[:n]
function arrify(val) {
return val == null ? [] : Array.isArray(val) ? val : [val];
}
@mrroot5
mrroot5 / url_params.js
Created February 3, 2019 20:02
Añade parámetros query string a una URL desde un objeto JSON. Usable por fetch
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;
}
@mrroot5
mrroot5 / nmap.sh
Created November 21, 2018 13:14
Nmap escaner de puertos
nmap -p 22 192.164.1.0/8
# -p: el puerto a buscar, en este caso ssh, el 22
# rango de ip a buscar: el /8 son toda las ip todas las ips del cero final
@mrroot5
mrroot5 / footer_center_logo.html
Created November 8, 2018 13:00
Bootstrap 4 logo centrado footer