Skip to content

Instantly share code, notes, and snippets.

View kujjwal02's full-sized avatar

Ujjwal Kumar kujjwal02

View GitHub Profile
@kujjwal02
kujjwal02 / aws_mfa.sh
Created September 25, 2023 09:39
Bash shell function to authenticate aws cli using mfa token
#!/bin/bash
function aws_mfa {
code="$1"
serial_number="<add mfa serial here>"
# Check if token code is provided
if [ -z "$code" ]; then
echo -e "\e[31mToken code not provided. Please provide the token code as an argument.\e[0m"
echo "Usage: aws_mfa <token-code> [additional arguments]"
@kujjwal02
kujjwal02 / aws_mfa.fish
Created June 25, 2023 17:37
fish shell function to authenticate aws cli using mfa token
function aws_mfa
set code $argv[1]
set serial_number "<add mfa serial here>"
# Check if token code is provided
if test -z $code
set_color red
echo "Token code not provided. Please provide the token code as an argument."
set_color normal
echo "Usage: aws_mfa <token-code> [additional arguments]"
@kujjwal02
kujjwal02 / jupyter_setup.sh
Last active December 4, 2020 09:33
Setup vm with miniconda and jupyter lab
!/bin/bash
echo "======================Downloading Miniconda=============================="
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
echo "======================Installing Miniconda =============================="
./Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc
echo "======================Installing JupyterLab=============================="
conda install -c conda-forge jupyterlab nb_conda ipywidgets nodejs -y
@kujjwal02
kujjwal02 / parallep_apply.py
Last active May 11, 2019 14:16
Parallel apply pandas
# Source: https://towardsdatascience.com/make-your-own-super-pandas-using-multiproc-1c04f41944a1
def parallelize_dataframe(df, func, n_cores=4):
df_split = np.array_split(df, n_cores)
pool = Pool(n_cores)
df = pd.concat(pool.map(func, df_split))
pool.close()
pool.join()
return df