Skip to content

Instantly share code, notes, and snippets.

@jpigla
Last active May 19, 2022 11:55
Show Gist options
  • Save jpigla/6cb35af49003d905ed7679382e9d0b6c to your computer and use it in GitHub Desktop.
Save jpigla/6cb35af49003d905ed7679382e9d0b6c to your computer and use it in GitHub Desktop.
ZSH Functions (Shell)
# create requirements.txt from Jupyter Notebook file ($1 = name of file)
pipreqs_nb() {
if [ -z "$1" ]; then
echo "Select a notebook to convert"
else
{
jupyter nbconvert --output-dir="./reqs" --to script $1.ipynb
cd reqs
pipreqs --force --mode gt
cp requirements.txt ../requirements.txt
cd ..
rm -rf reqs
} &> /dev/null
echo "requirements.txt created"
fi
}
check-statuscode() {
if [ -z "$1" ]; then
echo "Select a notebook to convert"
else:
result="$(curl -I $1 2>/dev/null | head -n 1 | cut -d$' ' -f2)"
echo $result
fi
}
check-redirect() {
if [ -z "$1" ]; then
echo "Select a notebook to convert"
else:
result="$(curl -LIsm 10 -o /dev/null -w %{url_effective} $1)"
echo $result
fi
}
@jpigla
Copy link
Author

jpigla commented May 18, 2022

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment