Skip to content

Instantly share code, notes, and snippets.

View tshabatyn's full-sized avatar

Taras Shabatyn tshabatyn

View GitHub Profile
@tshabatyn
tshabatyn / CODE_AND_DB_DUMP.MD
Last active October 5, 2022 05:33
Making Code and DB dump

Code dump

tar cf - ./ --exclude=pub/media/catalog/* --exclude=pub/media/* --exclude=pub/media/backup/* --exclude=pub/media/import/* --exclude=pub/media/tmp/* --exclude=pub/static/* --exclude=var/* --exclude=private --exclude=tests | gzip > /tmp/`date +%s`.code.tar.gz

After execution you will be able to find dump in the directory /tmp

ls -laht /tmp/*.code.tar.gz

Your dump will be shown at the top of the listed dumps.

console.log(Object.prototype.toString.call(undefined)) // [object Undefined]
console.log(Object.prototype.toString.call('undefined')) // [object String]
console.log(Object.prototype.toString.call('')) // [object String]
console.log(Object.prototype.toString.call(4)) // [object Number]
console.log(Object.prototype.toString.call(NaN)) // [object Number]
console.log(Object.prototype.toString.call(true)) // [object Boolean]
console.log(Object.prototype.toString.call({})) // [object Object]
console.log(Object.prototype.toString.call([])) // [object Array]
console.log(Object.prototype.toString.call(function() {})) // [object Function]
console.log(Object.prototype.toString.call(/^[0-9]*$/)) // [object RegExp]
BASE_URL='http://php70.magento2.local/ee214'
TOKEN=$(curl -sS -g -X POST "$BASE_URL/index.php/rest/V1/integration/customer/token" \
-H "Content-Type:application/json" \
-d '{"username":"roni_cost@example.com", "password":"roni_cost3@example.com"}' | sed 's#"##g')
echo ${TOKEN}
# Get product info
curl -sS -g -X GET "$BASE_URL/index.php/rest/V1/products/MH01/" \

Magento2 implements CyberSource Secure Acceptance Method and you must configure CyberSource with Profile ID, Merchant ID, Transaction Key, Access Key and Secret Key.

I have tested CyberSource with our sandbox account and it's work as expected.

Please ask merchant try to follow next steps: Goto sandbox account https://ebctest.cybersource.com

Tools & Settings -> Profiles -> Select your profile

Press Open Editable Version -> Customer Response Pages and enter URL like https://your-host.com/cybersource/SilentOrder/TokenResponse

@tshabatyn
tshabatyn / benchmark.php
Created December 10, 2018 14:06
Magento save Product vs saveAttribute
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
#!/usr/bin/env bash
OS=`uname -s`
if [ $OS != "Darwin" ]; then
echo "This script is OSX-only. Please do not run it on any other Unix."
exit 1
fi
if [[ $EUID -eq 0 ]]; then
Append or change the following settings in the `/etc/sysctl.conf` file
```
# /etc/sysctl.conf
vm.overcommit_memory = 1
net.core.somaxconn=65535
net.ipv4.tcp_keepalive_time = 10
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
```
Then please execute `/sbin/sysctl -p`. This command applies the changes, we made.
@tshabatyn
tshabatyn / do.sh
Last active August 13, 2020 15:25
Generate ~/.ssh/conf from DigitalOcean API call
#!/bin/sh
TOKEN=$PERSONAL_ACCESS_TOKEN # you can get TOKEN by the link https://cloud.digitalocean.com/account/api
# save droplets list to /tmp/respons.txt
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" "https://api.digitalocean.com/v2/droplets?status=active&page=1&per_page=50" > /tmp/respons.txt
# generate new ~/.ssh/conf from the list of droplets
cat /tmp/respons.txt | jq -s -c 'sort_by(.name) | .[]' | jq -r '.droplets|=sort_by(.name)|.droplets[]|{name: .name, ip_address: .networks.v4[1].ip_address, ip_address_privat: .networks.v4[0].ip_address}|"Host\t\t\t\te-\(.name)\n\tHostName\t\t\(.ip_address)\n## PrivateIp:\t\t\(.ip_address_privat)\n\tUser\t\t\troot\n\tAddKeysToAgent\tyes\n\tForwardAgent\tyes\n\tForwardX11\t\tyes\n\tUseKeychain\t\tyes\n\tIdentityFile\t~/.ssh/id_rsa\n"' > ./do_conf
sed -i -e 's/^Host\t\t\t\t\(.*\)/Host\t\t\t\t\L\1/' ./do_conf
import sys
import shelve
# Loading data fom dataname.db
def loadD():
db = shelve.open('dataname')
dbItems = []
for i in range(0, db['last_index'] + 1):
dbItems.append(db[str(i)])
return dbItems
@tshabatyn
tshabatyn / blocklist.txt
Created August 4, 2020 13:33 — forked from hn-support/blocklist.txt
A curated list of user agents that use lot's of resources but don't cause more conversion or add any value to most of the webshops
360Spider
80legs\.com
ADmantX
Abonti
AcoonBot
Acunetix
AddThis\.com
AhrefsBot
AngloINFO
Antelope