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 / 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 / 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 / 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 / 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 / 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 / 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: [email protected]
| URL: http://phpfm.sf.net
@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 / 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 / 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/)
@harshvardhanmalpani
harshvardhanmalpani / 0-step.js
Last active June 8, 2018 19:51
EMail addresses in my spam filter list
/* insert the following code in console jQuery v3.3.1 */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){"use strict";var n=[],r=e.document,i=Object.getPrototypeOf,o=n.slice,a=n.concat,s=n.push,u=n.indexOf,l={},c=l.toString,f=l.hasOwnProperty,p=f.toString,d=p.call(Object),h={},g=function e(t){return"function"==typeof t&&"number"!=typeof t.nodeType},y=function e(t){return null!=t&&t===t.window},v={type:!0,src:!0,noModule:!0};function m(e,t,n){var i,o=(t=t||r).createElement("script");if(o.text=e,n)for(i in v)n[i]&&(o[i]=n[i]);t.head.appendChild(o).parentNode.removeChild(o)}function x(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?l[c.call(e)]||"object":typeof e}var b="3.3.1",w=function(e,t){return new w.fn.init(e,t)},T=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;w.fn=w.protot