Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Allan Brazute EthraZa

🏠
Working from home
View GitHub Profile
@EthraZa
EthraZa / DO_upd_domain.sh
Last active Jul 20, 2021
Digital Ocean - Update DNS records with Droplets internal private IPs and hostname
View DO_upd_domain.sh
#!/bin/bash
#
# Digital Ocean - Update DNS records with Droplets internal private IPs and hostname
# DO_upd_domain.sh:
#
# 2021-07-20 - v1.1 - By EthraZa <Allan Brazute>
# Add: Update only powers and --flush switch to recreate the domain
#
# 2021-07-15 - v1.0 - By EthraZa <Allan Brazute>
#
@EthraZa
EthraZa / RefreshFormula.gs
Last active Mar 16, 2021
Google Sheets script: function refreshFormula(aToResfresh); For each cell in the array, force refresh the containing formula.
View RefreshFormula.gs
/**
* Google Sheets script: function refreshFormula(aToResfresh)
* For each cell in the array, force refresh the containing formula.
*
* @param {Array} aToResfresh The array of cells with formula to force refresh.
* @return {Void}
*/
function refreshFormula(aToResfresh = []) {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet(),
sheet = spreadsheet.getActiveSheet(),
@EthraZa
EthraZa / CountCellsByBgColor.gs
Last active Mar 15, 2021
Google Sheets: For each cell in a range, with a given background color, count or sum it.
View CountCellsByBgColor.gs
/**
* Google Sheets script: countCellsByBgColor(inputRange, colorReference, operation = 'count')
* For each cell in a range, with a given background color, count or sum it.
*
* @param {String} inputRange The range of cells to check for the background color.
* @param {String} colorReference The cell with the background color to count.
* @param {String} operation [count|sum] The operation to perform over selected range.
* @param {Int} eachRow The number of rows to jump to at each interaction loop.
* @param {Int} eachColumn The number of columns to jump to at each interaction loop.
* @return {Number} The number of cells with a matching background.
@EthraZa
EthraZa / post-receive.sh
Created Jul 26, 2020
One Git hooks script to rule them all
View post-receive.sh
#!/bin/sh
# Config
APPDIR="/tmp"
# Setup
HOOKS=$(basename "$0")
HOOKSDIR=$(dirname $(dirname "$0"))
HOOKSLOG="${HOOKSDIR}/${HOOKS}.log"
@EthraZa
EthraZa / sshd.sh
Created Jul 8, 2019
Termux simple init script - Goes in $PREFIX/etc/profile.d/
View sshd.sh
ENABLED=1
PROC="sshd"
CMD=$PROC
if [ $ENABLED = 1 ] ; then
if pgrep -f $PROC >/dev/null ; then
echo "[$PROC is running]"
else
echo "[Starting $PROC...]" && $CMD && echo "[OK]"
fi
@EthraZa
EthraZa / spiderstruct.php
Last active Jun 6, 2019
Spider Struct :: Mirror files from some remote place, based on a source directory structure, to a distination directory
View spiderstruct.php
<?php
/**
* Spider Struct - by Allan.Brazute
* Mirror files from some remote place, based on a source directory structure, to a distination directory
*
* Usage: spiderstruct.php /local_src_structure_path/ /output_path/ http://base_url/
*/
$localSrc = (isset($argv[1]) && $argv[1])? $argv[1] : '';
$localDst = (isset($argv[2]) && $argv[2])? $argv[2] : '';
@EthraZa
EthraZa / BorgBackup.sh
Last active Dec 13, 2019
A Borg Backup script for a centralized storage server to backup other servers
View BorgBackup.sh
#!/bin/bash
##
# BORG Backup
#
# [1.0] 2014-10-30 :: Allan Brazute
# - Assimilation
#
# All hosts need to have ssh and borg
# Backup Repository host may also need a compress tool like pigz
@EthraZa
EthraZa / backmark.sh
Created Oct 27, 2017
Backmark.sh Will create a pool of binary and text files with random content, duplicate then in two directories and backup it twice with multiple tools to compare their time and size.
View backmark.sh
#!/bin/bash
##
# Backmark.sh
#
# Will create a pool of binary and text files with random content,
# duplicate then in two directories and backup it twice
# with multiple tools to compare their time and size.
#
# Simple like that.
@EthraZa
EthraZa / lets-issue-cert.sh
Last active Oct 6, 2017
Issue a LetsEncrypt SSL certificate using acme.sh
View lets-issue-cert.sh
#!/bin/bash
# Issue a LetsEncrypt SSL certificate using acme.sh
#
# ISPConfig 3 preparation:
# Enable the SSL option and Add a self-signed certificate on SSL tab within Sites/Domains to create the needed configurations.
#
if [ -z "$*" ]; then
printf "\n issue-cert.sh domain.com \n\n"
@EthraZa
EthraZa / mysqldumpstream.sh
Created Aug 15, 2017
MySQL / MariaDB single shell command line to: 1- Dump DB from remote source server via SSH; 2- Compress dump with multithread bzip2; 3- Stream dump to local; 4- Uncompress dump; 5- Pipe through pv with a remote query to guess dump size to show progress bar; 6- Import dump to local DB
View mysqldumpstream.sh
ssh USER@REMOTE_SOURCE_SERVER 'mysqldump -uUSER -pPASSWORD --databases MYDATABASE | lbzip2' | lbunzip2 | pv -s `ssh USER@REMOTE_SOURCE_SERVER 'mysql -uUSER -pPASSWORD -e "SELECT ROUND(((SUM(DATA_LENGTH)*2)+SUM(INDEX_LENGTH))/3) B FROM information_schema.tables WHERE table_schema = \"MYDATABASE\";"| tail -n1'` |mysql -uUSER -pPASSWORD