Skip to content

Instantly share code, notes, and snippets.

View omartrigui's full-sized avatar
🚀
Auf Wiedersehen

Omar Trigui omartrigui

🚀
Auf Wiedersehen
View GitHub Profile
var aop = function(schema) {
schema.aop = [];
var executePre = function(functions, index, context, next) {
if (functions.length == index) {
next();
} else {
functions[index](context, function() {
executePre(functions, index + 1, context, next);

Keybase proof

I hereby claim:

  • I am OmarTrigui on github.
  • I am cipheredbytes (https://keybase.io/cipheredbytes) on keybase.
  • I have a public key whose fingerprint is 47A4 6711 5F27 1E20 0659 85F2 2EC1 3F4A 2C01 0303

To claim this, I am signing this object:

@omartrigui
omartrigui / netcat-proxy.sh
Last active January 4, 2017 21:30
Netcat TCP proxy - Outside the LAN
#!/bin/sh -e
if [ $# != 3 ]
then
echo "usage: $0 <src-port> <dest-host> <dest-port>"
exit 0
fi
TMP=`mktemp -d`
BACK=$TMP/pipe.back
@omartrigui
omartrigui / plesk-mailing-letsencrypt.sh
Last active April 21, 2017 16:02
Secure SMTP, POP and IMAP connections in Plesk with Let's Encrypt (Free SSL/TLS Certificates)
# Let's encrypt must be installed and port 443 must not be used for a short period
certbot auth --text --agree-tos --standalone --email user@domain.com -d domain.com -d mail.domain.com
cat /etc/letsencrypt/live/domain.com/privkey.pem > /etc/postfix/postfix_default.pem
cat /etc/letsencrypt/live/domain.com/fullchain.pem >> /etc/postfix/postfix_default.pem
/usr/local/psa/admin/sbin/mailmng --restart-service
# For the other Let's encrypt alternatives : https://wpguru.co.uk/2014/12/plesk-mail-ssl/
@omartrigui
omartrigui / node-mailer.js
Created April 21, 2017 22:40
Quick sample - Send e-mails with Node.JS
var nodemailer = require('nodemailer');
var smtpConfig = {
host: 'domain.com',
port: 587,
auth: {
user: 'user@domain.com',
pass: 'password'
}
};
@omartrigui
omartrigui / chroot-rescue-mode.sh
Created April 28, 2017 20:17
Mounting chrooted partitions - Linux rescue mode
#!/bin/bash
mount -t ext4 /dev/sdaX /mnt/
mount -t proc none /mnt/proc
mount -o bind /dev /mnt/dev
mount -o bind /sys/ /mnt/sys
chroot /mnt/ /bin/bash
echo 'nameserver 8.8.4.4' | sudo tee -a /etc/resolv.conf
@omartrigui
omartrigui / Nginx configuration
Last active June 16, 2017 10:17
My preferred Nginx configuraiton - #Hardened #Security ( A+ ssllabs )
upstream sample {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;
server_name my-domain.com;
location / {
return 301 https://$host$request_uri;
@omartrigui
omartrigui / ffmpeg-compile.sh
Last active September 27, 2017 14:30
Extended ffmpeg config
sudo apt-get install yasm libfdk-aac-dev libmp3lame-dev libvorbis-dev libvorbis-dev libx264-dev libxvidcore-dev libopus-dev libx265-dev
./configure --extra-libs=-ldl --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libxvid --enable-libopus --enable-libmp3lame
@omartrigui
omartrigui / ec2ize.sh
Created October 9, 2017 05:25
EC2ize a minimalist debian instance
[client]
ssh-keygen -t rsa -b 2048 -v
ssh-copy-id -i ~/sample.pub root@12.34.56.78
[server]
@omartrigui
omartrigui / renew-postfix.sh
Created October 10, 2017 03:40
Renew postfix certificate - Let's Encrypt cron
#!/bin/bash
service nginx stop;
certbot auth --text --agree-tos --standalone --email mail@domain.com -d domain.com -d mail.domain.com --non-interactive --fo
rce-renewal;
service nginx start;
cat /etc/letsencrypt/live/domain.com/privkey.pem > /etc/postfix/postfix_default.pem;
cat /etc/letsencrypt/live/domain.com/fullchain.pem >> /etc/postfix/postfix_default.pem;
/usr/local/psa/admin/sbin/mailmng --restart-service;