How to temporarily bypass content security policy CSP headers

Browser: Firefox Extension: Mod Headers https://addons.mozilla.org/en-US/firefox/addon/modheader-firefox/ Add A CSP policy like this: Use “parse” option and paste this:\ default-src *; script-src 'unsafe-inline' 'unsafe-eval' *; style-src 'unsafe-inline' *; img-src * blob: data:; font-src * data:; To create a Content Security Policy (CSP) header that allows everything, you would use the 'unsafe-inline' and 'unsafe-eval' sources for scripts and styles, and the * wildcard to allow all other sources. This setup is generally not recommended for production environments because it exposes your site to potential security vulnerabilities. However, it can be useful for development or testing purposes. Here’s an example of what this CSP header might look like: ...

March 7, 2024 · 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

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

proxying websockets via nginx and https

December 9, 2020 · 0 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

How to solve MySQL server gone away error Maria Db update on cPanel and WHM?

This is related to new MariaDb upgrade from 10.1.41 to 10.1.42 and also for servers which were updated from 10.2.27 to 10.2.28 Go to solution ( Special Thanks to @Valetia ) You will see errors in following formats/messages: No file or input found MySQL Server has gone away Connection to MySQL Server failed sqlstate[hy000]: general error: 2013 lost connection to mysql server during query General error: 2006 MySQL server has gone away ERROR 2006 (HY000): MySQL server has gone away ERROR 2013 (HY000): Lost connection to MySQL server during query Log files (/var/lib/mysql/$hostname.err) will have or can have any of these errors: ...

November 6, 2019 · 1 min · Harshvardhan Malpani

A basic time difference calculator in google script js

In your Google Sheet, Click “Tools” and then choose “Script Editor“. Put the code given below. Don’t forget to use function in your result column as “=dodiff(cell1,cell2)“ function dodiff(a, b) { if (a) a = fix(a); if (b) b = fix(b); if (Array.isArray(a) && Array.isArray(b)) { if (b[1] > a[1]) m = b[1] - a[1]; else { m = b[1] - a[1] + 60; b[0]--; } if (b[0] >= a[0]) h = b[0] - a[0]; else { h = b[0] - a[0] + 12; } m = m / 60; return (h + m).toPrecision(4); } } function fix(a) { if (a) x = a.toString().replace(" ", '').replace("am", "").replace("pm", "").replace("PM", "").replace("AM", ""); x = x.split(":"); x[0] = parseInt(x[0]); x[1] = parseInt(x[1]); return x; }

October 15, 2019 · 1 min · Harshvardhan Malpani

How to reverse the ids in a mysql table column without breaking primary key constraint?

Let me explain the problem scenario: Let us assume we have a table with 4 columns in it out of which 1 is PRIMARY column and rest 3 contain some data. What we want to do is to reverse the primary key IDs for that data keeping the rest of data intact. It is like shifting the first row to end and moving last row to starting. Initial Data id name email anything 1 jacob whatever how to reverse 3 nathan whosoeverisnathan ids in mysql table column 4 jagmohan idontknowjagmohan without breaking 8 monica iamsexy primary key constraint 9 batman idontexistinrealworld i am batman Data after update id name email anything 9 jacob whatever how to reverse 8 nathan whosoeverisnathan ids in mysql table column 4 jagmohan idontknowjagmohan without breaking 3 monica iamsexy primary key constraint 1 batman idontexistinrealworld i am batman Dude, you are just reversing the column, what is so tough in this? So, this seems simple to reverse an array if isolated by key “id“. But you have to understand that this column is the primary key. So if you run a command to change id for “jacob” to “9“. It will give you error: “Duplicate entry for id 9“ ...

June 1, 2019 · 2 min · Harshvardhan Malpani

How to remove files with “No Content Changes Found” in Git Desktop

There are 3 possible ways git can find a file changed (even if you didn’t change it) Line Endings have changed File permissions have changed Bonus: if modification time has changed for first case try these settings in bash shell. One of these will fix it for you $ git config core.eol $ git config core.autocrlf $ git config core.safecrlf For second case, here is the flag git config core.filemode false Bonus One: If Modification time was changed If your working tree has files with updated “last modification time” and you see a huge list of files with “no content changes found”, try this: ...

May 8, 2019 · 1 min · Harshvardhan Malpani