Skip to content

Instantly share code, notes, and snippets.

View vinodnimbalkar's full-sized avatar
🎯
Focusing

Vinod Nimbalkar vinodnimbalkar

🎯
Focusing
View GitHub Profile

Do not use forEach with async-await

TLDR: Use for...of instead of forEach in asynchronous code.

The problem

Array.prototype.forEach is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)

For example, the following forEach loop might not do what it appears to do:

NEOVIM KEYBOARD SHORTCUTS

As configured in my dotfiles.

MOVEMENT

h        -   Move left
j        -   Move down
k        -   Move up
l        -   Move right
$        -   Move to end of line
@vinodnimbalkar
vinodnimbalkar / tmux-cheatsheet.md
Created November 6, 2021 14:35
tmux shortcuts & cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@vinodnimbalkar
vinodnimbalkar / jiosaavan
Created September 11, 2021 14:56
Play song on terminal using jiosaavan unofficial API
#!/bin/bash
search_base_url="https://www.jiosaavn.com/api.php?__call=autocomplete.get&_format=json&_marker=0&cc=in&includeMetaTags=1&query="
song_details_base_url="https://www.jiosaavn.com/api.php?__call=song.getDetails&cc=in&_marker=0%3F_marker%3D0&_format=json&pids="
while getopts q: flag
do
case "${flag}" in
q) query=${OPTARG};;
esac
@vinodnimbalkar
vinodnimbalkar / vaccinestatus.sh
Created August 9, 2021 15:35
Vaccine availability status by pincode
#!/bin/bash
BASE_URL="https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin"
date=$(date +%d-%m-%Y)
while getopts p: flag
do
case "${flag}" in
p) pincode=${OPTARG};;
esac
@vinodnimbalkar
vinodnimbalkar / livechannel.sh
Last active March 2, 2022 14:55
Play live channel with help of curl, rofi and mpv (mxplayer)
#!/bin/bash
BASE_URL='https://www.mxplayer.in'
# GET LIST OF LINKS
links=$(curl -s https://www.mxplayer.in/browse/live-tv | grep -Eoi '<a [^>]+>' |
grep -Eo 'href="[^\"]+"' | grep -Eoi '\/live-tv\/.*' | grep -v '\-live-channels"$' | sed 's/\"//g')
# SELECT CHANNEL USING ROFI
link=$(echo ${links} | sed -e 's/\s/\n/g' | sed "s|^|$BASE_URL|g" | rofi -dmenu "live channel : ")
# GET M3U8 LINK
play=$(curl -s ${link} | tr "," "\n" | grep -E '(^\"contentUrl\":\"https:\/\/llvod\.mxplay).*(.m3u8)' | \
@vinodnimbalkar
vinodnimbalkar / yt-clip
Created July 7, 2021 15:39
Create Video clip from youtube video
#!/bin/bash
# make sure you have 'ffmpeg & youtube-dl' installed.
# Create Video clip from youtube video
read -p "Enter Url to Create Video Clip : " URL
read -p "Enter start time in HH:MM:SS format : " start_time
read -p "Enter duration in seconds from start time : " duration
read -p "Enter Video Clip name with .mp4 extension : " filename
@vinodnimbalkar
vinodnimbalkar / cowin.js
Last active May 18, 2021 06:53
Get an update on console as soon as a slot opens up in https://selfregistration.cowin.gov.in/
/*
This script inspired by -> https://gist.github.com/debarko/45995919e2dc13d741b75215d393800d
Thanks to Debarko De.
It might be not working on an older browser.
Change the pincodes to your needs as per your city.
How To setup Video -> https://www.youtube.com/watch?v=3_N5FFegtI4
Steps to use
1. Update Pincode eg. ['110001', '110002'] and update age e.g 25
@vinodnimbalkar
vinodnimbalkar / protect_pdf.py
Created August 12, 2020 04:11
bulk password protected pdf
import PyPDF2
import os
BASEDIR = os.path.abspath(os.path.dirname(__file__))
pdfdirectory = input("Pease provide pdf directory name : ")
user_pass = input("Pease provide password to protect pdf file : ")
PDFDIR = os.listdir(f"{BASEDIR}/{pdfdirectory}/")
def set_password():