Skip to content

Instantly share code, notes, and snippets.

View eramax's full-sized avatar
🎯
Focusing

Ahmed Morsi eramax

🎯
Focusing
View GitHub Profile
@eramax
eramax / slugify.js
Created May 6, 2020 17:26 — forked from codeguy/slugify.js
Create slug from string in Javascript
function string_to_slug (str) {
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
var to = "aaaaeeeeiiiioooouuuunc------";
for (var i=0, l=from.length ; i<l ; i++) {
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}
@eramax
eramax / hardening.sh
Created April 26, 2020 23:19 — forked from e23z/hardening.sh
[Ubuntu 16.04 Server Hardener] A script to make it easy to harden an Ubuntu 16.04 server. Its purpose is to setup simple security measures out-of-the-box, not to apply advanced security measures. #scripts #security #configuration #utils
#!/bin/bash
cd ~
read -s -p 'Sudo password: ' PASSWORD
echo ""
echo "Configuring server..."
read -p "What's the hostname of this machine? " NEW_HOSTNAME
echo $PASSWORD | sudo -Sk hostnamectl set-hostname $NEW_HOSTNAME
sudo sed -i -e "s/^127.0.0.1.*$/127.0.0.1 localhost $NEW_HOSTNAME/g" /etc/hosts
sudo dpkg-reconfigure tzdata
sudo service cron restart
#!/bin/bash
#Server hardening script for cPanel servers
# Make sure only root can run this script
if [ "$(id -u)" != "0" ]; then
echo -e "\e[93m This script must be run as root \e[0m"
exit 1
fi
echo -e "\e[1;36;40m Server Hardening initiated \e[0m"
@eramax
eramax / secure-server.sh
Created April 19, 2020 05:56 — forked from etoews/secure-server.sh
Secure an Ubuntu server
#!/bin/bash
# This script assumes you've created this server with a key pair. If you haven't, you're not getting back in.
# Switch to everett user
adduser --shell /bin/bash --gecos "User for managing feeds" --disabled-password --home /home/everett everett
adduser everett sudo
grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers || echo "#includedir /etc/sudoers.d" >> /etc/sudoers
( umask 226 && echo "everett ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/50_everett_sh )
mkdir /home/everett/.ssh