Skip to content

Instantly share code, notes, and snippets.

View MarounMaroun's full-sized avatar
🎹
♫♩♬

Maroun Maroun MarounMaroun

🎹
♫♩♬
View GitHub Profile
@MarounMaroun
MarounMaroun / copy_secrets.sh
Created September 21, 2022 08:36
Copy secrets from Azure vault to another
names=( $(az keyvault secret list --vault-name [oldvault] | jq '.[] | .name') )
for name in "${names[@]}"
do
name=`echo $name | tr -d '"'`
value=`az keyvault secret show --name $name --vault-name [oldvault] | jq '.value' | tr -d '"'`
echo "setting $name..."
az keyvault secret set --name "$name" --vault-name [newvault] --value "$value"
done
@MarounMaroun
MarounMaroun / scheme_exists.sh
Created October 25, 2020 11:14
Check if MySQL schema exists
table_exists() {
db_url="$1"
user="$3"
password="$4"
schema="$2"
if [[ ! -z $(mysql -Ns -h"$db_url" -u"$user" -p"$password" -e "select schema_name from information_schema.schemata where
schema_name='${schema}';") ]]; then
echo "schema exists"
return 0
fi
@MarounMaroun
MarounMaroun / update_k8s_secret.sh
Last active July 22, 2020 06:14
Updating K8s secret
#!/bin/bash
read -rp "What is the new access_key: " access_key
read -rp "What is the new secret_key: " secret_key
enc_access=$(echo "$access_key" | base64)
enc_secret=$(echo "$secret_key" | base64)
echo "encrypted access key: $enc_access"
echo "encrypted secret key: $enc_secret"
@MarounMaroun
MarounMaroun / clear_queues.sh
Created July 19, 2020 16:52
Clear RabbitMQ queues
docker ps -aqf "name=rmq" | xargs -I{} docker exec {} bash -c "rabbitmqctl stop_app ; rabbitmqctl reset ; rabbitmqctl start_app"
@MarounMaroun
MarounMaroun / consumers.py
Created September 4, 2019 07:28
Get RabbitMQ queues consumers
import requests
import json
uri = 'http://localhost:15677/api/queues'
res = json.loads(requests.get(uri, auth=('username', 'password')).content)
for i in res:
print('{:<40}: {} {}'.format(i.get('name'), i.get('state'), i.get('consumers')))
@MarounMaroun
MarounMaroun / install-2.23.0.sh
Created August 17, 2019 20:17
Git 2.23.0 installation
#!/bin/bash
curl -O https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.23.0.tar.gz
tar -xvf git-2.23.0.tar.gz
cd git-2.23.0/
./configure
make && make install
cp git /usr/local/bin/git
{
"contexts": {
"application-1": {
"beans": {
"spring.transaction-org.springframework.boot.autoconfigure.transaction.TransactionProperties": {
"prefix": "spring.transaction",
"properties": {}
},
"management.trace.http-org.springframework.boot.actuate.autoconfigure.trace.http.HttpTraceProperties": {
"prefix": "management.trace.http",
@MarounMaroun
MarounMaroun / CacheConfiguration.java
Created March 23, 2019 18:38
Spring 2.x Redis configurations
import java.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@MarounMaroun
MarounMaroun / commit-msg.sh
Last active June 26, 2018 09:11
Add branch name to commit message githook
mkdir -p ~/.git_hooks
# make it executable
chmod a+x ~/.git_hooks/commit-msg
# ---------------------------
# vi ~/.git_hooks/commit-msg:
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
echo "$NAME"': '$(cat "$1") > "$1"
@MarounMaroun
MarounMaroun / install_mongo.sh
Created January 16, 2018 06:35
MongoDB installation
read -p "What version you want to install? " version
brew install mongo@$version
brew install mongod
sudo mkdir -p /data/db
sudo chmod -R go+w /data/db
echo "Done! Run \"mongod\" to start the database"