Skip to content

Instantly share code, notes, and snippets.

View jojijacobk's full-sized avatar
🎯
Focusing

Joji Jacob jojijacobk

🎯
Focusing
View GitHub Profile
@jojijacobk
jojijacobk / launch.json
Last active September 30, 2022 10:25
How to debug Next.js in VSCode? How to prevent weird cache issue in VSCode which will retain older source code files even after we modify them in the editor. Use the following configuration to achieve this.
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev",
"preLaunchTask": "clear-editor-history"
},
@jojijacobk
jojijacobk / disable-mcafee-osx.md
Last active October 15, 2021 03:22
Disable McAfee in OSX command line before trying to sync iPhone or iPad with Mac. McAfee services blocks sync between iOS devices and Mac.

method 1

sudo /usr/local/McAfee/AntiMalware/VSControl stopoas

alternative 1

sudo defaults write /Library/Preferences/com.mcafee.ssm.StatefulFirewall.plist IsFirewallEnabled -bool false
@jojijacobk
jojijacobk / webpack.config.js
Created January 31, 2021 11:43
To have VS Code autocomplete feature for Webpack configuration add the following annotation as the first line in webpack.config.js file.
/** @type {import('webpack').Configuration} */
@jojijacobk
jojijacobk / GetColorCount.vba
Created August 23, 2020 15:36
VBA function to get count of cells with a specific colour code
Function GetColorCount(CountRange As Range, CountColor As Range)
Dim CountColorValue As Integer
Dim TotalCount As Integer
CountColorValue = CountColor.Interior.ColorIndex
Set rCell = CountRange
For Each rCell In CountRange
If rCell.Interior.ColorIndex = CountColorValue Then
TotalCount = TotalCount + 1
End If
Next rCell
@jojijacobk
jojijacobk / oraclelinux-nginx.Dockerfile
Last active July 12, 2020 10:19
Dockefile for Nginx on Oracle linux
FROM oraclelinux
MAINTAINER "Joji Jacob" <joji.jacob.k@gmail.com>
USER root
# Install nginx
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
yum install -y nginx
# Forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
EXPOSE 80 443
@jojijacobk
jojijacobk / oraclelinux-mysql.Dockerfile
Last active July 12, 2020 10:17
Dockerfile for MySQL on Oracle linux
FROM oraclelinux
MAINTAINER "Joji Jacob" <joji.jacob.k@gmail.com>
USER root
# Install mysql
RUN yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm && \
yum install -y --nogpgcheck mysql-community-server
EXPOSE 3306
@jojijacobk
jojijacobk / Setup (PHP, Nginx, MySQL) stack on AWS.md
Last active December 13, 2019 16:33
Setup stack of (PHP, Nginx & MySQL) on AWS

Yum Install PHP

# For Amazon Linux Image in AWS EC2, enable yum repository for amazon linux extras to install PHP
# Enable PHP 7.3 repo
sudo amazon-linux-extras enable php7.3

# Install PHP 7.3
sudo amazon-linux-extras install php7.3

# View all available PHP packages
@jojijacobk
jojijacobk / CORS.md
Last active November 17, 2019 10:47
Comprehend CORS - Cross Origin Resource Sharing

Cross Origin Resource Sharing

Understand CORS

Look at the following scenario:

  1. You load website-A
  2. Website A had a script which sends ajax request to website-B
  3. CORS violation appears: The response coming from website-B is blocked by browser from touching data of website-A by default due to CORS policy.

This is a security feature implemented only in browsers which prevents a 3rd party script from extracting your private data and send that to website-B. The gravity of this issue can be understood in the following sample script.

@jojijacobk
jojijacobk / intercept-XMLHttpRequest.js
Created August 10, 2019 16:18
Intercept any XMLHttpRequests happening in your page either by your own code or from a third party library
(function(originalOpen) {
XMLHttpRequest.prototype.open = function() {
this.addEventListener('progress', function() {
console.log('request in progress);
});
this.addEventListener('load', function() {
console.log('request complete);
});
originalOpen.apply(this, arguments);
@jojijacobk
jojijacobk / speech-synthesis.js
Last active August 9, 2019 17:38
To simulate speech from browser using all the voices installed in your computer
// To simulate speech from browser using all the voices installed in your computer
Array.from(window.speechSynthesis.getVoices()).forEach(voice => {
console.log(voice);
const msg = new SpeechSynthesisUtterance();
msg.voice = voice; // Note: some voices don't support altering params
msg.voiceURI = 'native';
msg.volume = 1; // 0 to 1
msg.rate = 1; // 0.1 to 10
msg.pitch = 2; // 0 to 2