Skip to content

Instantly share code, notes, and snippets.

View evertonpavan's full-sized avatar

Everton Pavan evertonpavan

View GitHub Profile
@faermanj
faermanj / aws-nuke.yml
Last active May 8, 2023 15:59
Limpando sua conta da AWS com aws-nuke
accounts:
"192912639870": {} # ccsandbox
account-blocklist:
- "192912699999"
resource-types:
excludes:
- IAMGroup
- IAMGroupPolicy
@twfahey1
twfahey1 / README.md
Last active June 7, 2024 12:11
Using Google API credentials.json file in Github Action or other scripts

The question: What is the best way we can use Google API via a service account in Github Actions? Answer: encrypt the credentials and decrypt during Action w/ a configured secret.

  • The credentials.json.gpg is originated from the credentials.json that can be downloaded from Cloud Console for the service account.
  • Encrypt it via: gpg --symmetric --cipher-algo AES256 credentials.json - Note the password used, as it will be added as a secret in this repo to be used for decoding the file and accessing Google APIs.
  • Update the credentials.json.gpg file in this repo using the contents of the newly created credentials.json.gpg, commit and push.
  • The password used should be added as a secret, e.g. the GOOGLE_API_PW secret in the github repo

Then, in the Github action or script, call gpg to decrypt and write the unencrypted file:

#!/bin/sh
@sethwololo
sethwololo / validateCPF.ts
Last active November 24, 2023 14:03
Validador de CPF com TypeScript.
const cpfPattern = /^(\d{11}|\d{3}\.\d{3}\.\d{3}-\d{2})$/
export function validateCPF(value: string): boolean {
if (!value.match(cpfPattern)) return false
// Remove caracteres especiais e espaços
const unformattedCpf = value.replace(/[^A-z\d][\\^\s]?/g, '')
// Separa os dígitos verificadores do parâmetro
const checkDigits = unformattedCpf
@OtayNacef
OtayNacef / isCached
Created February 21, 2021 19:34
Express middleware caching
import { Response, Request, NextFunction } from 'express';
import * as redis from 'redis';
const portRedis = process.env.PORT_REDIS || '6379';
const redisClient = redis.createClient(portRedis);
const isCached = (req: Request, res: Response, next: NextFunction) => {
const { idUser } = req.params;
@josephhanson
josephhanson / MockFile.js
Last active December 12, 2023 16:51
Mock file for JavaScript based file upload - with basic test harness
// mock file
function MockFile() { };
MockFile.prototype.create = function (name, size, mimeType) {
name = name || "mock.txt";
size = size || 1024;
mimeType = mimeType || 'plain/txt';
function range(count) {
var output = "";