Skip to content

Instantly share code, notes, and snippets.

View franckweb's full-sized avatar

Franck Mercado franckweb

  • Globant
  • Cusco, Perú
View GitHub Profile
@franckweb
franckweb / backups.sh
Last active October 11, 2023 20:33 — forked from dinhkhanh/backup-restore-mysqldump-cli.sh
Backup Files & Databases
#
# BACKUP FILES
# sources:
# https://tonyteaches.tech/rsync-backup-tutorial/
# https://www.nexcess.net/help/using-rsync-for-backups/
#
# daily
tar -zcf /home/tony/backup/daily/backup-$(date +%Y%m%d).tar.gz /home/website/public_html
find /home/tony/backup/daily/* -mtime +7 -delete
@franckweb
franckweb / renew-lets-encrypt.sh
Created October 27, 2022 23:07
Renew Lets Encrypt with certbot
#
# renews lets encrypt on a running server
# note: not ideal as it stops/renews nginx for a few millisecs
#
sudo certbot certonly --standalone --pre-hook "service nginx stop" --post-hook "service nginx restart" -d mydomain.com -d www.mydomain.com
@franckweb
franckweb / javascript-promise.js
Last active December 21, 2022 21:29
Javascript Promise
const myMethod = function () {
const promise = new Promise(function (resolve, reject) {
const result = null;
const y = "geeksforgeeks";
if (result !== null) {
resolve(result);
} else {
reject("Error");
}
});
@franckweb
franckweb / Mailer.php
Created July 6, 2022 13:25
Form Submission with Validation and Email Delivery through SMTP
<?php
namespace App;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
class Mailer
{
private $client;
@franckweb
franckweb / audacity.sh
Created December 24, 2021 16:43
Install audacity and ffmpeg on ubuntu
#
# 2. install ffmpeg on Ubuntu 18.04
# https://linuxize.com/post/how-to-install-ffmpeg-on-ubuntu-18-04/
#
sudo apt update
sudo apt install ffmpeg
ffmpeg -version
#
# 1. install audacity on Ubuntu
@franckweb
franckweb / postman_automatic_token.js
Last active October 5, 2021 16:40
Postman script to automatically get token and assign it to environment variable
/*
* Postman script to automatically get token and assign it to environment variable
* - Create new endpoint (GET, POST, etc)
* - Create an env variable called "access_token"
* - Add this script in Tests tab in Postman for your newly created endpoint
* - To debug you can use Postman Console (Alt + Ctrl + C)
*/
const tokenUrl = 'https://mywebsite.com/auth/token';
const apiKey = "123FJSKAHFSAJFHSAFKJSAFHASSAFA";
@franckweb
franckweb / php-compatibility-checker.sh
Last active October 21, 2022 13:10
PHP compatibility check
# PHP COMPATIBILITY CHECK
# PHP CODE SNIFFER (with compatibility 7.4)
docker run --rm -v $(pwd):/app vfac/php7compatibility 7.4 [folder or file path] --extensions=php --ignore=vendor
# -------
# PHPSTAN (with .neon configs)
@franckweb
franckweb / filesloader.php
Last active April 14, 2021 16:54
Read files from local directory with PHP, performance comparison between glob, scandir, readdir and DirectoryIterator.
<?php
/*
* Prints out time the specified method takes to run.
* Just need to add a bunch of files in your specified directory
*
* From console: php index.php [name_of_method] (ex: php index.php runiterator)
* From web request: go to http://yourdomain.test/?test=[name_of_method] (ex: http://yourdomain.test/?test=runglob)
*
*/
@franckweb
franckweb / tmux.md
Last active March 8, 2024 17:57
Tmux shortcuts

install (ubuntu)

apt-get install tmux

add following to ~/.tmux.conf (create file)

set-option -g default-shell /bin/zsh
set -g mouse on
bind e set-window-option synchronize-panes

then run command

@franckweb
franckweb / bulk_dir_rename.sh
Created May 6, 2020 02:20
Bash script to bulk rename subdirectories to lowercase and change spaces for underscore
#!/bin/bash
# use: "bash bulk_dir_rename.sh path"
source_dir=$1
for found_dir in $source_dir/*;
do
original_dir_name=$(basename "${found_dir}")
lowercase_name=${original_dir_name,,}
no_space_dir=$(echo "$lowercase_name" | sed -e 's/ /_/g')