Skip to content

Instantly share code, notes, and snippets.

View msalahat's full-sized avatar

Mutaz Salahat msalahat

View GitHub Profile
@msalahat
msalahat / wildcard-ssl-nginx-deployment.md
Last active December 26, 2019 17:35
Wildcard SSL Deployment for NGINX

SSL Deployment for NGINX

Combine .crt with .ca-bundle

cat [something].crt <(echo) [something].ca-bundle >> [something-bundle].crt

<(echo) is used to put new line between files content.

@msalahat
msalahat / gist:52dd0ba5061116e96b3e4d887634aa26
Created December 2, 2018 21:57
wordpress multisite nginx rewrite
location / {
root /var/www/example.com/wordpress;
index index.html index.htm index.php;
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
@msalahat
msalahat / export-countries.js
Last active March 30, 2017 12:56
Export data from countrycode.org
/**
* Copyrights for console.save http://bgrins.github.io/devtools-snippets/#console-save
**/
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
@msalahat
msalahat / distance.js
Created March 24, 2017 22:18
Calculate Distance Between 2 pixels in 2D sphere
const calculate_distance = (x1, y1, x2, y2) => {
let xd = x2 - x1;
let yd = y2 - y1;
let distance = Math.sqrt(xd * xd + yd * yd);
return distance;
}
@msalahat
msalahat / mongodb_s3_backup.sh
Created March 23, 2017 19:18
Backup MongoDB to Amazon S3
#!/bin/bash
MONGO_DATABASE="DB_NAME"
APP_NAME="APP_NAME"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
MONGO_USER="DB_USER"
MONGO_PASS="DB_PASS"
TIMESTAMP=`date +%F-%H%M`
@msalahat
msalahat / match_arabic_hmaz_letter.js
Last active March 22, 2017 23:18
Match user search with hamza in Arabic ( أ، ا ، آ ، إ ) against a list of words - UTF8
let match_arabic = (user_input, word) => {
let user_input_regx = "";
for (let d = 0; d < user_input.length; d++) {
//البحث عن أ، ا ، آ و إ
let hamz_letters = ["أ", "ا", "آ", "إ"].join("|")
const hamz_regx = new RegExp(hamz_letters);
if (hamz_regx.test(user_input.charAt(d))) {
user_input_regx += "[" + hamz_letters + "]";
} else {
user_input_regx += user_input.charAt(d);