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 / .httaccess
Created December 25, 2018 07:00
Apache .httaccess WebP rewrite
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
# WordPress content directory only rule.
# To rewrite all files remove `wp-content/` from regular expression below.
RewriteRule ^(wp-content/.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
AddType image/webp .webp
@radist2s
radist2s / generate-posts.sh
Created November 4, 2018 20:35
WP CLI Post generator helper
#/bin/bash
# Usage
# ./generate-posts.sh post_type [taxonomy_name count]
# post_type - Reqired
# taxonomy_name - Optional
# count - Optional
# Example:
# ./generate-posts.sh post # will create one post with thumnail and meta fields
# ./generate-posts.sh post category 4 # will create 4 posts and one existsing term appended for every post
@radist2s
radist2s / ffmpeg-install.sh
Created March 15, 2018 18:07
Brew ffmpeg install with all modules
brew install libvpx
brew install ffmpeg --with-chromaprint --with-fdk-aac --with-fontconfig --with-freetype --with-frei0r --with-game-music-emu --with-libass --with-libbluray --with-libbs2b --with-libcaca --with-libgsm --with-libmodplug --with-librsvg --with-libsoxr --with-libssh --with-libvidstab --with-libvorbis --with-libvpx --with-opencore-amr --with-openh264 --with-openjpeg --with-openssl --with-opus --with-rtmpdump --with-rubberband --with-sdl2 --with-snappy --with-speex --with-tesseract --with-theora --with-tools --with-two-lame --with-wavpack --with-webp --with-x265 --with-xz --with-zeromq --with-zimg
@radist2s
radist2s / cf7-hooks.php
Created March 15, 2018 16:09
WordPress Contact Form 7 custom chars validation hooks
<?php
<?
// Hooks only for version 5 only, may be for previous version also works
if (!defined('WPCF7_VERSION') OR intval(WPCF7_VERSION) !== 5)
{
return;
}
add_filter( 'wpcf7_validate_text', 'wpcf7_text_allowed_chars_validation_filter', 11, 2 );
add_filter( 'wpcf7_validate_text*', 'wpcf7_text_allowed_chars_validation_filter', 11, 2 );
@radist2s
radist2s / wp-github-updater.php
Last active March 13, 2018 22:32
GitHub Updater plugins header override
<?
define('GITHUB_UPDATER_OVERRIDE_DOT_ORG', TRUE);
function get_plugins_overrides()
{
static $map = NULL;
if ($map !== NULL)
{
return $map;
@radist2s
radist2s / rsync-ssh.sh
Last active December 11, 2017 14:31
Rsync ssh sync exmaple
#!/bin/sh
if [ -e ~/rsyncjob.lock ]
then
echo "Rsync job already running...exiting"
exit
fi
touch ~/rsyncjob.lock
@radist2s
radist2s / load-svg-symbols.js
Created November 23, 2017 09:14
Load SVG Symbols and replace href to keep ID only
window.loadSvgIcons = function loadSvgIcons(el) {
Array.prototype.forEach.call(el.querySelectorAll('svg use'), function (svgUseNode) {
const context = this || window
const hrefAttributes = ['xlink:href', 'href']
let hrefAttribute, href
hrefAttributes.some(function (attribute) {
href = svgUseNode.getAttribute(attribute)
@radist2s
radist2s / dash-offset-transition-detect.js
Created October 25, 2017 14:22
Stroke dash offset transition support detect
/**
* Detects browser's support for SVG stroke-dashoffset transition
*
* @return Promise
**/
window.strokeDashOffsetTransitionSupport = function strokeDashOffsetTransitionSupport() {
const caller = strokeDashOffsetTransitionSupport
if (caller.previousResult) {
@radist2s
radist2s / function.php
Created September 5, 2017 13:38
Hype banners loader
/**
* @param string $container_id
* @param string $target_script Relative path to loader file
* @param array $loader_config
*/
function product_block_loader($container_id, $target_script, Array $loader_config = [])
{
$product_block_callback_name = sanitize_file_name(str_replace('-', '_', "callback{$container_id}"));
$loader_url = theme_base_url('static/third-paty/product-block/hype-loader.php');
@radist2s
radist2s / app.js
Created July 12, 2017 13:45
Social Share boilerplate
define(['sharer'], function() {
Array.prototype.forEach.call(document.querySelectorAll('.socialShare'), function (shareLinksNode) {
socialShare(shareLinksNode)
})
})