Skip to content

Instantly share code, notes, and snippets.

View DimaMinka's full-sized avatar
💻
CDK Computers - Modern Web Development

Dima Minka DimaMinka

💻
CDK Computers - Modern Web Development
View GitHub Profile
@DimaMinka
DimaMinka / macos_high_sierra_apache_php_brew_2018.md
Created October 4, 2021 15:45 — forked from karlhillx/macos_high_sierra_apache_php_brew_2018.md
macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

macOS High Sierra Setup: Homebrew + Apache + PHP + MariaDB + SSL

Homebrew Installation

First let's install Homebrew.

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

@DimaMinka
DimaMinka / ably-jwt-authentication-send-json.php
Created August 19, 2021 07:22 — forked from michaelphipps/ably-jwt-authentication-send-json.php
Send a JSON message with Ably.com using JWT Authentication in PHP without using the official Ably PHP SDK.
<?php
// $ composer require lcobucci/jwt
require __DIR__ . '/vendor/autoload.php';
use Lcobucci\JWT\Configuration;
use Lcobucci\JWT\Signer\Key\InMemory;
use Lcobucci\JWT\Signer\Hmac\Sha256;
@DimaMinka
DimaMinka / set_acf_pro_license.php
Created November 18, 2019 07:57 — forked from campusboy87/set_acf_pro_license.php
Automatic activation of ACF license via PHP. The code adds the key to the option in the desired format, and adds the domain to the list of trusted domains tracked in the ACF profile, so that the update is successful. The code can be used as a MU plugin, a regular plugin, or inserted into the theme code.
<?php
add_action( 'acf/init', 'set_acf_pro_license' );
function set_acf_pro_license() {
global $acf_instances;
if ( isset( $acf_instances['ACF_Admin_Updates'] ) && ! get_option( 'acf_pro_license' ) ) {
/**
* @var ACF_Admin_Updates $acf
<?php
add_action( 'init', 'mysqlfix', -1 );
function mysqlfix() {
global $wpdb;
# Removed ONLY_FULL_GROUP_BY
$wpdb->set_sql_mode(['TRADITIONAL']);
}
@DimaMinka
DimaMinka / wp-image-placeholder.php
Created November 27, 2018 19:57 — forked from mihdan/wp-image-placeholder.php
Заменяет битые ссылки на кратинки в WordPress на заглушки. Удобно, например на тестовом сайте, чтобы не переносить фотки с боевого.
<?php
/**
* Plugin Name: Mihdan: Image Placeholder
*/
namespace Mihdan_Image_Placeholder;
$images = array(
// Обычные
'https://placeimg.com/640/480/animals',
@DimaMinka
DimaMinka / is_gutenberg_active.php
Created November 11, 2018 17:00 — forked from kagg-design/is_gutenberg_active.php
Function to check if Gutenberg is active.
/**
* Check if Gutenberg is active.
* Must be used not earlier than plugins_loaded action fired.
*
* @return bool
*/
private function is_gutenberg_active() {
$gutenberg = false;
$block_editor = false;
@DimaMinka
DimaMinka / .htaccess
Created August 27, 2018 10:22 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@DimaMinka
DimaMinka / get-word-count.php
Created May 11, 2018 06:46 — forked from dikiyforester/get-word-count.php
Return information about words used in a string prior PHP 5.3
<?php
/**
* Counts words in a text string.
*
* Uses code from wp_trim_words().
*
* @param string $text Given text.
*/
function my_get_word_count( $text = '' ) {
$translations = get_translations_for_domain( 'default' );
@DimaMinka
DimaMinka / adminer.sh
Created April 10, 2018 11:54 — forked from mhemmings/adminer.sh
Download Adminer like a boss! Found myself often wanting to quickly put Adminer on a box for a few minutes while I investigated something but couldn't remember the URL. This script downloads Adminer and also has some cool extra functionality, including automatic deletion (see --help for usage)
#!/bin/bash
usage() {
printf "%s\n" "Usage: $0 [-m] [-e] [-o] [-c] [-d]"
printf "\t%s\n\t%s\n\t%s\n\t%s\n" \
"-m MySQL only" "-e English only" "-o Output file" \
"-c CSS file to download" "-d Auto-delete time (minutes)"
exit 1
}