Skip to content

Instantly share code, notes, and snippets.

View lfelguetac's full-sized avatar

LF lfelguetac

  • METAVERSE
View GitHub Profile
@lfelguetac
lfelguetac / gist:c621085f7f3279eea22f62f7a9e246ae
Last active July 29, 2022 21:44
Esta rutina permite comprimir audios y cambiar el formato desde Node.
import ffmpeg from "fluent-ffmpeg";
import { promises as fs } from 'fs';
function convertAudioTo (srcPath:string, fileName:string): Promise<string> {
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
ffmpeg.setFfmpegPath(ffmpegPath);
@lfelguetac
lfelguetac / semi-primos.ts
Created October 18, 2021 22:57
listado de numeros semi-primos
// obtener un listado de numeros semi-primos contenidos en un rango de numeros.
const getSemiPrimos = (inicio, fin) => {
let semiPrimos = [];
const primos = getPrimos(fin);
primos.map(n => {
const secSemis = nextSemiInRango(n, primos, inicio, fin)
semiPrimos = semiPrimos.concat(secSemis);
});
@lfelguetac
lfelguetac / counter.ts
Last active October 18, 2021 23:00
contador de palabras
const cleanWords = (words: string) => {
return words.replace(/[,|.|:]/g, '');
}
const countWords = (glosa: string) => {
const words = cleanWords(glosa).split(' ');
let output = [] as unknown as [{key: string, value: number}];
for (const word of [...new Set(words)] ) {
output.push({key: word, value: words.filter(it => it === word).length})
}
@lfelguetac
lfelguetac / fibonacci.ts
Created October 18, 2021 22:55
secuencia fibonacci
const getFibonnaci = (n: number) => {
let fibonnaci = [0, 1];
let large = fibonnaci.length;
while (true) {
let nextValue = fibonnaci[large-2] + fibonnaci[large-1]
if (nextValue > n) break
fibonnaci.push(nextValue);
large = fibonnaci.length;