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
@michaelphipps
michaelphipps / ably-jwt-authentication-send-json.php
Created March 6, 2021 08:24
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;
@lennardv2
lennardv2 / 1. Building PHP-MAMP on Apple Silicon M1.md
Last active February 29, 2024 07:57
Native PHP development / MAMP stack on Apple silicon M1

Building the MAMP stack (php, apache & mysql) on Apple Silicon ARM (native)

Update! This tutorial is outdated. Nowadays brew installes m1 binaries just fine. Also use valet: https://laravel.com/docs/9.x/valet. It's 10x easier.

In this tutorial, we'll build the the nescessary packages for ARM via homebrew. After that we'll configure apache2 for using virtual hosts. The native php is ofcourse way faster, see the results of this benchmark below.

TEST NAME SECONDS OP/SEC
@manashmandal
manashmandal / download.sh
Created May 3, 2020 20:52
Download Asset from Private Repo
curl -L -H 'Accept: application/octet-stream' -H "Authorization: token $TOKEN" 'https://api.github.com/repos/:owner/:repo/releases/assets/:asset_id' --output output.format
@mindfullsilence
mindfullsilence / README.md
Last active February 12, 2024 20:50
Root Bedrock Homestead site-type

This script will create a roots/bedrock project in your desired directory, install composer dependencies, and install wordpress via the wp-cli tool. Works with mailhog.

For global homestead installations (not per-project installs)

Place the sh file in Homestead/scripts/site-types/

In your Homestead.yaml file, use "bedrock" as the type key for a site mapping, and the value of the map key as the database. Be sure to add /web to the end of your to: key for your folder mapping. The script will generate the web folder for you. E.g.:

---
@campusboy87
campusboy87 / set_acf_pro_license.php
Last active December 12, 2019 19:10
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
@zorca
zorca / mysqlfix.php
Last active November 17, 2019 07:26
<?php
add_action( 'init', 'mysqlfix', -1 );
function mysqlfix() {
global $wpdb;
# Removed ONLY_FULL_GROUP_BY
$wpdb->set_sql_mode(['TRADITIONAL']);
}
@mihdan
mihdan / wp-image-placeholder.php
Last active December 12, 2022 23:59
Заменяет битые ссылки на кратинки в WordPress на заглушки. Удобно, например на тестовом сайте, чтобы не переносить фотки с боевого.
<?php
/**
* Plugin Name: Mihdan: Image Placeholder
*/
namespace Mihdan\Image_Placeholder;
$images = array(
// Обычные
'https://placeimg.com/640/480/animals',
@kagg-design
kagg-design / is_gutenberg_active.php
Last active January 27, 2019 21:18
Function to check if Gutenberg is active.
<?php
/**
* Check if Block Editor is active.
* Must only be used after plugins_loaded action is fired.
*
* @return bool
*/
function is_active() {
// Gutenberg plugin is installed and activated.
$gutenberg = ! ( false === has_filter( 'replace_editor', 'gutenberg_init' ) );
@shrimp2t
shrimp2t / ruleset.xml
Last active January 29, 2019 18:56
Copy it in to ~/.composer/vendor/squizlabs/php_codesniffer/src/Standards/WordPress/ruleset.xml
<?xml version="1.0"?>
<ruleset name="WordPress" namespace="WordPress">
<description>WordPress Coding Standards</description>
<autoload>./PHPCSAliases.php</autoload>
<!--<rule ref="WordPress-Core"/> -->
<rule ref="WordPress-Core">
<exclude name="Generic.Commenting.DocComment.MissingShort" />
@nicooprat
nicooprat / custom-callback.php
Created October 22, 2018 17:22
Create an ACF block with Sage 9 & Blade
function my_acf_block_render_callback( $block ) {
$slug = str_replace('acf/', '', $block['name']);
$block['slug'] = $slug;
$block['classes'] = implode(' ', [$block['slug'], $block['className'], $block['align']]);
echo \App\template("blocks/${slug}", ['block' => $block]);
}