Skip to content

Instantly share code, notes, and snippets.

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

Ariel Ivan Diaz arielivandiaz

🏠
Working from home
View GitHub Profile
@arielivandiaz
arielivandiaz / kill.sh
Created January 14, 2024 07:25
kill-process-by-port.sh
#!/bin/bash
# Check if a port number was provided
if [ $# -eq 0 ]; then
echo "Usage: $0 port_number"
exit 1
fi
# Assign the first argument to a variable
PORT=$1
@arielivandiaz
arielivandiaz / oneLiners.js
Created April 19, 2022 15:20
One line important functions
// VARIABLES **************************************************************************
// Swapping Two Variables
[foo, bar] = [bar, foo];
// Conditional asignation
const fullName = name || 'buddy';
// NUMBERS **************************************************************************
// Check if a number is even
const isEven = (num) => num % 2 === 0;
@arielivandiaz
arielivandiaz / promises.js
Created April 18, 2022 15:25
JS-ES6 Cheatsheet Promises
//Promise.all
//Devuelve todas las promesas o el primer reject que ocurra
//***********************************************************************************/
const names = ["Victoria", "Ivan", "Katya", "Lina", "Jack"];
//Promise declaration
const returnAfter1sec = (value) => {
return new Promise((resolve, reject) => {
@arielivandiaz
arielivandiaz / strings.js
Created April 12, 2022 02:48
JS-ES6 Cheatsheet Strings
let name = "John Doe";
console.log(typeof name);
//Use template string
const user = "Ariel",
company = "Laguna";
const welcomeMsg = `Welcome ${user} to ${company}`;
//Number to String
let num = 99.97;
@arielivandiaz
arielivandiaz / arrays.js
Created April 12, 2022 00:08
JS-ES6 Cheatsheet Arrays
//Arrays elements could be with different types
let user = ["Ariel", 24, "Diaz"];
let [name, age, lastname] = user;
var arr = ["Pear", "Apple", "Orange"];
//CHECK IF IS AN ARRAY
console.log(Array.isArray(arr));
@arielivandiaz
arielivandiaz / switch_vs_constObj.js
Created May 21, 2021 20:03
Switch case vs Const Object Performance - Clean code with better performance.
//Switch case vs Const Object Performance
//Const Object is 20%-50% faster
//Comment the lines of code for "counter [x] ++;" and check the difference
const NAMES = [
'Zarya',
'Inna',
'Antoniya',
'Filippa',
'Irina',

Laguna Developer Tools

Laguna

LESSONS

📌 KEEP IT = {
      🎯 Especifico

@arielivandiaz
arielivandiaz / async.js
Created November 2, 2019 18:34
Async function for SQL
let getUser = async (userId) => {
let promise = new Promise((resolve, reject) => {
sql.query("SELECT * FROM `users` WHERE `id`=" + userId).then((userInfo) => {
resolve(userInfo);
}).catch((reject) => { //Sql reject
@arielivandiaz
arielivandiaz / killNode.md
Created May 20, 2019 16:53
Release the port after father was killed

sudo kill -9 sudo lsof -t -i:3838

@arielivandiaz
arielivandiaz / git_start.rm
Created December 19, 2018 17:09
Git start with HTTP & SSH
#SSH vs HTTP
Si usas HTTP por consola, te va a pedir usuario y contraseña o contraseña cada vez que realizas un pull/push
Si usas SSH, tus credenciales quedan guardadas en la PC y no necesitas loguearte para realziar acciones, pero para ello necesitas tener una key SSH en la PC/Servidor vinculada con la cuenta de github.
>En Windows Descargar git bash : [https://git-scm.com/](https://git-scm.com/)
## HTTP / SSH
Para usar git bash primero hay que configurar el usuario (probablemente si usaron github desktop esto no es necesario)
Ejecutar en el terminal: