Skip to content

Instantly share code, notes, and snippets.

View aamerio's full-sized avatar
⚙️
...

Alberto Amerio aamerio

⚙️
...
View GitHub Profile
tar cvzf - dir/ | split -b 200m - sda1.backup.tar.gz
# apache2.conf
ServerSignature Off
ServerTokens Prod
# ssl.conf
SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4
SSLProtocol -all +TLSv1.2
@aamerio
aamerio / check-certificate.sh
Last active August 9, 2022 07:23
Linux/Check expire certificate
openssl x509 -enddate -noout -in certificato.pem
@aamerio
aamerio / combine-string-digits.py
Created April 21, 2021 07:51
Python → Combination string + digits
import string
import itertools
combinations_generator = itertools.product(string.ascii_uppercase + string.digits, repeat=2)
combinations = list(map(''.join, combinations_generator))
print(len(combinations))
@aamerio
aamerio / aws-s3-sync.sh
Last active June 13, 2023 06:31
aws → S3 → simple weekly sync
DOW=$(date +%u)
(time aws s3 sync /var/www s3://BUCKET/$DOW/ \
--no-follow-symlinks \
--exclude 'DIR-ESCLUDED/*' \
) 2> LastBackup.txt
@aamerio
aamerio / ssh-setup.sh
Last active April 14, 2021 07:46
ssh setup
# remote
ssh-keygen -b 4096 -C "My RSA Key"
# local
ssh-copy-id -p [PORT] [user@][ip]
----
# more secure
ssh-keygen -t ed25519 -C "My Ed25519 key"
#local
ssh-copy-id -i .ssh/id_ed25519.pub 192.168.1.100
ssh 192.168.1.100 -i .ssh/id_ed25519
@aamerio
aamerio / logformat.conf
Last active July 3, 2025 09:36
Apache2 → log under CDN for original addr
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{X-Forwarded-For}i\"" combined+x-forwarded-for
@aamerio
aamerio / nobots.conf
Last active August 23, 2021 10:05
Apache2 → exclude Bots list
RewriteCond %{HTTP_USER_AGENT} (serpstatbot|mj12bot|brightedge|Ahrefsbot|Testomatobot|PetalBot|YandexBot|SemrushBot-BA|trendictionbot|EvilBot|ScumSucker|FakeAgent) [NC]
RewriteRule (.*) - [F,L]
@aamerio
aamerio / list2purge.py
Last active April 21, 2021 07:54
Python → css and js list to cache purge
import os
with open("listcache.txt", "w") as file1:
for currentpath, folders, files in os.walk('.'):
for file in files:
if file.split(".")[-1] in ['css']:
filename = os.path.join(currentpath, file).replace("./", "https://www.website.web/")
print(filename)
file1.write(f"{filename}\n")
if file.split(".")[-1] in ['js'] and file.startswith('main'):
@aamerio
aamerio / acw-start.sh
Last active November 29, 2022 11:13
AWS Cloudwatch onPremise * [CloudWatch agent on on-premises](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-on-premise.html) * [Download e configurazione dell'agente CloudWatch](https://docs.aws.amazon.com/it_
#!/bin/bash
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m onPremise -s -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json --region eu-south-1 --profile AmazonCloudWatchAgent
sudo systemctl restart amazon-cloudwatch-agent.service
#/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a start -m onPremise -s -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json