Skip to content

Instantly share code, notes, and snippets.

View radist2s's full-sized avatar

Alex Batalov radist2s

  • Georgia, Tbilisi
View GitHub Profile
@radist2s
radist2s / docker-machine-cheatsheet.md
Last active December 18, 2020 11:39
docker-machine cheatsheet

Retrieving mahine configuration

docker-machine config

Executing Docker command

docker \
-H=tcp://192.168.1.1:2376 \
--tlsverify \
@radist2s
radist2s / .env
Last active June 14, 2020 10:13
WP Attachment Multiple Origin support plugin. Helps to override Sage`s `UPLOADS_URL` filter with proper origin.
# For production no filters will be applied
WP_ENV=development
WP_HOME=http://example.com
WP_SITEURL=${WP_HOME}/wp
# Should be defined for staging and development, has no effect for production
UPLOADS_URL='http://example.com/app/uploads'
# Should be defined for development, maybe skipped for staging if Bedrock used
UPLOADS_URL_STAGING='//stage.example.com/app/uploads'
@radist2s
radist2s / .gitignore
Created April 15, 2020 19:18
IDEA PhpStorm .gitignore file
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
@radist2s
radist2s / Custom_WP_Image_Editor_GD.php
Created February 24, 2020 19:41
Wordpress custom GD editor with `fill_background` ability to fill PNG alpha with color fill
<?php
class Custom_WP_Image_Editor_GD extends WP_Image_Editor_GD {
/**
* @param array $rgb
*
* @return false|resource
*/
public function fill_background( $rgb ) {
$width = $this->size['width'];
$height = $this->size['height'];
@radist2s
radist2s / react-load-script.d.ts
Created November 6, 2019 15:39
react-load-script TypeScript definition
declare module 'react-load-script' {
import {Component} from 'react'
export interface ILoadScriptProps {
url: string
onCreate?: () => void
onError?: () => void
onLoad?: () => void
}
@radist2s
radist2s / analytics-event-catch.js
Last active September 27, 2019 03:58
Google Analytics event catcher
document.addEventListener('click', function (e) {
if (e.target.hasAttribute('data-ga')) {
catchGaEvent(e)
}
})
function catchGaEvent(e) {
var el = e.target
var event = el.getAttribute('data-ga'),
@radist2s
radist2s / remove_class_filter.php
Created August 6, 2019 17:04
Remove WordPress class to method filter from third party plugin `remove_class_filter`
<?php
// Found on https://wpforthewin.com/remove-hook-from-class-based-wp-plugin/
/**
* Make sure the function does not exist before defining it
*/
if (!function_exists('remove_class_filter')) {
/**
* Remove Class Filter Without Access to Class Object
*
@radist2s
radist2s / functions.php
Created May 23, 2019 08:54
Fix WooCommerce chosen Shipping Method during Address/ZIP code change on Form Totals update
<?php
add_filter('woocommerce_shipping_chosen_method', function ($default, $rates = [], $chosen_method = null) {
$rates = $rates ? (array)$rates : [];
if ($chosen_method and isset($rates[(string)$chosen_method])) {
return $chosen_method;
}
return $default;
}, 10, 3);
@radist2s
radist2s / php-to-blade-converter.php
Created May 20, 2019 03:20
PHP to Blade converter for WordPress templates (WooCommerce mostly)
<?php
$file_path = $argv[1] ?? null;
$file_path_abs = '';
if (!$file_path) {
throw new \Error('No file Path arg provided');
}
if (is_readable($file_path)) {
$file_path_abs = $file_path;
@radist2s
radist2s / bem-block-rename.php
Last active May 4, 2019 22:52
Tool for renaming BEM Blocks
<?php
/**
* Usage
* bem-block-rename.php ./templates/ .renaming-block-name .destination-block-name # will change every `.blade.php` in directory
* bem-block-rename.php .renaming-block--with-mod .dest-block--with-renamed-mode # will change every `.blade.php` in CWD directory
* bem-block-rename.php specified-file.php .renaming-block-name__child .destination-block-name__renamed-child # will change only `specified-file.php`
*/
namespace BemClassesTools;