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 / vscode-debug-sidebar-customization.md
Last active December 17, 2020 03:30
Hack VS Code sidebar widgets

Intro

Microsoft has done a great job with VSCode. One thing I dislike is that they hardcoded "font-family" and "font-size" on debug sidebar panel. I'm not sure why they didn't made them configurable while the default hardcoded style looks horrible and illegible. But, there is a way to fix this!

As VSCode app is based on Electron, you can alter the style of any interface of this IDE by editing corresponding CSS files. Here are some of my preferences:

  • Visual Studion version 1.51.1

Edit workbench.main.css, and add the following style changes to the end.

@jojijacobk
jojijacobk / media-query.css
Last active July 4, 2019 06:46 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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} */