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 / .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 / 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 / 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 / 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 / load.php
Last active January 22, 2019 16:28
console.chat
var domain = window.location.hostname;
console.log('Welcome to console.chat! You\'re chatting with other people who visited ' + domain + ' and opened their browser\'s console!');
console.log('To send a message it must be in this format: send(\'your message here\')\nExample: If you want to say "Hey, what\'s up?" send(\'Hey, what\'s up?\')');
console.log('Created by @DaltonEdwards :)');
var messageCount = 0;
function loadMessages() {
var request = new XMLHttpRequest();
request.open('GET', 'https://console.chat/api/read.php?domain=' + domain, true);
request.onload = function() {
if (request.status >= 200 && request.status < 400) {
@eslam-mahmoud
eslam-mahmoud / go-get-it.go
Last active February 18, 2019 16:23
create 50 worker pool what will do Async get request to URL and print result
package main
import (
"fmt"
"sync"
"strconv"
"net/http"
"io/ioutil"
)
var wg sync.WaitGroup
@eslam-mahmoud
eslam-mahmoud / gist:bddece7a407ea920e3600e48756bbd34
Last active January 30, 2021 17:04
create Certbot SSL on Docker Nginx on AWS - digitalocean
https://www.digitalocean.com/community/tutorials/how-to-acquire-a-let-s-encrypt-certificate-using-dns-validation-with-certbot-dns-digitalocean-on-ubuntu-20-04
https://www.humankode.com/ssl/how-to-set-up-free-ssl-certificates-from-lets-encrypt-using-docker-and-nginx
-> https://certbot-dns-digitalocean.readthedocs.io/en/stable/
certbot certonly --dns-digitalocean --dns-digitalocean-credentials ~/digitaloceanapikey.ini --preferred-challenges=dns -d=example.com -d=*.example.com
nano /etc/nginx/sites-available/x-app
ln -s /etc/nginx/sites-available/x-app /etc/nginx/sites-enabled/x-app
sudo service nginx configtest
sudo service nginx restart
@eslam-mahmoud
eslam-mahmoud / concurent_sequential.js
Last active June 26, 2019 15:25
Multiple Simultaneous Ajax Requests (concurrent sequential requests)
var ids = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
var stop = false;
function go(index, step) {
if (stop) {
console.log('Stoped', index, step);
return;
}
if (index > ids.length) {
console.log('Done');
@eslam-mahmoud
eslam-mahmoud / Makefile
Last active July 14, 2019 17:11
sample Makefile for tutorial
REPO_TAG=3.0.0
all: build
i18n-nodejs-$(REPO_TAG):
curl https://github.com/eslam-mahmoud/i18n-nodejs/archive/$(REPO_TAG).zip -L -o i18n-nodejs-$(REPO_TAG).zip
unzip i18n-nodejs-$(REPO_TAG).zip
build: i18n-nodejs-$(REPO_TAG)
cd i18n-nodejs-$(REPO_TAG); npm install
@eslam-mahmoud
eslam-mahmoud / Makefile
Created July 14, 2019 20:17
sample #2 Makefile for tutorial
NAME=executable
VERSION=1
GO_IMAGE=eslammahmoud/test:$(VERSION)
# Docker container that will be used to create the vendor folder and binary
GO_ENV=docker run -it --rm -v $(PWD):/app -w /app golang:1.8
all: push
# Create the executable file