Skip to content

Instantly share code, notes, and snippets.

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

Alejandro Medina wolftrax5

🏠
Working from home
View GitHub Profile
@wolftrax5
wolftrax5 / is-valid-email.ts
Created May 9, 2022 13:52 — forked from Klerith/is-valid-email.ts
Email validation - customHook
const isValidEmail = ( email: string ) => {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
@wolftrax5
wolftrax5 / Random.js
Created October 7, 2021 20:54
JS tools
/// get random index from the lenght of the array
let randomIndex = Math.floor(Math.random() * array.length)
{// Configuraciones para integrar ESLint, prettier y vscode
"editor.formatOnSave": true,
// Colocar Off el format de JS y JSX, para poder hacerlo via Eslint
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
// Esto le dice al plugin de ESLint que cualquier lint se ejecute al salvar.
/*
* @param row Array of Objects
* @param filterKey String
* @return Array of Objects
*/
const getFilteredRows = (rows, filterkey) => (
rows.filter((row) => JSON.stringify(row).toLowerCase().includes(filterkey))
);
@wolftrax5
wolftrax5 / werocomands.sh
Created March 31, 2021 04:15
Shell scripts
#!/bin/bash
# sprit to execute in a particular envionment
# rememeber made excutable sudo chmod +x werocomands.sh
# & run it where raspistill & v4l2 is enable
echo "Start wero's Scripts"
echo "Script one"
./raspistill -cs 0 -o test.jpg
sleep 1
echo "Script two"
@wolftrax5
wolftrax5 / Additems.js
Last active March 24, 2021 00:56
Array Tools
/*
combine 2 arrays
*/
const addMoreItemsInArray = (array = [], newItems = []) => [...array, ...newItems];
@wolftrax5
wolftrax5 / Base64.js
Created August 19, 2020 19:03
Base64 objecet to encode and decode data
// Create Base64 Object
var Base64 = {
_keyStr: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
encode: function (e) {
var t = ''; var n, r, i, s, o, u, a
var f = 0
e = Base64._utf8_encode(e)
while (f < e.length) {
n = e.charCodeAt(f++)
r = e.charCodeAt(f++)
@wolftrax5
wolftrax5 / console.js
Last active August 10, 2021 18:12
useful console logs examples
// https://developers.google.com/web/tools/chrome-devtools/console/?hl=es
const dogs = [{name: 'Snokers', age: 2}, {name: 'Dogger', age: 8}]
// regular
console.log('hello')
// interpolate
console.log('Hello i am %s old', dogs[0].age)
// template string whit Esc6
console.log(`Hello i am ${dogs[0].age} old`)
// styled
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<textarea name="text" id="text" cols="30" rows="10"></textarea>
<button id="button">Convert</button>