Skip to content

Instantly share code, notes, and snippets.

@mrcomoraes
mrcomoraes / clear_cache_MS_Teams.sh
Last active February 16, 2024 22:55
Clear cache Microsoft Teams on Linux
#!/bin/bash
# This script cleans all cache for Microsoft Teams on Linux
# Tested on Ubuntu-like, Debian by @necrifede, Arch Linux by @lucas-dclrcq and Manjaro with flatpak by @danie1k. Feel free to test/use in other distributions.
# Tested Teams via snap package.
# Tested Teams via flatpak package.
#
# How to use in terminal:
# ./clear_cache_MS_Teams.sh ( deb-stable | deb-insider | snap | flatpak )
# or
@tfentonz
tfentonz / awssessiontoken
Last active November 28, 2023 09:17
Set environment variables to use MFA token with AWS CLI
#!/bin/bash
#
# https://aws.amazon.com/premiumsupport/knowledge-center/authenticate-mfa-cli/
#
# Usage: source ~/bin/awssessiontoken
# arn:aws:iam::12345689012:mfa/ExampleMFADevice
mfa_arn=$(aws iam list-mfa-devices --query 'MFADevices[].SerialNumber' --output text)
echo "MFA ARN: $mfa_arn"
echo -n "Enter MFA Code: "
@jthomerson
jthomerson / delete-all-cloudsearch-documents.sh
Created April 24, 2017 14:50
Delete all CloudSearch documents in a given domain
#!/bin/bash
# This script will delete *all* documents in a CloudSearch domain.
# USE WITH EXTREME CAUTION
# Note: depends on the AWS CLI SDK being installed, as well as jq
# For jq, see: https://stedolan.github.io/jq/ and https://jqplay.org/
if [[ ! $# -eq 2 || $1 != "--doc-domain" || ! $2 =~ ^https://.*$ ]]; then
echo "Must define --doc-domain argument (e.g. --doc-domain https://somedomain.aws.com)";
@joar
joar / jq-insert-var.sh
Last active May 3, 2024 13:41
Add a field to an object with JQ
# Add field
echo '{"hello": "world"}' | jq --arg foo bar '. + {foo: $foo}'
# {
# "hello": "world",
# "foo": "bar"
# }
# Override field value
echo '{"hello": "world"}' | jq --arg foo bar '. + {hello: $foo}'
{
@dgoguerra
dgoguerra / script-with-options.sh
Last active November 23, 2023 19:17
Manual alternative to getopt in bash scripts, supporting short and long options
#!/usr/bin/env bash
# File name
readonly PROGNAME=$(basename $0)
# File name, without the extension
readonly PROGBASENAME=${PROGNAME%.*}
# File directory
readonly PROGDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# Arguments
readonly ARGS="$@"