Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
👨‍💻 Coding..

Juan pablo juanpablocs

💭
👨‍💻 Coding..
View GitHub Profile
@juanpablocs
juanpablocs / useAxios.md
Created May 20, 2022
useAxios with global error boundaries
View useAxios.md

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 Nov 14, 2021
Geo Country, ISO, DIAL, JSON
View _countries.md

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);
@juanpablocs
juanpablocs / testing.md
Last active Sep 15, 2021
React testing Library and jest tips and tricks
View testing.md

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
juanpablocs / tipo_de_cambio.md
Created Apr 6, 2021
Tipo de cambio Sunat Api TXT
View tipo_de_cambio.md
@juanpablocs
juanpablocs / google_cookie.md
Created Oct 4, 2020
Google auth cookie with curl
View google_cookie.md
@juanpablocs
juanpablocs / ssl_client_cert_if.conf
Last active Sep 14, 2020 — forked from onnimonni/ssl_client_cert_if.conf
How to regex from nginx variable with map directive
View ssl_client_cert_if.conf
##
# I wanted to use same ssl client certificate CA in nginx for multple client certs
# but restrict the users outside our organisation accessing everything.
# Because I can decide what to put into the emailAddress I can force verify everything and only pass the proper users.
##
##
# This way you can restrict users only with email addresses from @koodimonni.fi
# Put this into http context in nginx configs
##
@juanpablocs
juanpablocs / reduce.md
Last active Sep 9, 2020
Reduce js basic examples..
View reduce.md

Simple

[1,2,3,4].reduce( (acc,current) => acc+current , 0); // result => 10

Object sum

[
 {item: 10},
@juanpablocs
juanpablocs / cors_proxy_pass.md
Last active May 19, 2020
How to configure nginx site with cors and proxy_pass
View cors_proxy_pass.md

Nginx config

server {
    listen 80;
    server_name site.dev;
    add_header 'Access-Control-Allow-Credentials' 'true';
    location /  {
       proxy_pass http://127.0.0.1:3001/;
 }
@juanpablocs
juanpablocs / gdrive.php
Created Mar 31, 2020
Google drive php 2020
View gdrive.php
<?php
/*
https://redirector.googlevideo.com/videoplayback?
id=62705830c2bbd616&
itag=22&
source=youtube&
requiressl=yes&
ei=G5-CXpqzGIn6Wa3MvvAB&
susc=ytcp&
@juanpablocs
juanpablocs / curl.md
Last active Jan 8, 2019
Curl commands utils for devops
View curl.md

1 to 10 requests and get only http code

curl -s -o /dev/null -I -w "Http Code: %{http_code}\n" "http://mysite.com?[1-10]"

10 request simultaneous and get only http code

seq 1 10 | xargs -I % -n 1 -P 10 curl -s -o /dev/null -I -w "http: %{http_code}\n" "http://mysite.com"