Skip to content

Instantly share code, notes, and snippets.

View gustavoapolinario's full-sized avatar

GUSTAVO APOLINARIO gustavoapolinario

View GitHub Profile
@gustavoapolinario
gustavoapolinario / cancel-aws-batch-jobs.sh
Created September 16, 2020 12:29
Cancel All AWS Batchs Jobs to run
#! /bin/bash
for i in $(aws --profile [PROFILE] --region [REGION] batch list-jobs --job-queue [QUEUE] --job-status runnable --output text --max-items 10000 --query jobSummaryList[*].[jobId])
do
echo "Cancel Job: $i"
aws --profile [PROFILE] --region [REGION] batch cancel-job --job-id $i --reason "Cancelling job."
#echo "Job $i canceled"
done
Rest Elasticsearch samples
@gustavoapolinario
gustavoapolinario / redis-get-val.sh
Last active August 17, 2020 20:23
Redis commands sample
# ./$me.sh KEY_NAME
docker exec -it redis bash -c "echo 'HGETALL $1' | redis-cli"
#docker run --rm redis bash -c "echo 'HGETALL $1' | redis-cli"
@gustavoapolinario
gustavoapolinario / change-password.sh
Last active June 16, 2019 12:38
This script will create a new stpf user with non interactive mode.
#!/usr/bin/expect -f
set newUser [lindex $argv 0]
set newPassword [lindex $argv 1]
spawn passwd $newUser
expect "New password:"
send "$newPassword\r"
expect "Retype new password:"
send "$newPassword\r"
expect "passwd: all authentication tokens updated successfully."
send "exit\r"
#!/usr/bin/env bash
# Generate timestamped filename
TIMESTAMPED_TAG=`date +%Y-%m-%d-%H%M%S`
BACKUP_ARCHIVE="./jenkins-backup-${TIMESTAMPED_TAG}.tar.gz"
# Inconceivable race condition avoidance
if [-f $BACKUP_ARCHIVE ]; then
rm ${BACKUP_ARCHIVE}
fi
@gustavoapolinario
gustavoapolinario / nodejs-mongocli-script-tester.js
Last active December 27, 2018 00:08
Simple tester to your node.js connect with mongodb client
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://admin:adminadmin@$SERVER_IP:27017/exampleDb";
MongoClient.connect(url, { useNewUrlParser: true }, function(err, db) {
if (err) throw err;
var dbo = db.db("mydb");
var myobj = { name: "Company Inc", address: "Highway 37" };
dbo.collection("customers").insertOne(myobj, function(err, res) {
if (err) throw err;
console.log("1 document inserted");
@gustavoapolinario
gustavoapolinario / AWS-CodeBuild-sample.yaml
Last active December 26, 2018 23:49
sample Cloudformation CodeBuild docker
AWSTemplateFormatVersion: "2010-09-09"
Description: Example of Cloudformation to Build with CodeBuild an application. Get Code commit repo and build a docker container. Your repo needs the buildspec.yml file.
Parameters:
RepositoryName:
Description: CodeComit repository name
Type: String
Resources:
CodeBuildRole:
@gustavoapolinario
gustavoapolinario / clear-logs.sh
Created May 16, 2018 14:16
Script sh to clear logs by time
#!/bin/bash
#not tested... not working.
compacta() {
find $1 -name "*-201" -not -path "*.tar.gz" -exec tar -zcvf {}.tar.gz {} \;
}
remove_olders() {
find $1* -mtime +7 -exec rm {} \;
}
clear() {
@gustavoapolinario
gustavoapolinario / mysql-kill-long-queries.sql
Last active August 25, 2020 13:15
Procedure in mysql to kill long queries executions.
DELIMITER //
CREATE PROCEDURE killing_process (total_time int)
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE process_id INT;
DECLARE result varchar(4000);
DECLARE cur1 CURSOR FOR
SELECT id
FROM information_schema.processlist
@gustavoapolinario
gustavoapolinario / wildfly-cli
Last active September 30, 2022 01:34
wildfly-cli / jboss-cli
wildfly-cli / jboss-cli common commands
# Connect into wildfly/jboss cli (only with wildfly up)
$JBOSS_HOME/bin/jboss-cli.sh --connect
# Wildfly cli offline
$JBOSS_HOME/bin/jboss-cli.sh --commands="embed-server,$COMMAND,stop-embedded-server"
# Commands:
/system-property=VAR_NAME:add(value=VAR_VALUE)