Skip to content

Instantly share code, notes, and snippets.

View Eseperio's full-sized avatar

E.Alamo Eseperio

View GitHub Profile
@Eseperio
Eseperio / check-cloudflare
Created March 17, 2025 12:06
Check if cloudfront is requesting your server
#!/bin/bash
# This script downloads the AWS IP ranges JSON, extracts the CloudFront IP prefixes,
# and builds a tcpdump filter to capture traffic from those IP ranges.
# Check if jq is installed
if ! command -v jq &> /dev/null
then
echo "jq is required but not installed. Please install jq and run the script again."
exit 1
fi
@Eseperio
Eseperio / block-ai-bots-server-wide.md
Created December 13, 2024 07:12
Block AI Bots Server-wide in Plesk or ModSecurity-powered Servers

Block AI Bots Server-wide in Plesk or ModSecurity-powered Servers

Introduction

AI bots can be aggressive and cause severe server overload by consuming excessive resources. Their primary purpose is to train their machine learning models using your data, often without your consent. This activity can degrade your server's performance, cause downtime, and compromise your site's availability. This guide explains how to block these unwanted AI bots using ModSecurity on Plesk-managed servers.

Step 1: Enable ModSecurity in Plesk

  1. Log in to Plesk as an administrator.
  2. Go to Tools & Settings > Web Application Firewall (ModSecurity).
  3. Ensure that ModSecurity is enabled and select the Balanced or Fast mode, depending on your server's configuration and performance needs.
class UniqueSelector {
static getElementSelector(element) {
if (element.id) {
return `#${element.id}`;
}
if (element.tagName === 'BODY') {
return 'body';
}
let selector = element.tagName.toLowerCase();
if (element.className) {
@Eseperio
Eseperio / readme.md
Last active April 1, 2022 10:47
Multiple PHP versions at same time on MacOS in 2022 and using Apache

Multiple PHP versions at same time on MacOS and Apache

This is how i achieved to get all PHP versions working at the same time.

I have as many php versions as i want all running at same time. Versions are attached to directories, so in my www directory i have a folder for each php version www/php71/, www/php72/ and so on. If i want to change a project to another version, i only have to move it to a different folder. In MacOs, moving a huge folder is less than 1 second, so this is the fastest way to change version without updating server configuration.

Installing PHP

Install all the php versions via brew command. Example command (replace version number for each one)

@Eseperio
Eseperio / readme.md
Last active August 26, 2021 08:52
AWS Transcribe JSON to Script with php

Snippet to convert AWS transcribe into a scripted text

Be careful: This script has been created to be used under a command controller in Yii2. 

You can easily port to any php by adapting last three lines

@Eseperio
Eseperio / _auto-color.scss
Last active May 5, 2021 17:56
Css color based on letter.
$alphabet: "1","2","3","4","5","6","7","8","A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z";
$colors: #69d2e7, #a7dbd8, #e0e4cc, #f38630, #fa6900, #fe4365, #fc9d9a, #f9cdad, #c8c8a9, #83af9b, #ecd078, #d95b43, #c02942, #542437, #53777a, #556270, #4ecdc4, #c7f464, #ff6b6b, #c44d58, #774f38, #e08e79, #f1d4af, #ece5ce, #c5e0dc, #e8ddcb, #cdb380, #036564, #033649, #031634, #490a3d, #bd1550, #e97f02, #f8ca00, #8a9b0f, #594f4f, #547980, #45ada8, #9de0ad, #e5fcc2, #00a0b0, #6a4a3c, #cc333f, #eb6841, #edc951, #e94e77, #d68189, #c6a49a, #c6e5d9, #f4ead5, #3fb8af, #7fc7af, #dad8a7, #ff9e9d, #ff3d7f, #d9ceb2, #948c75, #d5ded9, #7a6a53, #99b2b7, #ffffff, #cbe86b, #f2e9e1, #1c140d, #cbe86b, #efffcd, #dce9be, #555152, #2e2633, #99173c, #343838, #005f6b, #008c9e, #00b4cc, #00dffc, #413e4a, #73626e, #b38184, #f0b49e, #
@Eseperio
Eseperio / Logger.js
Last active May 5, 2021 11:27
Simple prefixed javascript logger
export class Logger {
static prefix = "[YourAppNameHere] ";
static log(...args) {
console.log(Logger.prefix, ...args);
}
static warn(...args) {
console.warn(Logger.prefix, ...args);
}
@Eseperio
Eseperio / all-file-extensions.json
Created July 16, 2019 09:50
List of all file extensions with description (listed on wikipedia) in JSON format.
{
"0": {
"descriptions": [
"Compressed harddisk data"
]
},
"1": {
"descriptions": [
"Fax",
"Roff/nroff/troff/groff source for manual page"
@Eseperio
Eseperio / extract-file-extensions-from-wikipedia.js
Last active January 17, 2025 15:45
A snippet to extract all file extension names from wikipedia pages.
/**
* This snippet is used to extract all file extension names from wikipedia pages.
*
* Usage: Copy this snippet and paste on Chrome console. Do it for each extensions page available.
* After that, get the json using `localStorage.getItem('extensions')`
* @see https://en.wikipedia.org/wiki/List_of_filename_extensions
* @type {string}
*/
var memorySlot='extensions';
@Eseperio
Eseperio / sample_migration.php
Last active April 2, 2019 16:28
This is an example of a migration to move translated messages from Yii php files to lajax yii2-translate
<?php
use lajax\translatemanager\models\LanguageSource;
use lajax\translatemanager\models\LanguageTranslate;
use yii\db\Migration;
/**
* Class m190402_151021_move_translations_to_db
*/
class m190402_151021_move_translations_to_db extends Migration