Skip to content

Instantly share code, notes, and snippets.

View albarki's full-sized avatar
😁

Ibrahim Mohamed albarki

😁
View GitHub Profile
@albarki
albarki / rds.sh
Created July 7, 2018 21:46
Get List of RDS instances from All regions
for region in `aws ec2 describe-regions --output text | cut -f3`
do
echo -e "\nListing RDS in region:'$region'..."
aws rds describe-db-instances \
--region $region \
--query 'DBInstances[*].[DBInstanceIdentifier,ReadReplicaDBInstanceIdentifiers]'
done
@albarki
albarki / diskmon.sh
Last active June 25, 2018 16:35 — forked from fduran/gist:1870429
Linux disk space email alert
#!/bin/bash
# www.fduran.com
# script that will send an email to EMAIL when disk use in partition PART is bigger than %MAX
# adapt these 3 parameters to your case
MAX=95
[email protected],[email protected]
PART=sda1
USE=`df -h |grep $PART | awk '{ print $5 }' | cut -d'%' -f1`
if [ $USE -gt $MAX ]; then
@albarki
albarki / postgres-cheatsheet.md
Created June 4, 2018 22:25 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@albarki
albarki / .htaccess
Created June 4, 2018 12:02 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@albarki
albarki / autopart.sh
Created June 3, 2018 18:56 — forked from trentmswanson/autopart.sh
Linux bash script to partition and format all data disks in azure
#!/bin/bash
# An set of disks to ignore from partitioning and formatting
BLACKLIST="/dev/sda|/dev/sdb"
# Base directory to hold the data* files
DATA_BASE="/media"
usage() {
echo "Usage: $(basename $0) <new disk>"
}
@albarki
albarki / sidekiq.service
Created June 1, 2018 19:14 — forked from mkhuda/sidekiq.service
Sidekiq service auto start for Ubuntu 16.04 using Systemd
#
# Sidekiq auto start using systemd unit file for Ubuntu 16.04
#
# Put this in /lib/systemd/system (Ubuntu).
# Run:
# 1. systemctl enable sidekiq (to enable sidekiq service)
# 2. systemctl {start,stop,restart} sidekiq (to start sidekiq service)
#
# This file corresponds to a single Sidekiq process. Add multiple copies
# to run multiple processes (sidekiq-1, sidekiq-2, etc).
@albarki
albarki / cpanel-alternatives.md
Created May 19, 2018 14:46
cPanel alternatives
@albarki
albarki / installation.sh
Created May 16, 2018 14:28 — forked from mikhailov/installation.sh
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@albarki
albarki / ec2.sh
Created May 11, 2018 22:20 — forked from junaidk/ec2.sh
Get List of EC2 instances from All regions
# install aws cli first
for region in `aws ec2 describe-regions --output text | cut -f3`
do
echo -e "\nListing Instances in region:'$region'..."
aws ec2 describe-instances --query "Reservations[*].Instances[*].{IP:PublicIpAddress,ID:InstanceId,Type:InstanceType,State:State.Name,Name:Tags[0].Value}" --output=table --region $region
done
#!/bin/sh
#
# Bacula interface to mtx autoloader
#
# Created OCT/31/03 by Alexander Kuehn, derived from Ludwig Jaffe's script
#
# *Heavily* hacked between 31/10/07 & 02/11/07 by Sean Cardus to make it work
# with the current Bacula version & our LTO tape drive. This works for me,
# it might work for you too - But, don't blame me if it blows up :)
#