array_diff in excel – finding missing values from column B that exist in column A

Fill column A with bigger sample space, aka the longer array. Fill column B with smaller array, that has few or none of the elements from column A Now, you need to find out values that are in column A but not in column B, here is what you do. Create a separate column C and put this formula in cell C1 or $C$1\ =IF(ISERROR(MATCH(A1, $B$1:$C$<LAST_ROWNUMBER_THAT_EXISTS_IN_COLUMN_B>, 0)), A1, "") Ultimately your formula becomes match function dependable for whole column A. You just have to drag the cell C1 downwards.

April 7, 2024 · 1 min · Harshvardhan Malpani

Proxy another website url on a particular path using cloudflare workers – modify response body

// cloudflare worker to proxy a path or a whole url and make changes in response for any use case. const SECOND_DOMAIN = 'second.YOURDOMAIN.com' const THIRD_DOMAIN = 'third.YOURDOMAIN.com' const THIRD_PATH = 'abc-pathname-seo' const THIRD_LINK = 'https://' + THIRD_DOMAIN + THIRD_PATH async function handleRequest(event) { const url = new URL(event.request.url) const pathname = url.pathname if (pathname === '/' + THIRD_PATH) { return thirdLander(event) } const search = url.search const pathWithParams = pathname + search return retrieveStatic(event, pathWithParams) } async function retrieveStatic(event, pathname) { let response = await caches.default.match(event.request) if (response) { return response } const requestHeaders = new Headers(event.request.headers) const headers = new Headers() headers.set('Host', SECOND_DOMAIN) headers.set('Accept', requestHeaders.get('Accept')) headers.set('Accept-Encoding', requestHeaders.get('Accept-Encoding')) let init = { redirect: 'manual', method: event.request.method, headers: headers, } response = await fetch(`https://${THIRD_DOMAIN}/${pathname}`, init) if (event.request.method === 'GET') { event.waitUntil(caches.default.put(event.request, response.clone())) } return response } async function thirdLander(event) { let response = await caches.default.match(event.request) if (response) { return response } const requestHeaders = new Headers(event.request.headers) const headers = new Headers() headers.set('Host', THIRD_DOMAIN) headers.set('Accept', requestHeaders.get('Accept')) headers.set('Accept-Encoding', requestHeaders.get('Accept-Encoding')) headers.set('Cookie', requestHeaders.get('Cookie')) let init = { redirect: 'manual', method: event.request.method, headers: headers, } response = await fetch(THIRD_LINK, init) // RESPONSE BODY MODIFICATION let res2 = response.clone() let orgBody = await response.text() orgBody = orgBody.replace(/src="\//g, 'src="') orgBody = orgBody.replace(/url\("\//g, `url("https://${THIRD_DOMAIN}/`) orgBody = orgBody.replace(/<\/head>/g, `<base href="https://${THIRD_DOMAIN}/" target=_blank><link rel="canonical" href="https://YOURDOMAIN.com${THIRD_PATH}" /></head>`) if (event.request.method === 'GET') { event.waitUntil(caches.default.put(event.request, new Response(orgBody, res2))) } return new Response(orgBody, res2) } addEventListener("fetch", (event) => { event.passThroughOnException() event.respondWith(handleRequest(event)) })

October 9, 2023 · 2 min · Harshvardhan Malpani

How to fix CORS error for amazon s3 files and resources?

Go to bucket In the bucket permissions tab There is a section for CORS, put the following in it and save. [ { "AllowedOrigins": [ "*" ], "AllowedMethods": [ "GET" ], "MaxAgeSeconds": 3000, "ExposeHeaders": [ "Content-Range", "Content-Length", "ETag" ], "AllowedHeaders": [ "Authorization", "Content-Range", "Accept", "Content-Type", "Origin", "Range" ] } ]

January 17, 2022 · 1 min · Harshvardhan Malpani

centos web panel – vhost templates for proxying websocket traffic

http://wiki.centos-webpanel.com/webservers-vhost-templates Templates location: /usr/local/cwpsrv/htdocs/resources/conf/web_servers/ – Folder main contains main configuration for WebServers – Folder vhosts contains vhosts configuration for domains (this is what you need) How to create a template file The easiest way to do that is to simply copy an existing file and then edit a new file you have created. Note that you need to have .tpl and .stpl files (tpl is for http and stpl is for https version) ...

January 7, 2022 · 1 min · Harshvardhan Malpani

golang update in centos

wget https://raw.githubusercontent.com/udhos/update-golang/master/update-golang.sh chmod 755 ./update-golang.sh which go sudo RELEASE=1.16.6 DESTINATION=/usr/lib ./update-golang.sh sudo alternatives --install /usr/bin/go go /usr/lib/go/bin/go 5 sudo alternatives --config go

January 6, 2022 · 1 min · Harshvardhan Malpani

basic cwp with jenkins and nodejs

hostname srv1.example.com yum -y install wget yum -y update reboot cd /usr/local/src wget http://centos-webpanel.com/cwp-el7-latest sh cwp-el7-latest -r no --phpfpm 7.3 --softaculous no reboot sudo wget -O /etc/yum.repos.d/jenkins.repo \ https://pkg.jenkins.io/redhat-stable/jenkins.repo sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key sudo yum upgrade sudo yum install epel-release java-11-openjdk-devel sudo yum install jenkins sudo systemctl daemon-reload curl -sL https://rpm.nodesource.com/setup_12.x | bash - sudo yum install nodejs npm -y sudo npm install pm2@latest -g

December 28, 2021 · 1 min · Harshvardhan Malpani

How to generate a patch with edited files? How to zip latest committed changes only

zip archive.zip $(git diff-tree --no-commit-id --name-only -r latest-commit-id) Reference: https://stackoverflow.com/a/42971972/2229148 sometimes you need all the files that were updated so you can patch an external app which doesnt uses same git project or many other scenarios in which we need a zip or tar of those files. Use the above command to do so There is a smarter way also, if you want all the changes from last 5 commits, use the command like this: ...

September 6, 2021 · 1 min · Harshvardhan Malpani

Basic Authentication in nginx for any domain, server or location block

sudo yum install httpd-tools sudo htpasswd -c /etc/nginx/conf.d/vhosts/.htpasswd USERNAME Enter Password: xxxxx sudo chmod 644 /etc/nginx/conf.d/vhosts/.htpasswd Update the domain.conf file like /etc/nginx/conf.d/vhosts/myrestricteddomain.com.ssl.conf Ideally, use it in server config 1 2 3 4 5 server { satisfy all; auth_basic "Restricted Area"; auth_basic_user_file /etc/nginx/conf.d/vhosts/.htpasswd; location / { Save and restart nginx

August 3, 2021 · 1 min · Harshvardhan Malpani

Installing a testing instance for Magento CLI only

Prerequisite: Magento repo access keys Mysql Database, username and password a domain name pointing to a server if you dont have access key, get a pair here : https://marketplace.magento.com/customer/accessKeys/\ php -d memory_limit=-1 /bin/composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.2.11 ./ In the above command, you can change version/subversion of magento repo. You can also change the install directory After the successful run of above command:\ bin/magento setup:install \ --base-url=https://testmagento.domain.com \ --db-host=localhost \ --db-name=testmage_x1 \ --db-user=testmage_x1 \ --db-password=WEux3dxxxxw \ --admin-firstname=xxx \ --admin-lastname=yyy \ [email protected] \ --admin-user=admin \ --admin-password=WwKhxxxxxxEK \ --language=en_US \ --currency=USD \ --timezone=America/Chicago \ --use-rewrites=1 YOu will see Magento Admin URI: /admin_10lf7y after successful run ...

February 4, 2021 · 1 min · Harshvardhan Malpani

Jenkins auto deploying flask in test env with last build process kill and pipenv

#!/bin/sh cd $WORKSPACE export PY=/usr/local/bin/python3 export FLASK_RUN_PORT=4005 $PY -m pip install pipenv $PY -m pipenv install --dev export VENV_HOME_DIR=$($PY -m pipenv --venv) source $VENV_HOME_DIR/bin/activate flask db upgrade flask populate-initial-data export BUILD_ID=XYZapi $WORKSPACE/killlastbuild.sh flask run & deactivate killlastbuild.sh can have anything inside it depending upon your project requirements. I put 2 process killers to kill background-ed daemon processes from previous build command ps -Af | grep "xyzapi" | grep -v grep | awk '{print$2}' | head -1 | xargs kill -9 ps -Af | grep "xyzapi" | grep -v grep | awk '{print$2}' | head -1 | xargs kill -9

June 22, 2020 · 1 min · Harshvardhan Malpani