Skip to content

Instantly share code, notes, and snippets.

View feliperodriguess's full-sized avatar
👨‍💻

Felipe Rodrigues feliperodriguess

👨‍💻
  • Florianópolis, Brazil
  • 20:53 (UTC -03:00)
View GitHub Profile
@feliperodriguess
feliperodriguess / codegen.yaml
Last active August 15, 2022 02:08
GraphQL CodeGen + React Query + TypeScript
schema: http://localhost:3000/graphql
documents: "./src/**/*.graphql"
generates:
./src/graphql/generated.ts:
plugins:
- typescript
- typescript-operations
- typescript-react-query
config:
fetcher: "./utils#fetcher"
@feliperodriguess
feliperodriguess / docker-compose.yml
Created August 12, 2022 05:16
Postgres Docker Compose Snippet
version: '3.8'
services:
db:
image: postgres:14.1-alpine
restart: always
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- '5432:5432'
@feliperodriguess
feliperodriguess / useWallet.ts
Created October 6, 2021 16:43
useMetamaskWallet hook w/ TypeScript
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
import { ethers } from 'ethers';
declare global {
interface Window {
ethereum: {
on: (method: string, callback?: (arg: any) => void) => Promise<any>;
request: (args: EthereumRequestArguments) => Promise<any>;
removeListener: (method: string, callback?: (arg: any) => void) => Promise<any>;
selectedAddress: string;
@feliperodriguess
feliperodriguess / nvm-m1.txt
Created August 29, 2021 00:16
install nvm on MacBook M1 chips
# Install the most recent version of node or one that is at least v15
nvm install node
# Change to this new version
nvm use node
# Install Rosetta 2, if you haven't already
softwareupdate --install-rosetta
# Uninstall node v12 and v14, if you installed them before.
@feliperodriguess
feliperodriguess / helpers.js
Created August 27, 2021 00:00
Create Form Data / Create Form Data Documents - FE integration helpers
// Usage: dispatch(upload(createFormDataDocuments([...event.target.files])))
export const createFormData = (data, isCamelized = false) => {
const formData = new FormData()
Object.keys(data).forEach(field => {
const fieldValue = data[field]
const formDataValue = (() => {
if (!fieldValue) {
return ''
}
@feliperodriguess
feliperodriguess / google-map.jsx
Created July 28, 2021 18:57
Toggle StreetView helper
const toggleStreetView = useCallback(() => {
const panorama = mapRef.current.getStreetView()
panorama.setPosition({
lat: -16.7033165,
lng: -49.2747676,
})
panorama.setPov({
heading: 265,
pitch: 0,
})
@feliperodriguess
feliperodriguess / auth.js
Created June 12, 2021 07:18
⚡️ node.js auth middleware
//usage: routes.use(authMiddleware) in line above of the following authenticated routes
import jwt from 'jsonwebtoken'
import { promisify } from 'util'
import authConfig from '../config/auth'
export default async (req, res, next) => {
const authHeader = req.headers.authorization
import { useState, useEffect, useContext, createContext } from 'react'
import axios from 'axios'
const FetchContext = createContext()
const url = 'https://jsonplaceholder.typicode.com/posts'
const FetchProvider = ({ children }) => {
const [posts, setPosts] = useState([])
@feliperodriguess
feliperodriguess / hyper.js
Created July 12, 2020 19:16
💻 Hyper Terminal - Windows Config
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 16,
// font family with optional fallbacks
fontFamily: 'Fira Code, Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// default font weight: 'normal' or 'bold'
fontWeight: 500,
@feliperodriguess
feliperodriguess / index.html
Last active May 16, 2021 00:24
Next.js Meta Tags
<meta httpEquiv="x-ua-compatible" content="IE=edge,chrome=1" />
<meta name="MobileOptimized" content="320" />
<meta name="HandheldFriendly" content="True" />
<meta name="theme-color" content="#121214" />
<meta name="msapplication-TileColor" content="#121214" />
<meta name="referrer" content="no-referrer-when-downgrade" />
<meta name="google" content="notranslate" />
<meta property="og:title" content={pageTitle} />
<meta property="og:description" content={description} />