Skip to content

Instantly share code, notes, and snippets.

View JupyterJones's full-sized avatar

Jack Northrup JupyterJones

View GitHub Profile
@JupyterJones
JupyterJones / merge_random_mp4.py
Created August 4, 2023 23:56
This script selects 30 random videos from the path entered in this case "~/Desktop/StoryMaker/VIDEOS" and merges a random .5 seconds from each video into one video.
import os
import random
import shutil
import uuid
from moviepy.editor import VideoFileClip, concatenate_videoclips
def get_random_video_clips(dir_path, num_clips=30, clip_duration=1, target_size=(512, 768), default_fps=30):
video_files = []
for root, dirs, files in os.walk(dir_path):
@JupyterJones
JupyterJones / quantize_to_palette.py
Created August 1, 2023 09:19
quantize images to a specific palette Python cv2
import cv2
import numpy as np
from moviepy.editor import VideoFileClip
from sklearn.cluster import KMeans
# Define your own color palette as an array of RGB values
palette = np.array([[255, 0, 0], # Red
[0, 255, 0], # Green
[0, 0, 255], # Blue
[255, 255, 0], # Yellow
[255, 0, 255], # Magenta
@JupyterJones
JupyterJones / TUBEvid.py
Created June 23, 2023 15:28
creates a video from shuffled video files in a directory
import random
import glob
import subprocess
from PIL import Image
from datetime import datetime
def tubevid(DIR):
image_files = glob.glob(DIR + "*.jpg")
random.shuffle(image_files)
# Determine the dimensions of the first image
@JupyterJones
JupyterJones / minterpolate.py
Created June 21, 2023 20:56
Run ffmpeg with Python
import subprocess
import os
from datetime import datetime
from random import randint
#DIR = "/home/jack/Desktop/HDD500/0WORKSHOP-with-NOTEBOOKS/shaman/"
DIR = "/home/jack/Desktop/HDD500/FLASK/static/milestones_resources/Lexica-anime/"
VIDEOS = "EXPERIMENT/XXXX1.mp4"
BORDER ="/home/jack/Desktop/HDD500/FLASK/static/assets/512x666Border.png"
current_datetime = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
filename = f"EXPERIMENT/_file_{current_datetime}.mp4"
@JupyterJones
JupyterJones / Convert-Webp-to-jpg.py
Created March 29, 2023 05:01
Convert Webp to jpg
from PIL import Image
import os
# Define the directory to use
directory = "testfiles/"
# Iterate over the files in the directory
for filename in os.listdir(directory):
filepath = os.path.join(directory, filename)
if filename.endswith(".webp"):
@JupyterJones
JupyterJones / THIS_IS_A_SHORT_VIDEO-Complete.ipynb
Last active March 2, 2023 22:08
Created during a Youtube Video
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JupyterJones
JupyterJones / Make_a_video_of_Your_Jupyter_Notebook.ipynb
Created February 22, 2023 01:09
Make_a_video_of_Your_Jupyter_Notebook.ipynb Created To accompany A YouTube Video
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@JupyterJones
JupyterJones / CreateGif.py
Created February 15, 2023 03:54
Use Pil to create a gif - This opens a forground image and paste it small and with transparency then slowly increases opacity and size
from PIL import Image, ImageSequence
def zoom_effect(bg_file, fg_file):
bg = Image.open(bg_file).convert('RGBA')
bg = bg.resize((640,640), Image.BICUBIC)
fg = Image.open(fg_file).convert('RGBA')
fg = fg.resize((bg.size), Image.BICUBIC)
fg_copy = fg.copy()
fg_copy = fg_copy.resize((int(fg_copy.width), int(fg_copy.height)))
result_images = []
@JupyterJones
JupyterJones / ReplacePasswords.py
Created February 15, 2023 03:44
replace a string in a jupyter notebook get rid of any passwords
import os
import re
search_dir = '/home/jack/Desktop/HDD500/notebooks' # Replace this with the directory where you want to search for Jupyter notebooks
search_string = 'password' # Replace this with the string you want to search for
replace_string = 'XXXnopassword' # Replace this with the string you want to replace the search string with
for file in os.listdir(search_dir):
if file.endswith('.ipynb'):
with open(os.path.join(search_dir, file), 'r', encoding='utf-8') as nb_file:
@JupyterJones
JupyterJones / findpass.py
Created February 15, 2023 03:41
search jupyter notebooks in a directory for passwords
import os
search_dir = '/home/jack/Desktop/HDD500/notebooks' # Replace this with the directory where you want to search for Jupyter notebooks
search_string = 'passwords' # Replace this with the string you want to search for
output_file = 'contains_passwords.txt' # Replace this with the output file name
with open(output_file, 'w') as f:
for file in os.listdir(search_dir):
if file.endswith('.ipynb'):
with open(os.path.join(search_dir, file), 'r', encoding='utf-8') as nb_file: