Skip to content

Instantly share code, notes, and snippets.

View dtelaroli's full-sized avatar

Denilson Telaroli dtelaroli

View GitHub Profile
@dtelaroli
dtelaroli / joi-cpf-cnpj.js
Created July 13, 2020 17:24
Joi Validator validate cpf-cnpj field
const { cpf, cnpj } = require('cpf-cnpj-validator');
const Joi = require("@hapi/joi");
const JoiDoc = Joi.extend((joi) => ({
base: joi.string(),
type: "string",
messages: {
'document.invalid': '"{{#label}}" is invalid'
},
rules: {
@dtelaroli
dtelaroli / update.js
Last active April 9, 2020 18:55
Lambda to update all DynamoDB data to force reindex ElasticSearch AppSync Amplify
const { DynamoDB } = require("aws-sdk");
const ddb = new DynamoDB.DocumentClient();
/**
* @param event.TableName required - DynamoDB table name
* @param event.ExclusiveStartKey optional - Last Id if you want continue previeus execution
* Permissions to lambda:
* - dynamodb:Scan
* - dynamodb:BatchWriteItem
**/
@dtelaroli
dtelaroli / README.md
Last active November 16, 2022 13:31
AWS CodePipeline SAM Project CD with Bitbucket

Cloudformation Sam Pipeline Example

Template Parameters

env: environment name
region: aws region
codestarConnection: codestar connection arn https://docs.aws.amazon.com/cli/latest/reference/codestar-connections/create-connection.html
branch: bitbucket branch to continuous deployment
repo: bitbucket repo with pattern username/repository_name
@dtelaroli
dtelaroli / CustomResources.json
Created October 23, 2019 13:29
Amplify Cloudformation Example - AppSync HTTP Datasource
{
...
"Resources": {
"EmptyResource": {
"Type": "Custom::EmptyResource",
"Condition": "AlwaysFalse"
},
"MyDataSource": {
"Type": "AWS::AppSync::DataSource",
"Properties": {
@dtelaroli
dtelaroli / README.md
Last active October 13, 2023 08:24
How to activate Macbook TouchID in the Terminal
  1. Open the sudo file:
sudo vim /etc/pam.d/sudo
  1. Add the line above in the first line of the sudo file
auth sufficient pam_tid.so
@dtelaroli
dtelaroli / Dockerfile
Created April 5, 2019 13:05
Simple Glassfish on Docker
FROM openjdk:8-jdk
RUN curl -O https://download.oracle.com/glassfish/4.1.2/release/glassfish-4.1.2.zip -H 'Connection: keep-alive' --compressed \
&& unzip -o glassfish-4.1.2.zip \
&& rm glassfish-4.1.2.zip
COPY <java_webapp>.war|.jar|ear /glassfish4/glassfish/domains/domain1/autodeploy/
EXPOSE 8080
@dtelaroli
dtelaroli / wifi-reload.sh
Created April 3, 2019 18:44
Command line to disable and enable Wifi device on Ubuntu
# Disable Wifi on Ubuntu
nmcli radio wifi off
# Enable Wifi on Ubuntu
nmcli radio wifi on
@dtelaroli
dtelaroli / vsts-playbook.yml
Last active January 24, 2019 17:31
Deploy a new vsts self-hosted agent on Ubuntu 18.04
# Ansible tests
# $ ansible-playbook vsts-playbook.yml
---
- name: Install vsts agent
hosts:
- <your host>
vars:
ansible_python_interpreter: /usr/bin/python3
vsts_version: 2.144.0
@dtelaroli
dtelaroli / wait_for_http_200.sh
Last active January 11, 2019 14:00 — forked from rgl/wait_for_http_200.sh
Wait for an HTTP endpoint to return 200 OK with Bash and curl
#!/bin/bash
# Usage
# $ chmod +x ./wait_for_http_200.sh
# $ sh wait_for_http_200.sh http://<host>:<port>/<path>
echo "Trying to reach ${1}"
i=0
while [[ "$(curl -s -o /dev/null -w '%{http_code}' ${1})" != "200" ]]; do
sleep 5
@dtelaroli
dtelaroli / Test.java
Last active November 13, 2018 18:24
How to get SMS log from Cloudwatch by message id
class Test {
@Test
public void shouldGetLogs() {
AWSLogs client = AWSLogsAsyncClientBuilder.defaultClient();
//Your date of sent message: ex: 2018-01-01 00:00:00.000
LocalDateTime dateTime = LocalDateTime.of(2018, 1, 1, 0, 0, 0, 0 * 1000);
long time = dateTime.toEpochSecond(ZoneOffset.UTC) * 1000;