Skip to content

Instantly share code, notes, and snippets.

View ahmed-abdelazim's full-sized avatar

Ahmed Abdeazim ahmed-abdelazim

View GitHub Profile
@ahmed-abdelazim
ahmed-abdelazim / zimbra-ssl.sh
Last active June 18, 2022 13:03
zimbra update ssl cert
export YourSSLDomain=mail.yourdomain.com
# Renew or generate cert
certbot renew
# Copy cert
cp /etc/letsencrypt/live/$YourSSLDomain/* /opt/zimbra/ssl/letsencrypt
chown zimbra:zimbra /opt/zimbra/ssl/letsencrypt/*
# if first time copy the key to the right place
cp /etc/letsencrypt/live/$YourSSLDomain/privkey.pem /opt/zimbra/ssl/zimbra/commercial/commercial.key
# fix permissions
@ahmed-abdelazim
ahmed-abdelazim / .linode
Created April 10, 2022 09:07
certbot/dns-linode Docker issue certificate and renew
# Linode token
dns_linode_key = YOUR_ACCESS_TOKEN
@ahmed-abdelazim
ahmed-abdelazim / cloudfront.sh
Last active October 31, 2023 14:13
Bash script to update coudfront origin using aws cli
#!/bin/bash
CLOUDFRONT_DISTRIBUTION_ID=E2C3RNL2F4MRMQ
NEW_ORIGIN="origin2-zaid.s3.us-west-2.amazonaws.com"
ETAG=`aws cloudfront get-distribution --id $CLOUDFRONT_DISTRIBUTION_ID | jq -r .ETag`
aws cloudfront get-distribution --id $CLOUDFRONT_DISTRIBUTION_ID | \
jq --arg NEW_ORIGIN "$NEW_ORIGIN" '.Distribution.DistributionConfig.Origins.Items[0].Id=$NEW_ORIGIN' | \
jq --arg NEW_ORIGIN "$NEW_ORIGIN" '.Distribution.DistributionConfig.Origins.Items[0].DomainName=$NEW_ORIGIN' | \
jq --arg NEW_ORIGIN "$NEW_ORIGIN" '.Distribution.DistributionConfig.DefaultCacheBehavior.TargetOriginId=$NEW_ORIGIN' | \
jq .Distribution.DistributionConfig > config.json
aws cloudfront update-distribution --id $CLOUDFRONT_DISTRIBUTION_ID --distribution-config "file://config.json" --if-match $ETAG > /dev/null
@ahmed-abdelazim
ahmed-abdelazim / .htaccess
Created June 3, 2021 12:31
NodeJs htaccess for apache ONLY resources folder
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:3020/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ http://127.0.0.1:3020/$1 [P,L]
RewriteRule ^/?resources/(.*)$ http://127.0.0.1:3020/resources/$1 [L,P]
@ahmed-abdelazim
ahmed-abdelazim / allow.sql
Last active May 29, 2021 17:00
mysql allow root password login
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'the-password';
SELECT user,authentication_string,plugin,host FROM mysql.user;
FLUSH PRIVILEGES;
@ahmed-abdelazim
ahmed-abdelazim / index.html
Created January 25, 2021 11:51
pdf writer
<!doctype html>
<html ng-app="app">
<head>
</head>
<body>
<div ng-controller="LayoutViewController as $ctrl" class="container">
<div class="row">
@ahmed-abdelazim
ahmed-abdelazim / multiprocessing-pool.py
Last active July 3, 2020 15:38
multiprocessing python example
import multiprocessing.pool
import time
def theout(i):
print(i)
time.sleep(1)
pool = multiprocessing.pool.Pool(processes=10)
pool.map(theout, range(100))
@ahmed-abdelazim
ahmed-abdelazim / iptables-fix.sh
Created June 3, 2020 14:45
iptables fix after flush
#!/bin/sh
IPT="/sbin/iptables"
# Set default policies for all three default chains
$IPT -P INPUT ACCEPT
$IPT -P FORWARD ACCEPT
$IPT -P OUTPUT ACCEPT
# Flush old rules, old custom tables
@ahmed-abdelazim
ahmed-abdelazim / escape.py
Last active March 10, 2020 12:15
convert XML files to format can be posted via postman
import os
if not os.path.exists('escaped'):
os.makedirs('escaped')
def escape(file):
with open(file, 'r') as f:
a_string = ''.join(f)
escaped = a_string.replace('"', '\\"')
escaped = escaped.replace('><', '>\\r\\n<')
@ahmed-abdelazim
ahmed-abdelazim / export.py
Last active January 14, 2022 13:13
Export / import AWS dynamodb table from json file with correct data types using python
from __future__ import print_function # Python 2/3 compatibility
import json
import boto3
# AWS_ACCESS = ""
# AWS_SECRET = ""
AWS_REGION = "eu-west-3"
TABLE_NAME = "users"
client = boto3.client(