Skip to content

Instantly share code, notes, and snippets.

View catichenor's full-sized avatar

Christopher Tichenor catichenor

View GitHub Profile
@catichenor
catichenor / waitfordl.sh
Created March 3, 2023 19:10
Wait for a download to complete and send it on its way
#!/bin/bash
DLFILE=/path/to/file.zip
while [ ! -f $DLFILE ];
do
echo "`date --rfc-3339=seconds`: Not here yet"
sleep 60
done
echo "`date --rfc-3339=seconds`: It's here! Moving..."
@catichenor
catichenor / stable_diff_keras_noconda.py
Last active October 1, 2022 19:54
Stable Diffusion Keras without Conda on Windows
# This was the only way I could get TensorFlow to recognize the CUDA DLLs without installing Conda.
# Adapted from https://keras.io/api/keras_cv/models/stable_diffusion/
# Set up paths as noted in https://www.youtube.com/watch?v=-Q6SM_usn84 (although ctypes is basically overriding this since the paths didn't seem get properly detected)
# ctypes workaround taken from https://stackoverflow.com/questions/57528027/importerror-could-not-find-cudart64-100-dll
# TensorFlow memory workaround taken from https://stackoverflow.com/questions/65493824/tensorflow-gpu-memory-allocation
# Needed to download zlib for Windows as posted on this page: http://www.winimage.com/zLibDll/zlib123dllx64.zip
import ctypes
cudart64dll = ctypes.WinDLL(r"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\bin\cudart64_110.dll")
@catichenor
catichenor / youtube_audio_playlist.sh
Last active November 12, 2023 18:33
Download a YouTube playlist but extract audio only from the movies in that playlist.
#!/usr/bin/env bash
# Download a YouTube playlist but extract audio only from the movies.
yt-dlp --extract-audio -ciw -o "%(title)s.%(ext)s" -v https://www.youtube.com/playlist?list=XXXXXXX_XXXXXX #Replace X's with the playlist characters
@catichenor
catichenor / many_requests_auth.py
Last active December 19, 2020 08:44
How to add authentication to a request in many_requests
#!/usr/bin/env python3
# How to do Basic authentication with the many_requests library, should work for Digest auth,
# or any other authentication method supported by the asks library.
# many_requests: https://github.com/joshlk/many_requests
# asks library authentication docs: https://asks.readthedocs.io/en/latest/overview-of-funcs-and-args.html#authing
from many_requests import ManyRequests
from asks import BasicAuth
@catichenor
catichenor / auto_resume_restart_download.sh
Created June 12, 2020 23:39
Download a file over HTTP, automatically resume the download if the exit status isn't zero, and restart the download when it stalls.
#!/usr/bin/env bash
# Taken from https://ilovesymposia.com/2013/04/11/automatically-resume-interrupted-downloads-in-osx-with-curl/ and https://ec.haxx.se/usingcurl/usingcurl-timeouts
export ec=18; while [ $ec -ne 0 ]; do /usr/bin/curl --speed-time 15 --speed-limit 1000 -O -C - "http://somedomain.com/path/to/some_huge_file.txt"; export ec=$?; done
@catichenor
catichenor / yagmail_no_auth.py
Created April 6, 2020 20:52
How to authenticate to yagmail on an SMTP server without authentication
# Couldn't find a reference on how to authenticate to an SMTP server that doesn't require authentication, but this worked.
# Based on the yagmail PyPi page: https://pypi.org/project/yagmail/
# and yagmail docs: https://yagmail.readthedocs.io/en/latest/api.html#smtp-client
import yagmail
user_email = "my_email@somedomain.com"
yag = yagmail.SMTP(user=user_email, host='smtp.somedomain.com', port=25, smtp_skip_login=True, smtp_ssl=False)
@catichenor
catichenor / is_port_open.py
Last active October 28, 2019 22:48 — forked from betrcode/README.md
Using Python to check if remote port is open and accessible.
import time
import socket
ip = "mylicenseserver.mydomain.com"
port = 27000
responses = []
for i in range(10):
try:
@catichenor
catichenor / text_to_qr.py
Created April 16, 2019 19:43
Generate a QR code from text in an input file (also adds the text itself).
#!/usr/bin/env python
import os
import argparse
from pathlib import Path
import qrcode
from PIL import Image, ImageDraw, ImageFont
@catichenor
catichenor / .bashrc
Created September 24, 2018 23:39
Git Bash .bashrc contents containing PATH variables for Anaconda3
export PATH="$PATH:/c/Users/ctichenor/AppData/Local/Continuum/anaconda3:/c/Users/ctichenor/AppData/Local/Continuum/anaconda3/Scripts"
alias python="winpty python"
@catichenor
catichenor / md2xl.sh
Last active September 24, 2018 17:29
Convert a series of Markdown table files to HTML/Excel tables using pandoc
#!/usr/bin/env bash
find . -maxdepth 1 -type f -name '*.md' | xargs -I {} basename "{}" .md | xargs -I {} pandoc -f markdown_mmd -t html {}.md -o {}.xls