Skip to content

Instantly share code, notes, and snippets.

import React from 'react';
import { useForm } from "react-hook-form";
import { Dialog, DialogTitle, DialogContent, TextField, DialogContentText, Typography, DialogActions, Button, FormControl, FormLabel, FormGroup, makeStyles, Theme, createStyles, Box, CircularProgress, FormControlLabel, Checkbox } from '@material-ui/core';
import dynamic from 'next/dynamic';
const InputMak = dynamic(
() => import('../../util/InputMak'),
{ loading: () => <p>...</p>, ssr: false }
);
@alsantos123
alsantos123 / LAMAWS_SQS_LAMBDA_CONSUMER.ts
Created March 30, 2021 05:59
AWS SQS Lambda Consumer
import * as util from "util";
import { Context, Callback, SQSEvent } from "aws-lambda";
import SaldoNegocio, { ISQS_DATA } from "/opt/core/dist/SaldoNegocio";
import { TransactWriteItemList } from "aws-sdk/clients/dynamodb";
const DEBUG = true;
export const handler = async ( event: SQSEvent ): Promise<void> =>
@alsantos123
alsantos123 / React_Memo_Lodash_Throttle
Last active March 18, 2021 22:11
Reac + useMemo() + lodash.throttle()
///
/// Autocomplete Cliente
///
const memoBuscarClientes = React.useMemo( () =>
{
return _.throttle(
( sugestao:string, callback: (lst:string[])=>void ) =>
{
new Promise((resolv: (lst:string[])=>void, rejec) =>
{
@alsantos123
alsantos123 / ARM_Ubuntu_Server_Setup.sh
Created January 30, 2021 22:21
git, git-flow, awscli, jq, nginx, docker, portainer, nvm, code-server, cloudwatch agent e swap file
#!/bin/bash
chmod 644 /var/log/syslog
apt-get update && apt-get upgrade -y
# TOOLS
apt -y install git git-flow
apt -y install zip
apt -y install awscli
@alsantos123
alsantos123 / Cognito_Login_Logout.js
Last active January 30, 2021 23:51
Cognito Login e Logout (via Hosted-UI) com Javascript Vanilla
/**
* A classe é exportada (via webpack) e inciada em 'window.objUsuarioCognito'
*
* Exemplos:
* objUsuarioCognito.EhLogado(); // Retorna True no caso do usuário ter token armaznado, indicando que ele já executou o login.
*
* objUsuarioCognito.Login(); // Redireciona para o login (Amazon Hosted-UI - guarda o endereço local para o retorno do visitante).
*
* objUsuarioCognito.AtualizarToken()
* .then( tokens => console.log(tokens)) // True => token atualizado com sucesso
@alsantos123
alsantos123 / user-data.sh
Created January 30, 2021 13:11 — forked from abhilash1in/user-data.sh
Install nvm and NodeJS using AWS EC2 user data script
#!/bin/bash
apt-get -y update
cat > /tmp/subscript.sh << EOF
# START UBUNTU USERSPACE
echo "Setting up NodeJS Environment"
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.9/install.sh | bash
echo 'export NVM_DIR="/home/ubuntu/.nvm"' >> /home/ubuntu/.bashrc
echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> /home/ubuntu/.bashrc
# Dot source the files to ensure that variables are available within the current shell
. /home/ubuntu/.nvm/nvm.sh
@alsantos123
alsantos123 / Search my gists.md
Created January 30, 2021 13:02 — forked from santisbon/Search my gists.md
How to search gists

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@alsantos123
alsantos123 / Paypal_Typescript_Interfaces.ts
Created January 9, 2021 23:26
Interfaces do Paypal API Rest v2 (smart button js include)
export interface IConfig
{
API_KEY: string
API_SECRET: string
paypal_contexto: Paypal_AppContext
}
export interface Paypal_AppContext
{
@alsantos123
alsantos123 / CWLog.ts
Last active January 31, 2021 00:02
CloudWatchLog putEvent()
import * as util from "util";
import appConfig from "../app-config";
import * as AWS from 'aws-sdk';
import { InputLogEvent, Tags } from "aws-sdk/clients/cloudwatchlogs";
const DEBUG = false;
export enum CWLogTipo {
INFO = "INFO",
{
"agent": {
"run_as_user": "cwagent",
"metrics_collection_interval": 300
},
"metrics": {
"metrics_collected": {
"mem": {
"measurement": ["mem_used_percent"]
},