Skip to content

Instantly share code, notes, and snippets.

View eslam-mahmoud's full-sized avatar

Islam Mahmoud eslam-mahmoud

  • US
View GitHub Profile
@eslam-mahmoud
eslam-mahmoud / buildDockerContainer.sh
Last active January 24, 2019 23:54
sh script to stop current container and remove it and rebuild the image and run the container, can be used after pull new code
#from https://stackoverflow.com/questions/41322541/rebuild-docker-container-on-file-changes
#!/bin/bash
imageName=app
containerName=app-container
docker build -t $imageName -f Dockerfile .
echo Delete old container...
docker rm -f $containerName
@eslam-mahmoud
eslam-mahmoud / ssh.sh
Created January 10, 2019 05:12
comands to install docker on fresh aws ec2 instance
sudo apt-get update
sudo apt-get install git
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce
@eslam-mahmoud
eslam-mahmoud / post-style-per-lang.js
Last active December 17, 2018 19:38
Scan WordPress post paragraphs if most of characters are EN lang change direction and alignment to LTR and the other way if Arabic
//TODO use regex
let enAlphabet = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
let arAlphabet = 'ض ص ث ق ف غ ع ه خ ح ش س ي ب ل ا ت ن م ئ ء ؤ ر لا ى ة و ز ظ ط ك د ج'.split(' '); //TODO update the list
let resutls = document.querySelectorAll(".post p");
resutls.forEach(function(post){
let arScore = 0;
let enScore = 0;
let postText = post.textContent.trim();
if (postText.length < 1) {
return;
@eslam-mahmoud
eslam-mahmoud / .htaccess
Created November 20, 2018 01:49
Single page app .htaccess
RewriteEngine on
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
# If the requested resource doesn't exist, use index.html
Options +FollowSymLinks
@eslam-mahmoud
eslam-mahmoud / httpd-vhosts.conf
Last active November 20, 2018 01:50
Apache VirtualHost
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents/appname"
ServerName appname.local
ServerAlias www.appname.local
ErrorLog "/private/var/log/apache2/appname.local.error"
CustomLog "/private/var/log/apache2/appname.local.custom" common
<Directory /Library/WebServer/Documents/appname/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
#export branch to zip file
git archive --format zip --output /full/path/to/zipfile.zip master
#fix GIT issues
#Discarding all local commits on this branch
https://sethrobertson.github.io/GitFixUm/fixup.html#discard_all_unpushed
//add your EC2 .pem file to ssh kys
ssh-add ~/aws/mypemfile.pem
//create bare repo on AWS EC2 webserver and deploy on demand
mkdir ~/git/the_project
cd ~/git/the_project
git init --bare
//create local repo and track remote one
cd ~/git/the_project
#scp -i <keypair> myfile.txt [email protected]/home/ubuntu/myfile.txt
#install
sudo apt-get install nginx
#remove default
sudo nano /etc/nginx/sites-available/default
sudo rm /etc/nginx/sites-enabled/default
#create new file
sudo nano /etc/nginx/sites-available/{appName}
server {
listen 80;
tar -xvzf ./dump.tar.gz