Skip to content

Instantly share code, notes, and snippets.

View Falciighol's full-sized avatar
📷
Say JS!

Juampa Falciighol

📷
Say JS!
View GitHub Profile
@Falciighol
Falciighol / arrayPagination.js
Created March 13, 2020 22:15
[Array pagination] Slice an array with the page size and page number params #javascript #js
function paginate(array, page_size, page_number) {
// human-readable page numbers usually start with 1, so we reduce 1 in the first argument
return array.slice((page_number - 1) * page_size, page_number * page_size);
}
console.log(paginate([1, 2, 3, 4, 5, 6], 2, 2));
console.log(paginate([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 4, 1));
@Falciighol
Falciighol / consoleScriptCall.js
Created November 12, 2019 21:45
[Console Script Call] Call an external or local script from console #js #bp
document.head.appendChild(Object.assign(
document.createElement('script'),
{ src: 'https://momentjs.com/downloads/moment-with-locales.js' }
));
// Example
console.log(moment("2011-10-31", "YYYY-MM-DD").format('DD/MM/YYYY'));
@Falciighol
Falciighol / professions.json
Created October 30, 2019 19:25
[Professions List] Professions list in spanish #json #bp #list
[
{
"CODPROFESI": 1,
"DESPROFESI": "ABOGADO"
},
{
"CODPROFESI": 2,
"DESPROFESI": "AEROTECNICO"
},
{
@Falciighol
Falciighol / svMunicipalities.json
Created October 30, 2019 15:47
[El Salvador Municipalities] El Salvador municipalities list #json #list #bp
[
{
"DESCIUDAD": "AHUACHAPAN",
"CODDEPTO": 1,
"CODCIUDAD": 1
},
{
"DESCIUDAD": "APANECA",
"CODDEPTO": 1,
"CODCIUDAD": 2
@Falciighol
Falciighol / countriesList.json
Last active October 20, 2022 02:49
[Countries list] Countries list (in spanish) #json #list #bp
[
{
"CODPAIS": 93,
"DESPAIS": "AFGANISTAN"
},
{
"CODPAIS": 355,
"DESPAIS": "ALBANIA"
},
{
@Falciighol
Falciighol / numberToLetters.js
Created October 15, 2019 17:04
[Number to Letters] Change a number (Integer/Double) value to letters #js #bp
var numeroALetras = (function() {
// Código basado en el comentario de @sapienman
// Código basado en https://gist.github.com/alfchee/e563340276f89b22042a
function Unidades(num) {
switch (num) {
case 1:
return 'UN';
case 2:
return 'DOS';
@Falciighol
Falciighol / pagoFunc.js
Last active August 4, 2022 07:14
[Excel PAGO Func] Función PAGO de Excel en Javascript #js #bp
// Basado en la formula de matemática financiera:
// https://luismasanchezmaestre.files.wordpress.com/2014/08/calculo-anualidad.jpg
var a = 0;
// Monto
var co = 5700;
// Años
var n = 13;
// Pagos Anuales
var m = 12;
// Tasa Interes
@alfchee
alfchee / NumeroALetras.js
Last active June 15, 2024 09:21
Código en JavaScript que convierte números a letras, bastante útil para formularios de documentos contables y similares
/*************************************************************/
// NumeroALetras
// The MIT License (MIT)
//
// Copyright (c) 2015 Luis Alfredo Chee
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights