This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jwt = require('jsonwebtoken') | |
const dotenv = require('dotenv').config(); | |
const authConfig = process.env.AUTH | |
module.exports = (req, res, next) => { | |
const authHeader = req.headers.authorization | |
if (!authHeader){ | |
return res.status(401).send({error: 'No token provided'}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Util { | |
static #defaultFormart = Intl.NumberFormat("en-us", { | |
currency: "BRL", | |
style: "currency" | |
}); | |
static formatDate(date) { | |
let d = new Date(date), | |
month = '' + (d.getMonth() + 1), | |
day = '' + (d.getDate() + 1), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NextScript } from 'next/document'; | |
function dedupe(bundles) { | |
const files = new Set(); | |
const kept = []; | |
for (const bundle of bundles) { | |
if (files.has(bundle.file)) continue; | |
files.add(bundle.file); | |
kept.push(bundle); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from 'react'; | |
function usePersistedState(key, initialState) { | |
const [state, setState] = useState(() => { | |
if(typeof window === 'undefined') return initialState; | |
const storageValue = localStorage.getItem(key); | |
if (storageValue) { | |
return JSON.parse(storageValue); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const results = [ | |
{ | |
"adult": false, | |
"backdrop_path": "/pcDc2WJAYGJTTvRSEIpRZwM3Ola.jpg", | |
"genre_ids": [ | |
28, | |
12, | |
14, | |
878 | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
module.exports = { | |
mode: 'production', | |
entry: path.resolve(__dirname, 'src', 'main.js'), | |
output: { | |
path: path.resolve(__dirname, 'public', 'assets', 'js'), | |
filename: 'bundle.js' | |
}, | |
module: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#define endl "\n" | |
/* | |
esse macro serve para performance | |
apenas inserir um \n eh mais | |
performatico que chamar uma stream | |
pra quebrar a linha | |
*/ | |
int main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Pool } from "pg"; | |
import 'dotenv/config' | |
const db = new Pool({ | |
connectionString: process.env.DATABASE_URL, | |
ssl: process.env.NODE_ENV === "development" ? false : { | |
rejectUnauthorized: false | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Obj = {[key: string]: string|number} | |
const omit = curry(<T extends Obj>(names: Array<string>, obj: T): T => { | |
let result: T = {} as T; | |
let index: Obj = {}; | |
names.forEach(name=> { | |
index[name] = 1; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# backup | |
docker exec -t your-db-container pg_dumpall -c -U postgres > dump_`date +%d-%m-%Y"_"%H_%M_%S`.sql | |
# restore | |
cat your_dump.sql | docker exec -i your-db-container psql -U postgres |
OlderNewer