Skip to content

Instantly share code, notes, and snippets.

View agarzon's full-sized avatar
🕶️
Hunting bugs....

AG agarzon

🕶️
Hunting bugs....
  • Zend Certified Engineer
  • Canada, Montreal
View GitHub Profile
@agarzon
agarzon / clearCache.sh
Created March 30, 2023 13:19
gitlab-runner clear cache script
#!/bin/bash
#Variables
gitlabUrl="https://gitlab.yourdomain.com"
configFile="/etc/gitlab-runner/config.toml"
gitlabTolken="" # Get it from https://gitlabUrl/profile/account API read access token
# Get GitLab Runner tokens from config.toml
mapfile -t runner_tokens < <(sudo grep -oP 'token = "\K[^"]+' ${configFile})
@agarzon
agarzon / random_color.php
Last active September 11, 2023 17:04
PHP Random Color Generator Hex
<?php $color = dechex(rand(0x000000, 0xFFFFFF)); ?>
<body style="background-color: <?php echo $color; ?>;">
<h1><?php echo $color ?></h1>
</body>
@agarzon
agarzon / sdk-downloader.ps1
Created July 12, 2023 01:21
Download all the MSFS SDK msi installers automatically (flight simulator)
$version = Read-Host "Enter the version (default: 0.21.1):"
if ([string]::IsNullOrWhiteSpace($version)) {
$version = "0.21.1"
}
$baseUrl = "https://sdk.flightsimulator.com/files/installers/$version/"
$urls = @(
"MSFS_SDK_Documentation_Installer_$version.0.msi",
"MSFS_SDK_Core_Installer_$version.0.msi",
@agarzon
agarzon / queueCounter.sh
Last active March 28, 2023 01:15
alert based in mail queue size for postfix and plesk
#!/bin/sh
MAIL_BIN=`command -v mail`
QUEUE_SIZE=`/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}'`
QUEUE_SUMMARY=`/usr/sbin/qshape -s deferred | head`
MAILTO="xxx@gmail.com"
LIMIT=100
function send_notification_mail() {
echo $QUEUE_SUMMARY | $MAIL_BIN -s "WARNING: mail queue critical on $HOSTNAME" $MAILTO
@agarzon
agarzon / dnsbl.sh
Last active October 2, 2022 09:04
DNS Black List - Linux shell script (improved from: http://www.daemonforums.org/showthread.php?t=302)
#!/bin/sh
# Check if an IP address is listed on one of the following blacklists
# The format is chosen to make it easy to add or delete
# The shell will strip multiple whitespace
BLISTS="
b.barracudacentral.org
bb.barracudacentral.org
bl.deadbeef.com
bl.mailspike.net
@agarzon
agarzon / index.html
Last active April 5, 2022 23:44
My Html5 template with Jquery and Bootstrap from CDN
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Project Title</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
@agarzon
agarzon / DbHelper.php
Last active January 1, 2022 08:49
Codeception DB helper to extend database functionalities (update & delete)
<?php
namespace Codeception\Module;
/**
* Additional methods for DB module
*
* Save this file as DbHelper.php in _support folder
* Enable DbHelper in your suite.yml file
* Execute `codeception build` to integrate this class in your codeception
*/
@agarzon
agarzon / installSourceCodePro.sh
Last active December 28, 2021 14:58
Install Source Code Pro fonts on Linux
version=1.017R
echo "\n* Downloading version $version of source code pro font"
rm -f SourceCodePro_FontsOnly-$version.zip
rm -rf SourceCodePro_FontsOnly-$version
wget https://github.com/downloads/adobe/source-code-pro/SourceCodePro_FontsOnly-$version.zip
echo "\n* Unziping package"
unzip SourceCodePro_FontsOnly-$version.zip
mkdir -p ~/.fonts
@agarzon
agarzon / imgCompress.sh
Last active December 15, 2021 14:46
JPG recursive resize and compress (Linux)
#find . -type f -name '*.png' -exec optipng -o5 -quiet -preserve {} \;
#find . -type f -name '*.jp*' -exec mogrify -compress jpeg -quality 70 {} \;
find . -type f -iname "*.jp*g" | xargs mogrify -resize '1280x1280>'
find . -type f -iname "*.jp*g" | xargs jpegoptim --strip-all --max=90
# With parallel
find . -type f -iname "*.jp*g" -print0 | parallel --progress -0 -j +0 "mogrify -resize 1280x1280\> {}"
find . -type f -iname "*.jp*g" | parallel --progress "jpegoptim --strip-all --max=65 {}"
@agarzon
agarzon / install-php-tools.sh
Last active October 27, 2021 03:48
Install globally popular PHP dev tools like composer, phpunit, phpcs, phpmd, phpcpd, deployer, robo, codeception, etc.
#!/bin/bash
#To execute it directly: sudo bash <(curl -s https://gist.githubusercontent.com/agarzon/ecb0b92d4c8e1bbde126534c76721a58/raw/install-php-tools.sh)
BIN_PATH=/usr/local/bin/
#COMPOSER
sudo curl -LsS https://getcomposer.org/composer.phar -o ${BIN_PATH}composer
sudo chmod a+x ${BIN_PATH}composer