Skip to content

Instantly share code, notes, and snippets.

View tiendungdev's full-sized avatar

Tien Dung Dao tiendungdev

View GitHub Profile
@bouroo
bouroo / cloudflare-add-dns.sh
Last active August 15, 2024 03:42
Cloudflare bash add Sites/DNS record
#!/usr/bin/env bash
# Require curl & jq
hash curl 2>/dev/null || { echo >&2 "I require 'curl' but it's not installed. Aborting."; exit 1; }
hash jq 2>/dev/null || { echo >&2 "I require 'jq' but it's not installed. Aborting."; exit 1; }
# Get domain list
read -e -i 'domains.csv' -p 'Domain list file: ' DOMAIN_FILE
read -e -i 'y' -p 'CF Proxy [Y/n]: ' CF_PROXY
if [[ ${CF_PROXY} =~ ^([yY][eE][sS]|[yY])+$ ]]
@holmberd
holmberd / php-pools.md
Last active April 19, 2025 05:22
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@bjornjohansen
bjornjohansen / maintenance.php
Created August 31, 2017 11:57
Custom WordPress maintenance mode page
<?php
wp_load_translations_early();
$protocol = wp_get_server_protocol();
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Retry-After: 30' );
?>
<!DOCTYPE html>
<html>
@bouroo
bouroo / swap.sh
Last active August 21, 2024 11:55
Create swap on VPS
#!/usr/bin/env bash
#==============================================================================
# title: swap.sh
# description: This script automatically creates a swap size that's 20% of total RAM
# and comments out the old swap device in /etc/fstab.
# author: Kawin Viriyaprasopsook <[email protected]>
# usage: bash swap.sh
# notes: need `sudo dd sed` packages
#==============================================================================
@keesiemeijer
keesiemeijer / wp-update
Last active April 7, 2025 20:14
A bash script to update everything WordPress (core, plugins, themes and comments).
#!/usr/bin/env bash
# =============================================================================
#
# *** WARNING: THIS SCRIPT IS NO LONGER MAINTAINED ***
#
# use https://github.com/keesiemeijer/wp-update instead
#
# =============================================================================
/**
* My Account
*/
.woocommerce-account .woocommerce-MyAccount-navigation {
width: 20%;
}
.woocommerce-account .woocommerce-MyAccount-content {
display: inline-block;
@wpexplorer
wpexplorer / gist:a3f58b5f32026e7fb106
Created February 24, 2016 20:22
Total theme custom archive.php template file example
<?php
/* Example custom archive template file */
// Get header
get_header(); ?>
<div id="content-wrap" class="container clr">
<?php wpex_hook_primary_before(); ?>
@fevangelou
fevangelou / my.cnf
Last active April 18, 2025 11:00
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 September 2024 ~
#
#
# 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.
#
@shizhua
shizhua / like-it-enqueue.php
Last active January 10, 2025 10:14
Add a like button without a plugin in WordPress
add_action( 'wp_enqueue_scripts', 'pt_like_it_scripts' );
function pt_like_it_scripts() {
if( is_single() ) {
wp_enqueue_style( 'like-it', trailingslashit( plugin_dir_url( __FILE__ ) ).'css/like-it.css' );
if (!wp_script_is( 'jquery', 'enqueued' )) {
wp_enqueue_script( 'jquery' );// Comment this line if you theme has already loaded jQuery
}
wp_enqueue_script( 'like-it', trailingslashit( plugin_dir_url( __FILE__ ) ).'js/like-it.js', array('jquery'), '1.0', true );
@thachpham92
thachpham92 / gist:d57b18cf02e3550acdb5
Last active February 9, 2025 05:02
Tất cả các tham số trong WP_Query
// Source: https://gist.github.com/luetkemj/2023628
// Xem hướng dẫn WP_Query toàn tập: http://goo.gl/kRpzTz
<?php
$args = array(
//////Author Parameters - Tham số lấy bài viết theo tác giả
//http://codex.wordpress.org/Class_Reference/WP_Query#Author_Parameters
'author' => '1,2,3,', //(int) - Các ID tác giả cần lấy bài viết (thêm dấu - vào để loại trừ tác giả, ví dụ: -14, -20)
'author_name' => 'luetkemj', //(string) - Lấy bài viết dựa theo tên nick name của tác giả
'author__in' => array( 2, 6 ), //(array) - Lấy bài dựa theo ID của tác giả