Skip to content

Instantly share code, notes, and snippets.

View harshvardhanmalpani's full-sized avatar
💯
life is a party!!

Harshvardhan Malpani harshvardhanmalpani

💯
life is a party!!
View GitHub Profile
@harshvardhanmalpani
harshvardhanmalpani / di.xml
Last active November 27, 2021 22:57
Fixes batch size for Magento 2.2.4 and above. Put the file in app/code/[Vendor]/[Module]/etc/adminhtml/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Model\Indexer\Category\Product\Action\Full">
<arguments>
<argument name="batchRowsCount" xsi:type="number">1000</argument>
</arguments>
</type>
<type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\BatchSizeCalculator">
<arguments>
<argument name="batchRowsCount" xsi:type="array">
@harshvardhanmalpani
harshvardhanmalpani / woo-get_order-api-update.php
Last active June 24, 2021 02:01
overriding wc api response
<?php
//// FOR LEGACY API ONLY
add_filter('woocommerce_api_order_response', 'harsh_add_shipping_phone_legacy', 99, 1);
function harsh_add_shipping_phone($order_data)
{
$order_data["billing_address"]["email"] = "XXXX";
$shipping_phone = get_post_meta($order_data["id"],"_shipping_phone",1);
if($shipping_phone!==false && strlen($shipping_phone))
{
@harshvardhanmalpani
harshvardhanmalpani / socket-config.nginx
Created December 9, 2020 15:46
nginx configuration for proxying web sockets
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server 127.0.0.1:4050;
}
server {
@harshvardhanmalpani
harshvardhanmalpani / int_float-type-conversion_test.php
Created July 4, 2020 13:08
PHP caveats – int/float type conversion
<?php
// important to focus on the values with "e" scientific notation
// interesting results for "0.1",-0, "1" and "042"
$arr = ["true", true, false, "false",
0, -0.0, 00, "-0", "+0", "-0.0", "+0.0", "0", "0w", "0.0t",
"0.1", 0.1, 1, "1",
1e4, "2e", 2e4, "2e4",
1337e0, "1e3", 1e1,
1.3, "1.4", "1t", "1.5n",
@harshvardhanmalpani
harshvardhanmalpani / createCat.php
Created October 27, 2017 08:02
How to create Magento 2 category programmatically
<?php
//creating categories in magento 2
//last verified Magento 2.2.0 27 Oct 2017
use \Magento\Framework\App\Bootstrap;
echo 'code by harshvardhanmalpani';
include('./app/bootstrap.php');
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
function createCategory($a='',$b=2,$c=true,$d='',$e='',$f='',$g='') {
global $objectManager;
@harshvardhanmalpani
harshvardhanmalpani / flushdb.sql
Created October 30, 2018 23:05
Remove all tables
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
@harshvardhanmalpani
harshvardhanmalpani / show domains with 2 vowels on char5.com.js
Created May 20, 2019 13:38
this console script shows domain names with 2 or more vowels on char5.com
var jqry = document.createElement('script'); jqry.src = "https://code.jquery.com/jquery-3.3.1.min.js"; document.getElementsByTagName('head')[0].appendChild(jqry); $=jQuery.noConflict();
$("table form input[type=submit]").each(function(){
var c=$(this).attr("value").replace("www.","").replace(".com","");
var d=getVowels(c);
if(d<2)$(this).parent().parent().remove();
});
function getVowels(str) {
var m = str.match(/[aeiou]/gi);
@harshvardhanmalpani
harshvardhanmalpani / magento latest 7.1.json
Last active January 3, 2019 13:00
EasyApache4 Magento2x Profile with PHP 7.1 and 7.1
{
"desc" : "Magento Latest 7.1",
"pkgs" : [
"ea-apache24",
"ea-apache24-config",
"ea-apache24-config-runtime",
"ea-apache24-devel",
"ea-apache24-mod_brotli",
"ea-apache24-mod_bwlimited",
"ea-apache24-mod_cache",
@harshvardhanmalpani
harshvardhanmalpani / fman.php
Created December 23, 2018 17:00
php file manager
<?php
//{"lang":"","auth_pass":"d41d8cd98f00b204e9800998ecf8427e","error_reporting":"1"}
/*--------------------------------------------------
| PHP FILE MANAGER
+--------------------------------------------------
| phpFileManager 1.6
| By Fabricio Seger Kolling
| Copyright (c) 2004-2018 Fabrício Seger Kolling
| E-mail: dulldusk@gmail.com
| URL: http://phpfm.sf.net
@harshvardhanmalpani
harshvardhanmalpani / FixerIo.php
Created July 19, 2018 08:45
fixer.io replacement
<?php
#/vendor/magento/module-directory/Model/Currency/Import/FixerIo.php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Directory\Model\Currency\Import;
/**
* Currency rate import model (From http://fixer.io/)