This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Colorify your Console statements | |
//Follow us @JSTipsNTricks | |
const bright = "\x1b[1m"; | |
const black = "\x1b[30m"; | |
const red = "\x1b[31m"; | |
const green = "\x1b[32m"; | |
const BGred = "\x1b[41m"; | |
const BGgreen = "\x1b[42m"; | |
const BGyellow = "\x1b[43m"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function checkCapsLock(){ | |
let isCapsLockOn = false; | |
document.addEventListener( 'keydown', (_)=> { | |
var state = _.getModifierState && _.getModifierState('CapsLock'); | |
if(isCapsLockOn !== state){ | |
isCapsLockOn = state; | |
console.log(`Caps Lock Status: ${isCapsLockOn}`) | |
} | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Web API 2 - Get Battery Status | |
Follow us @jstipsntricks | |
*/ | |
const batteryPromise = navigator.getBattery(); | |
batteryPromise.then((e)=>{ | |
printBatteryStatus(e); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
JS: Use _ for visual separation of digits in a number | |
Follow us @jstipsntricks | |
*/ | |
const num1 = 1000000; | |
const num2 = 1_000_000; | |
console.log(num1 === num2); //true | |
//Using exponential representation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
# import webdriver from selenium | |
from selenium import webdriver | |
# Choose browser of your wish | |
# In the case of Firefox, use webdriver.Firefox() | |
driver = webdriver.Chrome(executable_path = 'C:/Users/user1/Downloads/chromedriver_win32/chromedriver.exe') | |
# provide an URL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Node JS: Compress a file using zlib | |
Follow us @jstipsntricks | |
*/ | |
const zlib = require('zlib'); | |
const fs = require('fs'); | |
const zip = zlib.createGzip(); |