Skip to content

Instantly share code, notes, and snippets.

View ibernabel's full-sized avatar

Idequel Bernabel ibernabel

View GitHub Profile
def count_numbers_without_adjacent_repeats():
# Initialize count to 0
count = 0
# Loop through all possible numbers from 000000 to 999999
for num in range(1000000):
print(num)
# Convert the number to a string
num_str = str(num).zfill(6)
@ibernabel
ibernabel / diff-between-dates.js
Created February 19, 2024 21:28
Diff between two dates using vanilla JavaScript
// Fechas proporcionadas como cadenas
//const fechaInicioStr = "2017-08-01";
const fechaInicioStr = "2023-02-18";
const fechaFinalStr = "2024-02-17";
// Parsear las fechas
const fechaInicio = new Date(fechaInicioStr);
const fechaFinal = new Date(fechaFinalStr);
// Calcular la diferencia en milisegundos
@ibernabel
ibernabel / diff-daysjs.js
Created February 19, 2024 21:25
dayjs diff between two date in day and hours
const date1 = dayjs('2021-03-13');
const date2 = dayjs();
let hours = date2.diff(date1, 'hours');
const days = Math.floor(hours / 24);
hours = hours - (days * 24);
console.log('Days: ', days);
console.log('Hours: ', hours);
@ibernabel
ibernabel / best-place-to-work-web-scraping.js
Last active April 23, 2024 15:46
Script to extract the information of the best places to work, published by Great Place To Work. To obtain the data and export it as a JSON file. URL: https://www.greatplacetowork.com/best-workplaces/100-best/2023
let elements0 = document.querySelectorAll(".rank");
let rank = Array.from(elements0).map(function(element) {
return element.textContent.replace(/\s+/g, '');
});
//---
let elements1 = document.getElementsByClassName("link h5");
let names = Array.from(elements1).map(function(element) {
return element.textContent.trim();
});
//---
@ibernabel
ibernabel / click-to-web-whatsapp.js
Created February 9, 2024 16:04
Script to go (select) to the WhatsApp web version when sending an automatic message.
setTimeout(function(){
const url = window.location.href;
if(url.includes("api.whatsapp.com")){
let button = document.querySelector("#action-button");
button.click();
setTimeout(function(){
let link = document.querySelector("#fallback_block > div > div > h4:nth-child(2) > a");
link.click();
},300);
}
@ibernabel
ibernabel / actual-course-duration-platzi.js
Last active April 23, 2024 15:43
Script to print, by console, the actual duration of Platzi courses.
//Duracion real del curso mas guardado datos en local por 24 horas
//Mas guardado en especifico por nombre del curso
setTimeout(function () {
if (window.location.href.includes("/cursos/")) {
setTimeout(function () {
let parrafs = Array.from(document.querySelectorAll('.ContentClass-item-content > p'));
let duracionMinutos = 0;
let duracionSegundos = 0;
parrafs.forEach(function (element) {

Inicializar un proyecto

  • npm init: Inicializa un proyecto. Luego tienes que responder preguntas básicas del proyecto
  • npm init -y: Inicializa un proyecto con una descripción por defecto de las preguntas bases

Instalando dependencias

  • npm install: Instala las dependencias escritas del package.json
  • npm install package-name: Instala el paquete de nombre package-name y lo guarda como dependencia para producción
  • npm install package-name --save-dev: Instala el paquete y lo guarda como dependencia de desarrollo