Skip to content

Instantly share code, notes, and snippets.

View etc-tiago's full-sized avatar

Tiago Souza etc-tiago

View GitHub Profile
@etc-tiago
etc-tiago / lambda-dynamodb-backup.js
Created April 1, 2020 23:55
Create dynamodb backup with lambda
const AWS = require("aws-sdk");
AWS.config.update({
region: process.env.AWS_REGION || 'sa-east-1'
});
const DynamoDB = new AWS.DynamoDB();
const getListTables = () => {
return new Promise((resolve, reject) => {
try {
DynamoDB.listTables((err, data) => {

Use React Relay

Document in pt-br to explanation the sequencies of commands for build graphql client with relay and CRA.

Instalação do relay

react-relay - O pacote que permite usar relay no projeto react.

relay-compiler - Pacote de desenvolvimento que permite compilar o código graphql estatico.

/*
# file: Auth.tsx
name query: <File>Query|Mutation
*/
/* Query */
const queryIsAvaliable = graphql`
query AuthQuery($slug: String!) {
isRegistered(slug: $slug)
// import
import { Dispatch } from 'redux';
import { connect } from 'react-redux';
// On Export
export default connect<IState, IAction>(
(state: any) => ({
// code
}),
@etc-tiago
etc-tiago / README.md
Created May 13, 2020 14:21 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@etc-tiago
etc-tiago / Files changed since last tag
Created May 13, 2020 14:22 — forked from arnold-almeida/Files changed since last tag
GIT: Files changed since last tag
#!/bin/bash
unset GIT_DIR
cd /path/to/project
# Get our info....
LATEST_TAG=$(git describe --tags --abbrev=0)
CURRENT_REVISION=$(git describe)
NUMBER_FILES_CHANGED=$(git diff --name-only HEAD $LATEST_TAG | wc -l)
#FILES_CHANGED=$(git diff --name-only HEAD $LATEST_TAG)
@etc-tiago
etc-tiago / reader.env.json.ts
Created June 9, 2020 19:42
Zero-dependency module that loads environment variables from a .env.json file into process.env.
import { readFileSync } from 'fs';
import path from 'path';
type Config = {
envPath: string;
encoding: BufferEncoding;
debug: boolean;
};
export default ({ envPath = path.resolve(process.cwd(), '.env.json'), encoding = 'utf8', debug = false }: Config) => {
var ID = function () {
// Math.random should be unique because of its seeding algorithm.
// Convert it to base 36 (numbers + letters), and grab the first 9 characters
// after the decimal.
const start = Math.random().toString(36).substr(2, 2);
const end = Math.random().toString(36).substr(2, 2);
return '_' + start + end;
};
@etc-tiago
etc-tiago / playwright.js
Created October 14, 2020 12:07
Playwright helper
const browserOpen = async (browser, url, headless = true) => {
const browserRef = await chromium.launch({ headless: false });
page = await browserRef.newPage();
await page.goto(url);
const element = async (selector) => await page.$(selector);
const click = async (selector) => await page.click(selector);
const inputFill = async (selector) => await page.click(selector);
const waitTimeout = async (milliseconds) => await page.waitForTimeout(milliseconds);
const countElement = async (selector) => await page.$$eval(selector, (el) => el.length);
@etc-tiago
etc-tiago / backup-restore-mongodb.sh
Created November 2, 2020 13:08
backup-restore mongo
docker exec mongo-docker sh -c 'mongodump -u root -p etc --archive --gzip' > ./mongo.db
docker exec -i mongo-docker-tests sh -c 'mongorestore -u root -p etc --gzip' < ./mongo.db