Skip to content

Instantly share code, notes, and snippets.

View aabouzaid's full-sized avatar
🐧
I build sustainable solutions!

Ahmed AbouZaid aabouzaid

🐧
I build sustainable solutions!
View GitHub Profile
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 21 columns, instead of 13. in line 5.
location,date,p_scores_all_ages,p_scores_15_64,p_scores_65_74,p_scores_75_84,p_scores_85plus,deaths_2020_all_ages,average_deaths_2015_2019_all_ages,deaths_2015_all_ages,deaths_2016_all_ages,deaths_2017_all_ages,deaths_2018_all_ages,deaths_2019_all_ages,deaths_2010_all_ages,deaths_2011_all_ages,deaths_2012_all_ages,deaths_2013_all_ages,deaths_2014_all_ages,Week,deaths_2021_all_ages
Austria,2020-01-05,-10.83,-4.99,-23.21,-5.11,-11.17,1613.0,1809.0,1704.0,1634.0,2293.0,1767.0,1647.0,1557.0,1579.0,1574.0,1637.0,1549.0,1,1944.0
Austria,2020-01-12,-8.35,-1.45,-5.43,-5.3,-13.4,1702.0,1857.0,1768.0,1626.0,2340.0,1842.0,1709.0,1582.0,1671.0,1563.0,1659.0,1543.0,2,1941.0
Austria,2020-01-19,0.59,-7.32,-1.09,9.77,-2.91,1797.0,1786.4,1837.0,1608.0,2060.0,1786.0,1641.0,1573.0,1513.0,1586.0,1612.0,1578.0,3,
Austria,2020-01-26,1.83,14.2,-5.11,10.18,-5.01,1779.0,1747.0,1792.0,1578.0,1938.0,1714.0,1713.0,1573.0,1560.0,1595.0,1584.0,1463.0,4,
Austria,2020-02-02,7.06,-5.91,-0.22,19.98,5.79,1947.0,1818.6,1837.0,1609.0,2045.0,1870
@aabouzaid
aabouzaid / prepare-commit-msg-ticket-id
Created September 25, 2020 09:39
Add JIRA ticket ID to Git commit message
#!/bin/bash
COMMIT_MSG_FILE=$1
TICKET_ID_PATTERN="INFRA-[0-9]+"
TICKET_ID=$(git symbolic-ref --short HEAD | egrep -o "${TICKET_ID_PATTERN}")
TICKET_MSG_IN_COMMIT=$(grep -c "Related to: ${TICKET_ID}" ${COMMIT_MSG_FILE})
if [[ -n "${TICKET_ID}" && ${TICKET_MSG_IN_COMMIT} -lt 1 ]]; then
echo -e "\nRelated to: ${TICKET_ID}" >> ${COMMIT_MSG_FILE}
@aabouzaid
aabouzaid / CaesarCipher.py
Created September 30, 2015 13:41
My solution for "Caesar Cipher" challenge on HackerRank.com - https://www.hackerrank.com/challenges/caesar-cipher-1
#!/usr/bin/python
# Python 2.7.6
#
# My solution for "Caesar Cipher" challenge on HackerRank.com
# https://www.hackerrank.com/challenges/caesar-cipher-1
#
k = 2
k = k%26
n = 11
#!/bin/bash
#
# DESCRIPTION:
# Simple -very simple :D- Nagios script to check CPanel license.
#
# SYNTAX:
# ./check_cpanel_license.sh -H SERVER_IP (or $HOSTADDRESS$ in Nagios/Opsview)
#
# BY:
# Ahmed M. AbouZaid
#! /bin/bash
#
# You can find more info about this competition at following url:
# https://community.trueability.com/t/the-sub-par-assembler-round-1/911
#
#Main section.
spasm_dir_path="."
#spasm_dir_path="/var/lib/spasm"
print_error () {
@aabouzaid
aabouzaid / ssh_conf_to_ansible
Last active August 29, 2015 14:18
Simple snippet to reformat hosts in ssh conf file to Ansible inventory file format.
#! /bin/bash
#This snippet assume each "Host", "Hostname", "Port", "User" in separated line, and valid ssh config file.
ssh_conf_to_ansible () {
awk 'BEGIN{IGNORECASE=1}
{gsub(/\s+/," ");
gsub("Host ","");
gsub("Hostname ","ansible_ssh_host=");
gsub("Port ","ansible_ssh_port=");
gsub("User ","ansible_ssh_user=")};
#! /bin/bash
count_chains_rules () {
awk '$1 == "Chain" { chain_name = $2 }
chain_name != $2 && $0 != "" { chains[chain_name]++ }
END { ORS="";
for (var in chains) {
print var, chains[var]-1", ";
total += chains[var]-1
}
#! /bin/python
#Ansible module with Python to list groups in inventory (version 0.2 :D)
#You can print output like "pretty-print" outside Ansible by using:
#./listgroups | python -m json.too
import os
import re
import json
#Get hosts inventory from ansible.cfg file.
#! /bin/python
#30 minutes Ansible module to list groups in inventory (Python version) :D
#You can print output like "pretty-print" outside Ansible by using:
#./listgroups | python -m json.tool
import os
import re
import json
#get hosts inventory from ansible.cfg file.
#!/bin/bash
#10 minutes Ansible module to list groups in inventory (AWK version) :D
#You can see outupt of script like "JSON Pretty Print" outside Ansible by using:
#./listgroups | python -m json.tool
awk 'BEGIN {ORS=" ";};
/^\[/{gsub("[\[\]]",""); groups_number++; groups_array[groups_number]=$0};
END {
print "{\"Inventory Groups\": [";
for (group_in_array = 1; group_in_array <= groups_number-1; group_in_array++) printf "\"%s\", ",groups_array[group_in_array];