Skip to content

Instantly share code, notes, and snippets.

View andremalveira's full-sized avatar
:electron:
Learning Each Day

André Malveira andremalveira

:electron:
Learning Each Day
View GitHub Profile
@andremalveira
andremalveira / node-express.js-request-validation-schema-with-yup.md
Last active December 1, 2023 14:25
Node Express.js Request Validation Scheme with Yup

Node Express.js Request Validation Scheme with Yup

Example Folder Structure

📁 project-name
 ├──📁 app
 │   ├──📁 Middleware    
 │   │   └── ReqValidate.ts
 │   └──📁 Validators    
 │       └── RegisterSchema.ts
@andremalveira
andremalveira / document.getElementByAttribute.md
Last active July 25, 2022 02:49
⭐ document.getElementByAttribute() - JavaScript Vanilla

Creating getElementByAttribute function.

📌 getElementByAttribute Return only one element

document.getElementByAttribute = HTMLElement.prototype.getElementByAttribute = function(attribute) {
  let e = this.querySelector(`[${attribute}]`) ?? this.querySelector(`[data-${attribute}]`)
  let value = e.getAttribute(`${attribute}`) ?? e.getAttribute(`data-${attribute}`)
  
  let rgx = /^[0-9.]+$/
@andremalveira
andremalveira / ✅ Next.js - Hoc Client Side to authentication of page.md
Last active July 9, 2023 16:23
Next.js - Hoc Client Side to authentication of page

✅ Next.js - Hoc Client Side to authentication of page

A simple client side Hoc for Next.js, in this example I use 'isAuthenticated' cookies as verification, if user authenticate it will be set to true if cookie does not exist it will be false and user is redirected to /login .

Um Hoc simples do lado do cliente para Next.js, neste exemplo eu uso cookies 'isAuthenticated' como verificação, se o usuário autenticar será definido como true se o cookie não existir será false e o usuário será redirecionado para /login.

app
├──📁 hocs    
│   └── pageWithAuth.tsx 
@andremalveira
andremalveira / Get user data from github authenticated with firebase auth using accessToken (JWT).md
Last active April 23, 2022 15:33
Get user data from github authenticated with firebase auth using accessToken (JWT)

Getting user data from github using (login with github) from Firebase Auth via accessToken (JWT) - Octokit

📂 loginWithGithub
├──📄 firebase.client.ts/js
├──📄 login.with.github.ts/js

📄 firebase.client.ts/js

// npm i firebase
@andremalveira
andremalveira / Problem fixed in css when javascript is disabled.md
Last active December 26, 2021 01:25
Problem fixed in css when javascript is disabled in Next.js!

✅ Problem fixed in css when javascript is disabled in Next.js!

Server side rendering Styled-Components with NextJS

  • Make sure you have these packages in package.json:
  {
  "dependencies": {
    "next": "latest",
    "react": "^16.8.0",
@andremalveira
andremalveira / cURL error 60 SSL certificate problem fix.md
Last active December 3, 2021 22:31
cURL error 60: SSL certificate problem fix - Firebase Realtime Database - PHP - wamp

Problem Fix

Error: Kreait\Firebase\Exception\Database\DatabaseError: cURL error 60: SSL certificate problem: unable to get local issuer certificate

English