Skip to content

Instantly share code, notes, and snippets.

View amberj's full-sized avatar

Amber Jain amberj

View GitHub Profile
@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 / 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 / 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 / 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 / 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
#
{"shop_id":84644,
"vendor_id":62414,
"img_URL":null,
"user_preferred_domain":null,
"shipping_cost":0,
"shop_description":"my test shop",
"domain_identifier":"test59",
"shop_name":"Test",
"shop_logo_URL":null,
"shop_contact_number":"9769110914",
@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:
@amberj
amberj / setup-headless-selenium-xvfb.sh
Created September 25, 2013 05:06
Bash script to install/setup headless Selenium (uses Xvfb and Chrome)
#!/bin/bash
#
# Bash script to setup headless Selenium (uses Xvfb and Chrome)
# (Tested on Ubuntu 12.04)
# Add Google Chrome's repo to sources.list
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
# Install Google's public key used for signing packages (e.g. Chrome)
# (Source: http://www.google.com/linuxrepositories/)
@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 #