Skip to content

Instantly share code, notes, and snippets.

@tpkahlon
tpkahlon / index.sh
Created September 20, 2021 19:35
How to install third-party applications on Mac?
# Run following command
sudo spctl --master-disable
# Install your third-party application on the machine. After installation is complete, run the command below
# Run following command
sudo spctl --master-enable
@tpkahlon
tpkahlon / index.js
Created September 7, 2021 15:47
CDS - Twitter Handles
const getTwitterHandles = Array.from(document.querySelectorAll('a[href^="https://twitter.com"]')).map(i => i.getAttribute('href').replace('https://twitter.com/', '@')).join("\n");
console.log(getTwitterHandles);
@tpkahlon
tpkahlon / logic.js
Created June 26, 2021 02:32
Logic - Calculate quantity of fruit with coverage of possible test cases
/*
Write a function that takes input of arrays and loops over them to calculate return values based on some criteria. For example, take this array [['oranges', 1], ['apples', 2], ['grapes', 7]]. Based on this array return total costs if second array property is a quantity and product is first array item. If say Oranges cost $5, and user buys the quantity of 2 or more, apply a 20% discount etc.. Return total cost from array by adding them all up.
Let's assume:
Orange = $2
Apple = $3
Grapes = $5
*/
const sampleData = [
@tpkahlon
tpkahlon / dark-mode.js
Last active January 5, 2021 21:36
Dark Mode (Hacker News)
// Copy code below and run in browser console
"use strict";document.querySelectorAll("td, #hnmain").forEach(e=>e.setAttribute("bgcolor","")),document.querySelectorAll("a").forEach(e=>e.style.cssText="color:inherit"),document.querySelectorAll(".storylink").forEach(e=>e.style.cssText="color:white"),document.querySelectorAll(".pagetop *, span").forEach(e=>e.style.cssText="color:grey"),document.querySelector("body").style.cssText="background-color:#222;color:#fff";
@tpkahlon
tpkahlon / locked-papers.js
Last active January 6, 2021 00:00
locked-papers.js
// thestar.com
// Open any locked article on thestar.com/business/personal_finance
// E.g. https://www.thestar.com/business/personal_finance/2021/01/04/this-29-year-old-was-laid-off-early-on-in-the-pandemic-she-recently-found-a-job-but-now-her-investment-property-is-sitting-vacant-how-can-she-achieve-her-saving-goals.html
// Paste script below in console and run
document.querySelectorAll('p').forEach(i => (i.style.display = 'block'));
@tpkahlon
tpkahlon / modern-browsers.sh
Last active December 24, 2020 10:48
Modern Browsers for Macintosh
# Run the following command to get modern browsers (make sure you have stable version of Brew installed on your Macintosh)
# Installation
brew install google-chrome-dev firefox-developer-edition brave-browser-dev opera-developer microsoft-edge-dev safari-technology-preview
# Uninstallation
brew uninstall google-chrome-dev firefox-developer-edition brave-browser-dev opera-developer microsoft-edge-dev safari-technology-preview
@tpkahlon
tpkahlon / imgur-next-please.js
Last active December 10, 2020 00:27
Imgur Next Please...
setInterval(() => {
const b = document.querySelector('.Navigation-next');
b.click();
}, 10000);