Skip to content

Instantly share code, notes, and snippets.

View unnamedfeeling's full-sized avatar

Oleksandr Yarosh unnamedfeeling

View GitHub Profile
@unnamedfeeling
unnamedfeeling / Wrapper.php
Created May 13, 2020 14:58 — forked from krisanalfa/Wrapper.php
Tiny Guzzle Wrapper
<?php
namespace Alpha;
use GuzzleHttp\Client;
class Wrapper
{
protected static $client;
@unnamedfeeling
unnamedfeeling / wc_order_status_changes.php
Created September 6, 2019 14:51 — forked from abegit/wc_order_status_changes.php
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
@unnamedfeeling
unnamedfeeling / strtr.js
Created May 17, 2019 11:26 — forked from dsheiko/strtr.js
Java-script strtr — translate characters or replace substrings
/**
* strtr() for JavaScript
* Translate characters or replace substrings
*
* @author Dmitry Sheiko
* @version strtr.js, v 1.0.1
* @license MIT
* @copyright (c) Dmitry Sheiko http://dsheiko.com
**/
<?php
add_action( 'rest_api_init', function () {
register_rest_route( 'heartweb/v1', '/webinarData', [
'methods' => 'POST',
'callback' => 'heartweb_webinarData',
] );
} );
function heartweb_webinarData(WP_REST_Request $request){
$payload = $request->get_params();
@unnamedfeeling
unnamedfeeling / .htaccess
Created March 11, 2019 10:11
htaccess redirect 301
# Redirect 301 *from* *to*
# example:
Redirect 301 /aqua-news/только_с_15-по_20_июня_купи_билет_в_аквапарк_одесса_по_суперцене_и_зайди_с_ним_до_конца_лета.htm /content/aqua-news/только_с_15-по_20_июня_купи_билет_в_аквапарк_одесса_по_суперцене_и_зайди_с_ним_до_конца_лета.htm
<?php
$target_products = array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page'=>-1
);
$my_query = new WP_Query( $target_products );
@unnamedfeeling
unnamedfeeling / what-forces-layout.md
Created August 21, 2018 11:05 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@unnamedfeeling
unnamedfeeling / scripts.js
Last active September 27, 2018 14:00
Universal scripts and styles async js and css loaders
var scriptsLoaded=[],
scriptCb=function(params){
if (typeof params=='undefined') {
return console.log('No params provided for scriptCb');
}
var callback=params.el.cb,
cbparams=(typeof params.el.cbparams!=='undefined')?params.el.cbparams:null;
if (typeof params.script!=='undefined') {
if (params.script.readyState) { // IE, incl. IE9
params.script.onreadystatechange = function() {
@unnamedfeeling
unnamedfeeling / backup.sh
Created August 20, 2018 07:47 — forked from arunk-s/backup.sh
Shell Script for taking Incremental Backup and store it at a remote place
# backup.sh
# The contents of this file are released under the GNU General Public License. Feel free to reuse the contents of this work, as long as the resultant works give proper attribution and are made publicly available under the GNU General Public License.
# By Arun Sori <arunsori94@gmail.com>
#For taking backup of the desired directory and store it at a remote place
#timestamp
time_stamp=`date`
#backup file name