Skip to content

Instantly share code, notes, and snippets.

View ShivamJoker's full-sized avatar
🐢
Code for life

Shivam ShivamJoker

🐢
Code for life
View GitHub Profile
@ShivamJoker
ShivamJoker / GoogleLogin.js
Created December 29, 2020 16:23
Login to your google account with puppeteer
import puppeteer from "puppeteer-extra";
import StealthPlugin from "puppeteer-extra-plugin-stealth";
puppeteer.use(StealthPlugin());
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
const navigationPromise = page.waitForNavigation();
await page.goto("https://accounts.google.com/");
@ShivamJoker
ShivamJoker / benchmark
Created December 5, 2021 11:11
nodejs stream benchmarks
❯ autocannon -c 5 -a 5 --timeout 1000000 'http://143.110.241.172/stream?limit=100000'
Running 5 requests test @ http://143.110.241.172/stream?limit=100000
5 connections
┌─────────┬──────────┬──────────┬──────────┬──────────┬────────────┬──────────┬──────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────────┼──────────┼──────────┼──────────┼────────────┼──────────┼──────────┤
│ Latency │ 14475 ms │ 14588 ms │ 15197 ms │ 15197 ms │ 14666.8 ms │ 270.1 ms │ 15197 ms │
@ShivamJoker
ShivamJoker / Useful bash commands.md
Last active November 17, 2024 19:19
Some of the useful bash commands which I use everyday

Rename all files extension recursively eg. .js to .jsx

find . -name '*.js' -exec sh -c 'mv "$0" "${0%.js}.jsx"' {} \;

Convert all images in a specific format (eg .png or .jpg to webp)

for i in *; do convert $i "${i%.*}.webp"; done   
@ShivamJoker
ShivamJoker / index.html
Last active January 7, 2022 16:17
Split vs Slice #jsbench #jsperf (http://jsbench.github.io/#659320c361dc2745813ae6aaebbdfff9) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Split vs Slice #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@ShivamJoker
ShivamJoker / password-manager.ts
Created January 9, 2022 14:31
Password encryption in NodeJS with Crypto module
import { randomBytes, scryptSync } from 'crypto';
// Pass the password string and get hashed password back
// ( and store only the hashed string in your database)
const encryptPassowrd = (password: string, salt: string) => {
return scryptSync(password, salt, 32).toString('hex');
};
/**
* Hash password with random salt
@ShivamJoker
ShivamJoker / README.md
Created May 26, 2022 09:34
Simple function which rendereds RGB color in your terminal console

Sample color pallete output

image

@ShivamJoker
ShivamJoker / jwt-encode-decode-with-jose.js
Last active September 6, 2022 17:48
Simple JWT encoding and verifying with jose library
import { TextEncoder } from "util";
import { SignJWT, jwtVerify } from "jose";
const secret = process.env.JWT_SECRET ?? "I like bananas";
const textEncoder = new TextEncoder();
const keyToSignWith = textEncoder.encode(secret);
const jwt = await new SignJWT({
email: "[email protected]"
@ShivamJoker
ShivamJoker / get-cookie.js
Created July 13, 2022 17:41
Simple cookie utility function to get a particular cookie in JavaScript
@ShivamJoker
ShivamJoker / AWS_regions.json
Created July 18, 2022 14:03
AWS Regions' list in array with region code
[
"US East (N. Virginia) us-east-1",
"US East (Ohio) us-east-2",
"US West (N. California) us-west-1",
"US West (Oregon) us-west-2",
"Africa (Cape Town) af-south-1",
"Asia Pacific (Hong Kong) ap-east-1",
"Asia Pacific (Jakarta) ap-southeast-3",
"Asia Pacific (Mumbai) ap-south-1",
"Asia Pacific (Osaka) ap-northeast-3",
@ShivamJoker
ShivamJoker / dad-jokes-collection.json
Created September 6, 2022 14:57
A collection of 600+ dad jokes downloaded from icanhazdadjoke.com
[
{
"id": "0189hNRf2g",
"joke": "I'm tired of following my dreams. I'm just going to ask them where they are going and meet up with them later."
},
{
"id": "08EQZ8EQukb",
"joke": "Did you hear about the guy whose whole left side was cut off? He's all right now."
},
{