Skip to content

Instantly share code, notes, and snippets.


Roman Glushko roma-glushko

View GitHub Profile
roma-glushko /
Last active May 26, 2021
Implementation of heap (priority queue) from my blog post:
from typing import List
class PriorityQueue:
Represents the heap and preserves the heap property during adding/removing elements
items: List[int]
def __init__(self, items: List[int]):
import shap
# Create object that can calculate shap values
explainer = shap.TreeExplainer(rf_classifier)
# Calculate Shap values
shap_values = explainer.shap_values(X_test, y_test)
roma-glushko /
Created Jun 23, 2020
A simple interface around git commands that simplifies patch creation
# display usage
# run commands one after the other using
[ $# -eq 0 ] && { echo -e "Usage: $0 command [path]"; exit 1; }
case $command in
roma-glushko / commands.js
Created Jun 22, 2020
Cypress - Magento2 loginAsCustomer() command
View commands.js
Cypress.Commands.add("loginAsCustomer", (username, password) => {
.then((body) => {
const $html = Cypress.$(body)
const formKey = $html.find('input[name="form_key"]').val()
method: 'POST',
url: '/customer/account/loginPost',
roma-glushko / apache-config.conf
Last active Jun 18, 2020
Disable HTTP auth for specific IP on the Apache server which is behind Varnish proxy
View apache-config.conf
<Directory /home/usr/sites/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
AuthType Basic
AuthName "HTTP Auth"
AuthUserFile /etc/apache2/.htpasswd
SetEnvIf X-Forwarded-For ^1\.2\.3\.4 env_no_http_auth
View magento2-graphql-client.php
require __DIR__ . "/app/bootstrap.php";
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\ObjectManager\ConfigLoader;
use GuzzleHttp\Client;
use Magento\Framework\Stdlib\ArrayManager;
$bootstrap = Bootstrap::create(BP, $_SERVER);
roma-glushko / Vendor\Module\Plugin\Checkout\AddProductLabelPlugin
Created Apr 8, 2019
Usage of Magento\Framework\Stdlib\ArrayManager in Magento 2 while working with nested arrays
View Vendor\Module\Plugin\Checkout\AddProductLabelPlugin
namespace Vendor\Module\Plugin\Checkout;
use Magento\Checkout\Model\DefaultConfigProvider;
use Magento\Framework\Stdlib\ArrayManager;
class AddProductLabelPlugin
roma-glushko /
Created Jun 19, 2018 — forked from amenk/
How To Apply a Magento 2 Patch to your project
  • Find the commit a GitHub
  • Add .patch to the URL
  • Require vaimo/composer-patches
  • Add an entry like the above, with path-removal-level 5, to the composer.json
roma-glushko / xdebug.bash
Created May 31, 2018
A bash script to toggle xdebug module
View xdebug.bash
#!/bin/env bash
# Simple script to enable or disable the xdebug extension
case $1 in
sudo sudo phpenmod xdebug
sudo service apache2 restart
echo "Xdebug is ON"
wget -O - | grep -E -o '<loc>.*</loc>' | sed -e 's/<loc>//g' -e 's/<\/loc>//g' > ~/sitemaps/mage2.txt
sudo siege -c100 -d5 -r1 -v -i -f ~/sitemaps/mage2.txt