Skip to content

Instantly share code, notes, and snippets.

@fevangelou
fevangelou / my.cnf
Last active July 14, 2024 17:45
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated December 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@Slaver
Slaver / functions.php
Last active November 13, 2019 15:48
How to use WP Super Cache and AdRotate
<?php
/**
* Custom banner handler for cache
*/
add_action('init', 'adrotate_request_handler');
function adrotate_request_handler() {
if ( isset($_GET['adrotate_action']) && $_GET['adrotate_action'] == 'show' ) {
// You can use adrotate_group or adrotate_ad
// First param — ad group ID
@ajithrn
ajithrn / soil-nav walker.php
Last active April 20, 2017 02:31
WordPress: Soli Nav walker Modified
<?php
/*
* Modified soil nav walker to add the missing dropdown to the parent li of the ul.sub-menu
*/
namespace Roots\Soil\Nav;
use Roots\Soil\Utils;
/**
@georgiecel
georgiecel / wp-comment-walker
Last active December 28, 2022 15:16
Custom comment walker for HTML5 friendly WordPress comment and threaded replies. To be inserted in functions.php.
<?php
class comment_walker extends Walker_Comment {
var $tree_type = 'comment';
var $db_fields = array( 'parent' => 'comment_parent', 'id' => 'comment_ID' );
// constructor – wrapper for the comments list
function __construct() { ?>
<section class="comments-list">
@fomigo
fomigo / gist:2382775
Created April 14, 2012 07:59
Russian Plural Form in PHP
<?php
/*
echo plural_form(42, array('арбуз', 'арбуза', 'арбузов'));
*/
function plural_form($n, $forms) {
return $n%10==1&&$n%100!=11?$forms[0]:($n%10>=2&&$n%10<=4&&($n%100<10||$n%100>=20)?$forms[1]:$forms[2]);
}