Skip to content

Instantly share code, notes, and snippets.

View hluaces's full-sized avatar

Héctor Luaces hluaces

View GitHub Profile
@hluaces
hluaces / clang_lpc_settings.json
Created January 9, 2019 22:55
Clang-format file to use with the LPC language
{
"IndentWidth" : 4,
"AllowShortBlocksOnASingleLine": false,
"AllowShortFunctionsOnASingleLine": false,
"AllowShortIfStatementsOnASingleLine": false,
"AllowShortLoopsOnASingleLine": false,
"AlignAfterOpenBracket" : "AlwaysBreak",
"AlignConsecutiveAssignments": true,
"AlignConsecutiveDeclarations": true,
"AlignEscapedNewlines": "Left",
@hluaces
hluaces / telegram-as-alert-system-for-zabbix.md
Created January 11, 2019 11:32
Using telegram as an alert system for Zabbix

# Using telegram as an alert system for Zabbix

This is a very simple and quick external script to allow Zabbix to report alerts to telegram.

There are three main steps to follow in order to get this working:

  • Create and configure a Telegram bot.
  • Add an external script to Zabbix.
  • Configure a new type of media in Zabbix.
@hluaces
hluaces / wp_config.php
Last active January 14, 2019 08:32 — forked from butlerblog/wp_config.php
Configura la función wp_mail de WordPress para que use envíos por SMTP y no la función mail() local. Fork en español del gist de Chad Butler: https://gist.github.com/butlerblog/c5c5eae5ace5bdaefb5d | http://b.utler.co/Y3
<?php
/**
* Empieza por poner las siguientes constantes en tu archivo wp-config.php.
*
* Has de ponerlas antes de la línea que define la cosntante ABSPATH.
*
* Ten en cuenta que has de cambiar el valor de todas las constantes acorde a
* la configuración de correo electrónico que te facilite tu proveedor de correo.
*/
@hluaces
hluaces / functions.php
Last active February 12, 2019 11:13
Snippet para crear avatares aleatorios desde un array en WordPress. Creado para adjuntar a una respuesta de un blog. El código puede añadirse a un plugin personalizado o a un fichero "functions.php". Una vez creado aparecerá la nueva opción dentro de "Ajustes → Discusión".
<?php
/**
* Snippet para avatares de WordPress aleatorios en base a un array de
* imágenes.
*
* Se asume que éstas están en ./wp-content/uploads/avatares/.
*
* Este código puede añadirse a un "functions.php" o a cualquier plugin
* personalizado.
@hluaces
hluaces / phpcgi-watcher.sh
Last active February 20, 2019 15:21 — forked from josesayago/phpcgi-watcher.sh
PHP-CGI Watcher, a little BASH script to kill PHP-CGI orphan processes draining server resources.
#!/bin/bash
#
# @author Jose SAYAGO
# @uri http://josesayago.com/blog/
#
# Process to monitor how many PHP-CGI processes are running, and kill them
# if they exceed the limit
#
# Set the maximum number of CGI Processes allowed
MAX_CGI=25;
@hluaces
hluaces / zabbixv4_remove_acks.sql
Created June 11, 2019 11:35
Remove Acknowledges from Zabbix v4
-- Héctor Luaces Novo
-- SQL query to remove ACKs from Zabbix events.
-- It is name-based but it can be easily tweaked to filter in some other ways.
-- Please note that this might cause damage to your database. Be sure to have a backup.
-- Usage:
-- Copy this in an editor, change the NAME_PATTERN to switch your needs.
-- If everything ran successfully, commit the transaction. Otherwise, do a rollback
-- The pattern for your mail triggers
@hluaces
hluaces / queueCounter.sh
Last active June 21, 2019 11:18 — forked from agarzon/queueCounter.sh
Alert based in mail queue size for postfix and plesk forked from [agarzon's](https://gist.github.com/heartshare/7bdeebfab74ed436e72c163aadbb3004) and slightly tuned.
#!/bin/bash -e
# Binary locations
readonly MAIL_BIN=$(command -v mail)
readonly QUEUE_SIZE=$(/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}')
readonly QUEUE_SUMMARY=$(/usr/sbin/qshape -s deferred | head)
readonly CONTROL_FILE="/tmp/queueCounter"
# Comma-separated list of email addreses that should be notified when the
# queue grows above the defined threshold
---
- name: 'Example playbook to populate a dinamically created list list'
hosts: localhost
vars:
# The list of known VPNs
vpn_list:
- 'vpn-1'
- 'vpn-2'
- 'vpn-3'
@hluaces
hluaces / ejemplo.php
Last active September 23, 2019 07:19
Filtro que añade a las búsquedas de WordPress tanto entradas como páginas
function filtro_mostrar_entradas_y_posts($query) {
if ($query->is_search) {
$query->set('post_type', ['post', 'page']);
}
return $query;
}
add_filter('pre_get_posts','filtro_mostrar_entradas_y_posts');
@hluaces
hluaces / .htaccess
Created January 13, 2020 14:01
Example usage of mod_expires on an .htaccess file to change the browser cache
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css A31536000
ExpiresByType text/x-component A31536000
ExpiresByType application/x-javascript A31536000
ExpiresByType application/javascript A31536000
ExpiresByType text/javascript A31536000
ExpiresByType text/x-js A31536000
ExpiresByType text/html A3600
ExpiresByType text/richtext A3600