Skip to content

Instantly share code, notes, and snippets.

@Wellers0n
Wellers0n / redirect-nextjs-url.ts
Created February 14, 2023 14:30
redirect url nextjs url from http to htttps
if (
PRODUCTION_ENV &&
request.headers.get("x-forwarded-proto") !== "https"
) {
const hostname = request.headers.get("host") || request.nextUrl.hostname;
return NextResponse.redirect(
`https://${hostname}${request.nextUrl.pathname}`
);
}
@Wellers0n
Wellers0n / query-params-nextJS.tsx
Created January 5, 2023 16:23
passing array to query params with nextJS
const { query } = router
const queryParams = {
[field]: [value]?.concat?.(query[field] || [])
}
router.replace({
query: { ...query, ...queryParams },
});
@Wellers0n
Wellers0n / MuiltSelect.tsx
Created January 4, 2023 18:58
MuiltSelect with mui
import { TextField } from '@mui/material';
import Autocomplete from '@mui/material/Autocomplete';
import { useFormikContext } from 'formik';
import React from 'react';
type OptionsValues = {
title: string,
value: string
}
@Wellers0n
Wellers0n / pull-request.yml
Last active December 17, 2022 19:27
pull-request
name: ci
on:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
env:

Install pyenv

brew update
brew install pyenv

.zsh config

export PYENV_ROOT="$HOME/.pyenv"
@Wellers0n
Wellers0n / docker-compose.yml
Created December 4, 2021 13:09
docker-compose
version: '3.9'
services:
postgres:
image: 'postgres:13'
ports:
- '5432:5432'
volumes:
- postgres:/data/db
environment:

Github Two-Factor Authentication (2FA) for Brazil via SMS

The Github doesn't provide country code for Brazil (+55). To add this option, just run the code below in your console:


🇧🇷 [pt-BR]

Autenticação em dois fatores (2FA) do GitHub para o Brasil via SMS

@Wellers0n
Wellers0n / context.js
Created September 30, 2020 19:10
context
import React from 'react'
const Context = React.createContext({})
const withContext = Component => props => {
const [state, setState] = React.useState()
return (
<Context.Provider value={[state, setState]}>
<Component {...props} />
@Wellers0n
Wellers0n / setup-jest-redux.js
Created August 20, 2020 17:21
mock redux jest
import React from 'react'
import { render } from '@testing-library/react'
import { createStore } from 'redux'
import { Provider } from 'react-redux'
import reducers from 'your-reducers'
function renderWithRedux(
ui,
{ initialState, store = createStore(reducers, initialState) } = {}
) {