Skip to content

Instantly share code, notes, and snippets.

@mkjsix
mkjsix / export.sh
Created March 8, 2022 08:45
A bash script to export all MongoDB collections from a single database to JSON files
#!/bin/bash
if [ ! $1 ]; then
echo " Example of use: $0 database_name [dir_to_store]"
exit 1
fi
db=$1
out_dir=$2
if [ ! $out_dir ]; then
out_dir="./"
@mkjsix
mkjsix / jar-version.sh
Last active October 16, 2019 11:46
Extract the POM version from JAR file
#!/bin/bash
VERSION=$(unzip -q -c "$1" META-INF/MANIFEST.MF | grep "Implementation-Version:" | awk '{print $2}' | sed 's/["\n\r]//g')
printf "%s" "$VERSION"
@mkjsix
mkjsix / set-retention.sh
Last active January 31, 2020 08:57
Set retention policies for AWS CloudWatch Log Groups, for a profile and a region
#!/bin/bash
# Example - to set the logs retention policy for your default AWS account in region eu-west-1 to 5 days, execute the command:
# set-retention.sh default eu-west-1 5
export AWS_PROFILE=$1
export AWS_REGION=$2
RETENTION_DAYS=${3:-30}
echo "AWS_PROFILE=$AWS_PROFILE, AWS_REGION=$AWS_REGION, RETENTION_DAYS=$RETENTION_DAYS"
while read -r i;
do (aws logs put-retention-policy --region "$AWS_REGION" --log-group-name "$i" --retention-in-days "$RETENTION_DAYS" );
done < <(aws logs describe-log-groups --region "$AWS_REGION" --query 'logGroups[*].[logGroupName]' | grep / | sed 's/"//g')
@mkjsix
mkjsix / read-retention.sh
Last active October 18, 2019 07:26
Read retention policies for AWS CloudWatch Log Groups, for a profile and a region
#!/bin/bash
# Example - to read the logs retention policy for your default AWS account in region eu-west-1, execute the command:
# read-retention.sh default eu-west-1
export AWS_PROFILE=$1
export AWS_REGION=$2
echo "AWS_PROFILE=$AWS_PROFILE, AWS_REGION=$AWS_REGION"
while read -r i;
do (printf "%s: " "$i" && aws logs describe-log-groups --region "$AWS_REGION" --log-group-name-prefix "$i" --query 'logGroups[0].retentionInDays');
done < <(aws logs describe-log-groups --region "$AWS_REGION" --query 'logGroups[*].[logGroupName]' | grep / | sed 's/"//g')
@mkjsix
mkjsix / describe-log-groups.sh
Last active October 18, 2019 07:30
Describe AWS CloudWatch Log Groups for a profile and a region
#!/bin/bash
export AWS_PROFILE=$1
export AWS_REGION=$2
echo "AWS_PROFILE=$AWS_PROFILE, AWS_REGION=$AWS_REGION"
aws logs --region "$AWS_REGION" describe-log-groups --query 'logGroups[*].[logGroupName]' | grep / | sed 's/"//g'
@mkjsix
mkjsix / delete-docker.sh
Last active June 1, 2017 10:17
Delete all Docker images and containers
# Delete every non-running Docker container
docker rm -f $(docker ps -a -q)
# Delete every Docker image for non-running containers
docker rmi -f $(docker images -q)
@mkjsix
mkjsix / maven-compiler-plugin
Created May 18, 2017 11:07
maven-compiler-plugin configuration to detect Java warnings and deprecations
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
@mkjsix
mkjsix / province.geojson
Created April 19, 2017 10:37 — forked from davidejmancino/province.geojson
Confini amministrativi delle province italiane
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mkjsix
mkjsix / regioni.geojson
Created April 19, 2017 10:37 — forked from davidejmancino/regioni.geojson
Confini amministrativi delle regioni italiane
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mkjsix
mkjsix / regioni-con-trento-bolzano.geojson
Created April 19, 2017 10:36 — forked from davidejmancino/regioni-con-trento-bolzano.geojson
Confini amministrativi delle regioni italiane, con le province di Trento e Bolzano mostrate separatamente
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.