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 / 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 / centos_rootfs_resize.sh
Last active March 25, 2021 17:04
Expanding (resize) persistent & mounted Centos 7 disk size in Custom Google Compute Image.
sudo yum install -y cloud-utils-growpart
# You can use lsblk command to check the total available space of you disk.
# growpart is used to to expand a partition to the whole disk (expand sda1 to sda)
# xfs_growfs is used to resize and apply the changes
# df -h
# For more informations : https://blog.myduniahosting.com/how-to-resize-your-root-diskpartition-online-for-linux/
part=`df --output=source / |grep "/dev/"`
if [ ! -z "$part" ] ; then
len=${#part}
@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 / html-to-pdf-A4.js
Created April 27, 2017 00:18
Rendering HTML pages to PDF using PhantomJS (custom format, footer, margin ...)
var page = require('webpage').create();
var cookie = {
// your cookie here
};
page.paperSize = {
format: 'A4',
footer: {
height: "2cm",
@omartrigui
omartrigui / make-swap.sh
Last active August 9, 2023 02:33
Create 4G swap file in Linux
#!/bin/bash
dd if=/dev/zero of=/swapfile bs=1024 count=$((1024 * 1024 * 4))
chown root:root /swapfile
chmod 0600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
@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