Skip to content

Instantly share code, notes, and snippets.

View juanpablocs's full-sized avatar
👨‍💻 Coding..

Juan pablo juanpablocs

👨‍💻 Coding..
View GitHub Profile
juanpablocs /
Last active April 13, 2024 02:34
Docker run vps

Docker run web

first create Dockerfile second build 3 push on registry github or vultr

Docker nginx basic

FROM nginx:latest

SelectBox Typescript

version 1

import React, { FC } from 'react';

// Definición de tipos
interface Option {
  label: string;
  value: string;
juanpablocs /
Last active March 22, 2024 22:15 — forked from Andrey2G/encoding.txt
Video Encoding with multiple resolutions

Encoder mp4 to m3u8

ffmpeg -i \
-map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 \
-c:v libx264 -crf 22 -c:a aac -ar 48000 \
-filter:v:0 scale=w=480:h=360  -maxrate:v:0 600k -b:a:0 64k \
-filter:v:1 scale=w=640:h=480  -maxrate:v:1 900k -b:a:1 128k \
-filter:v:2 scale=w=1280:h=720 -maxrate:v:2 900k -b:a:2 128k \
-var_stream_map "v:0,a:0,name:360p v:1,a:1,name:480p v:2,a:2,name:720p" \
juanpablocs /
Last active October 18, 2023 22:34
create library npm

Publish library on github registry NPM

configure github action:

name: Publish Library
   types: [created]
juanpablocs /
Last active July 19, 2023 18:20
mongo dump bash

Mongo dump bash

download all db with gzip mongo backup and delete backups old 10 days before

DATE=$(date +"%Y%m%d")

Video Stream with node.js

the part of code is express

app.get("/video", (req, res) => {
// indicates the part of a document that the server should return
// on this measure in bytes for example: range = 0-6 bytes.
const  range = req.headers.range;
if (!range) res.status(400).send("Range must be provided");
juanpablocs /
Created May 20, 2022 04:38
useAxios with global error boundaries

hook axios sugar

import { useEffect, useRef } from 'react';
import axios, { AxiosError, AxiosRequestConfig } from 'axios';
import _useAxios, { configure } from 'axios-hooks';
import { useErrorHandler } from 'react-error-boundary';
import { useToast } from '@chakra-ui/react';

import { API_URL } from '../config';
juanpablocs /
Last active November 14, 2021 02:51
Geo Country, ISO, DIAL, JSON

Countries GEO

Json file from countries and iso and dial data for users register.

$file = file_get_contents(dirname(__FILE__)."/countries.json");
$json = json_decode($file, true);

juanpablocs /
Last active September 15, 2021 17:10
React testing Library and jest tips and tricks

Jest and React testing library

Funciones globales para ejecutar pruebas describe(name, cb) te permite agrupar varios test unitarios y dentro podemos usar it(name, cb) o test(name, cb) para acceder a un elemento screen y para debugear screen.debug()

usamos render de @testing-library/react para pintar y evaluar el componente.

para acceder al dom del componente usamos screen y buscar elementos con getBy... y con promise findBy...

los objetos y funciones mas usados

juanpablocs /
Created April 6, 2021 05:45
Tipo de cambio Sunat Api TXT