Skip to content

Instantly share code, notes, and snippets.

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

Juan pablo juanpablocs

💭
👨‍💻 Coding..
View GitHub Profile
@juanpablocs
juanpablocs / docker.md
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
juanpablocs / encoding.md
Last active March 22, 2024 22:15 — forked from Andrey2G/encoding.txt
Video Encoding with multiple resolutions

Encoder mp4 to m3u8

ffmpeg -i https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_30mb.mp4 \
-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
juanpablocs / vite-library-npm.md
Last active October 18, 2023 22:34
create library npm

Publish library on github registry NPM

configure github action:

name: Publish Library
on:
 release:
   types: [created]
jobs:
 publish-library:
@juanpablocs
juanpablocs / tipo_de_cambio.md
Created April 6, 2021 05:45
Tipo de cambio Sunat Api TXT
@juanpablocs
juanpablocs / sunat.md
Last active September 4, 2023 20:10
Ver RUC de la Sunat con node.js sin captcha. Simple y rápido.

Ruc Sunat

Obtener resultados sin necesidad de captcha ni ocr. Simple código

Instalar paquetes

npm init -y
npm i request cheerio --save

Run

@juanpablocs
juanpablocs / mongo_bash.md
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

#!/bin/bash
BACKUP_DIR="$HOME/Backup/my-site"
DATE=$(date +"%Y%m%d")
BACKUP_FILE="$BACKUP_DIR/my-site_$DATE.gz"
DAYS_TO_KEEP=10

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
juanpablocs / useAxios.md
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
juanpablocs / _countries.md
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);

var_dump($json);