Skip to content

Instantly share code, notes, and snippets.

@miradnan
miradnan / migrate-redis.py
Last active April 17, 2021 21:40 — forked from thomasst/migrate-redis.py
Migrate Redis data on Amazon ElastiCache
"""
Copies all keys from the source Redis host to the destination Redis host.
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are
restricted (e.g. on Amazon ElastiCache).
The script scans through the keyspace of the given database number and uses
a pipeline of DUMP and RESTORE commands to migrate the keys.
Requires Redis 2.8.0 or higher.
@miradnan
miradnan / load_dotenv.sh
Created February 24, 2021 16:21 — forked from mihow/load_dotenv.sh
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
@miradnan
miradnan / solr.service
Created October 12, 2020 08:26
Apache Solr Service file
[Unit]
Description=Apache SOLR
[Service]
Type=forking
User=solr
Environment=SOLR_INCLUDE=/etc/default/solr.in.sh
ExecStart=/opt/solr/bin/solr start
ExecStop=/opt/solr/bin/solr stop
Restart=on-failure
-- show running queries (postgresql > 9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
curl --user-agent "Googlebot/2.1 (+http://www.google.com/bot.html)" -v $@
@miradnan
miradnan / aws_update_infra.sh
Last active February 12, 2019 07:46
aws_update_infra.sh
#!/usr/bin/env bash
HOUR=$(date +"%H")
RDS_DESIRED_SIZE=db.t2.2xlarge
RDS_IDLE_SIZE=db.t2.large
EC2_DESIRED_SIZE=2
EC2_IDLE_SIZE=1
# AWS Config
AWS_AVAILIBILIY_ZONE=ap-south-1a
@miradnan
miradnan / Instructions.md
Created September 17, 2018 11:45 — forked from pgilad/Instructions.md
Git commit-msg hook to validate for jira issue or the word merge

Instructions

  • copy the file commit-msg to .git/hooks/commit-msg
  • make sure your delete the sample file .git/hooks/commit-msg.sample
  • Make commit msg executable. chmod +x .git/hooks/commit-msg
  • Edit commit-msg to better fit your development branch, commit regex and error message
  • Profit $$

Shell example

@miradnan
miradnan / rpm-digital-signature.sh
Created January 9, 2018 23:50 — forked from fernandoaleman/rpm-digital-signature.sh
How to sign your custom RPM package with GPG key
# How to sign your custom RPM package with GPG key
# Step: 1
# Generate gpg key pair (public key and private key)
#
# You will be prompted with a series of questions about encryption.
# Simply select the default values presented. You will also be asked
# to create a Real Name, Email Address and Comment (comment optional).
#
# If you get the following response: