Skip to content

Instantly share code, notes, and snippets.

View dtelaroli's full-sized avatar

Denilson Telaroli dtelaroli

View GitHub Profile
@dtelaroli
dtelaroli / clean-tf-state.js
Last active December 14, 2021 20:29
Script in node to cleanup terraform state file based on terraform file
# $1 parameter inverse (true|false)
# inverse true remove what is in tf file
# inverse false remove what is not in tf file
# command: node clean-tf-state.js [true|false]
const json = require("./state.json")
const fs = require('fs')
const inverse = process.argv[1]

Keybase proof

I hereby claim:

  • I am dtelaroli on github.
  • I am dtelaroli (https://keybase.io/dtelaroli) on keybase.
  • I have a public key ASB80HHC08K7bPObA78PeVBwIa6Jc4cWL6tFvu-7TdLO6Ao

To claim this, I am signing this object:

@dtelaroli
dtelaroli / script.sh
Last active November 12, 2020 01:54
mac osx enable and disable aac aptx codecs
#read
sudo defaults read bluetoothaudiod
# disable
sudo defaults write bluetoothaudiod "Enable AAC codec" -bool false
sudo defaults write bluetoothaudiod "Enable AptX code" -bool false
# restart
# enable
sudo defaults write bluetoothaudiod "Enable AAC codec" -bool true
@dtelaroli
dtelaroli / elastisearch.json
Created September 4, 2020 00:31
ElasticSearch error Fielddata is disabled on text fields by default. Set fielddata=true on [field] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.
PUT <index>/_mapping/doc
{
"properties": {
"field": {
"type": "text",
"fielddata": true
}
}
}
@dtelaroli
dtelaroli / policy.json
Created August 23, 2020 18:49
AWS ElasticSearch Service policy
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<accountId>:role/<authRoleArn>"
},
"Action": "es:*",
"Resource": "<ESDomainArn>/*"
@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 / 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 / pagseguro.en.yml
Last active April 30, 2019 14:46
Pagseguro I18n - API Ruby de pagamento transparente
en:
pagseguro:
errors:
'bad_request': 'Bad request'
'5003': 'bank network error'
'10000': 'invalid creditcard brand'
'10001': "creditcard number with invalid length"
'10002': "invalid date format"
'10003': "invalid security field"
'10004': "cvv is mandatory"
@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