Skip to content

Instantly share code, notes, and snippets.

View amberj's full-sized avatar

Amber Jain amberj

View GitHub Profile
@amberj
amberj / rgb-colored-echo.sh
Last active April 25, 2024 21:45
A bash pretty print script that provides following red/green/blue colored echo functions.
#!/bin/bash
#
## @file rgb-colored-echo.sh
## @author Amber Jain
## @section DESCRIPTION A bash pretty print script which provides red/green/blue colored echo functions
## @section LICENSE ISC
#################
# Documentation #
@amberj
amberj / beautifulsoup_snippets.py
Last active January 29, 2024 17:53
Beautiful Soup Snippets
#!/usr/bin/env python3
import requests
from curl_cffi import requests
from bs4 import BeautifulSoup
'''
requirements.txt
@amberj
amberj / uncurl.py
Last active October 22, 2023 08:07
Convert curl to requests using uncurl
#!/usr/bin/env python3
import time
import uncurl
'''
This script uses: https://github.com/spulec/uncurl
To install: Setup virtualenv, then run:
@amberj
amberj / csv.py
Created October 21, 2023 04:26
Write Python list as a row to CSV
#!/usr/bin/env python3
import csv
def write_row_to_csv(filename, row_data_as_list, file_mode):
with open(filename, file_mode, newline='') as csvfile:
# creating a csv writer object
csvwriter = csv.writer(csvfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL)
# writing the data rows
csvwriter.writerow(row_data_as_list)
@amberj
amberj / setup-local-replit.sh
Created March 14, 2013 23:30
A bash script to automate the installation/setup of repl.it on local system.
#!/bin/bash
#
## @file setup-local-replit.sh
## @author Amber Jain
## @section DESCRIPTION A bash script to automate the installation/setup of repl.it on local system
## @section LICENSE ISC
#################
# Documentation #
@amberj
amberj / create-folder-date-time.py
Created April 20, 2022 14:26
Create folder (with date & time as folder name) in Python 3
#!/usr/bin/env python3
from datetime import datetime
import os
now = datetime.now()
now_str = now.strftime("%m-%d-%Y_%H-%M-%S-%f")
# This will create a directory similar to this path:
# ./logs/04-20-2022_19-37-08/
temp_path="logs/" + now_str
@amberj
amberj / rev-youtube-playlist-urls.sh
Created May 7, 2012 23:52
This (bash) script takes a youtube playlist URL as argument and outputs title and URL of each video (in playlist) in reverse order
#!/bin/bash
#
# File: rev-youtube-playlist-urls.sh
# Description: This (bash) script takes a youtube playlist URL as argument and outputs title and URL of each video (in playlist) in reverse order (i.e. starting from last video in playlist)
# Author: Amber Jain
# Check if "only one" argument (playlist_url) passed as input:
if [ "$#" -lt "1" ]
then
echo "Invalid! You must pass playlist_url as argument"
@amberj
amberj / calculate-rd-interest.py
Created October 19, 2021 10:46
Calculate interest earned and maturity amount for Recurring Deposit (RD) in Python
#!/usr/bin/env python3
monthly_installment = 30000
# 36 means one installment every month for 3 years
number_of_installments = 36
# Annual rate of interest
# e.g. 9.25%
r = 9.25
@amberj
amberj / calculate-fd-interest.py
Last active October 19, 2021 10:44
Calculate interest earned and maturity amount for Fixed Deposit (FD) in Python
#!/usr/bin/env python3
principal = 200000
# Annual rate of interest
# e.g. 9.25%
r = 9.25
# number of compounding periods per year
#
@amberj
amberj / initial-vps-setup.sh
Last active June 22, 2021 21:36
Initial setup of hosted VPS (which comes with 'root' access by default)
#!/bin/bash
# ABOUT:
#
# Use this set of commands to:
# - Change password of root account
# - Create a new user account, set it's password and grant sudo privileges
# on Ubuntu Linux.
# Change password of currently logged in 'root' account: