Skip to content

Instantly share code, notes, and snippets.

View qant's full-sized avatar
💫
Permanent study state

Anton qant

💫
Permanent study state
  • lusa realty, lusa legal, banisio
  • Испания
  • X @antseme
View GitHub Profile
@qant
qant / lenura_empty_cart_before_add.php
Created May 29, 2021 11:48 — forked from viniciusrtf/lenura_empty_cart_before_add.php
WooCommerce Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty
<?php
/**
* Hook: Empty cart before adding a new product to cart WITHOUT throwing woocommerce_cart_is_empty
*/
add_action ('woocommerce_add_to_cart', 'lenura_empty_cart_before_add', 0);
function lenura_empty_cart_before_add() {
global $woocommerce;
// Get 'product_id' and 'quantity' for the current woocommerce_add_to_cart operation
@qant
qant / woo-events.js
Created May 29, 2021 08:51 — forked from bagerathan/woo-events.js
Woocommerce Javascript events #woocommerce
//Woocommerce Checkout JS events
$( document.body ).trigger( 'init_checkout' );
$( document.body ).trigger( 'payment_method_selected' );
$( document.body ).trigger( 'update_checkout' );
$( document.body ).trigger( 'updated_checkout' );
$( document.body ).trigger( 'checkout_error' );
//Woocommerce cart page JS events
$( document.body ).trigger( 'wc_cart_emptied' );
$( document.body ).trigger( 'update_checkout' );
@qant
qant / curl_vs_getheaders.php
Created April 16, 2021 10:56
cURL vs get_headers() Speed Test
<?php
// Get headers for 100 unique random domains with get_headers() and cURL to determine which is faster.
/*
TL;DR -> cURL is significantly faster.
get_headers (GET) vs cURL:
Execution time : 139.95884609222 seconds
Execution time : 65.998840093613 seconds
@qant
qant / google_translate.html
Created April 1, 2021 09:53 — forked from carolineschnapp/google_translate.html
Google Translate Embed Code
<div id="google_translate_element"></div>
<script>
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en'
}, 'google_translate_element');
}
</script>
<script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
@qant
qant / gulp-image-compressor-page-peed-google.txt
Created March 9, 2021 13:39
Gulp image compression for Page Speed of Google, 37% of compression aprox.
install node
install npm
put package.json
npm i
create _src/ and dest/ folders
put image files to _src/ folder
then "npx gulp" to run
@qant
qant / gist:01dea07fa9847c292225e57176c35712
Created March 7, 2021 12:23
Docker mysql how to import big sql dump (close to 1 gb)
docker ps (for get name of my container like "ant_database_1")
docker exec ant_database_1 sh -c 'exec mysql -D wordpress -uwordpress -pwordpress' < local.sql
* will not work because default max_allowed_packet in mysql configuration so:
docker exec -it ant_database_1 bash -c "echo 'max_allowed_packet = 1G' >> /etc/mysql/mysql.conf.d/mysqld.cnf"
Now it might work.
But to be shure i am prefere the way with copy and manual import inside the container
@qant
qant / docker.md
Created March 5, 2021 11:21 — forked from JacobFierro/docker.md
Docker Cheatsheet

Docker Cheatsheet

Docker info:

docker info

Containers

List Images:

@qant
qant / example.txt
Created May 21, 2020 11:00
Translate text with google api for free
Upload this file to your php app and run like this:
http://localhost/translate-text-google-api-free.php
OR with translating parameters http://localhost/translate-text-google-api-free.php?tl=ru
Also there is limit with 5000 simbols, and the google api can ban your ip if you will abise to much.
@qant
qant / vanilla-js-cheatsheet.md
Created May 16, 2020 09:09 — forked from thegitfather/vanilla-js-cheatsheet.md
Vanilla JavaScript Quick Reference / Cheatsheet
@qant
qant / playwright-iphone11pro.js
Created May 12, 2020 15:16
Check url on iphone 11 pro with playwright (like puppeteer) in 3 browser
//npm
const playwright = require("playwright");
const vp = { width: 375, height: 812 };
(async () => {
for (const browserType of ["webkit", "chromium", "firefox"]) {
const browser = await playwright[browserType].launch();
const context = await browser.newContext({
devices: ["iPhone 11 Pro"],