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 / install.sh
Last active September 12, 2021 10:58
Terminator installation
# Ubuntu
sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator
# Fedora
yum install terminator
@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 / strict_vs_lazy.scala
Created November 22, 2017 11:41
Strict VS Lazy evaluation in Scala
/**
* Assume we are interested in finding the first two even numbers in a very big file.
* Since we love functional programming, we don't want to use the traditional for loops.
* Instead, we want to apply a series of function to get the desired output.
*/
// for the sake of the example, I assume the input is found in a list, not a file
var l = List(1, 47, 38, 53, 51, 67, 39, 46, 93, 54, 45, 33, 87, 96, 100, 4, 84, 17, 31, 81, 88, 35, 36)
// we don't really need toList here, but since we're assuming the data is coming from a file, I'll use it anyway
@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;