Skip to content

Instantly share code, notes, and snippets.

## SHUNT YARD ALGORITHM
class ShuntCalc:
def __init__(self):
## available operators
self.operators = {
'-': [self._process_minus, 1],
'+': [self._process_plus, 1],
'*': [self._process_times, 2],
'/': [self._process_divide, 2],
import subprocess
import random
from pathlib import Path
import cv2
import numpy as np
from PIL import Image , ImageDraw, ImageFont
import textwrap
from podcast_animator.analysis.animation_frame_constructor import AnimationFrame
# from .image_generator import generate_image
import cv2
import os
import sys
from pathlib import Path
from uuid import uuid4
from .image_generator import generate_image
import itertools
import time
FRAMES = 24
import cv2
import argparse
import os
# # Construct the argument parser and parse the arguments
# ap = argparse.ArgumentParser()
# ap.add_argument("-ext", "--extension", required=False, default='png', help="extension name. default is 'png'.")
# ap.add_argument("-o", "--output", required=False, default='output.mp4', help="output video file")
# args = vars(ap.parse_args())
"""
this function will combine audio and video files to file named Output_Video.MP4
in output folder created in the same directory you are running this function from
"""
### for more information for advance use check moviepy documentation ###
### https://zulko.github.io/moviepy/getting_started/getting_started.html ###
from moviepy.editor import *
import os
def combine_audio_video(audiofile,videofile,output_file_name_with_extension):
#We can import some python libraries before starting to merge videos.
from moviepy.editor import VideoFileClip, concatenate_videoclips
import time
start = time.time()
#we use VideoFileClip() class create two video object, then we will merge them.
video_1 = VideoFileClip("data/Video/VideoExample1.mp4")
video_2 = VideoFileClip("data/Video/VideoExample2.mp4")
@nwizugbesamson
nwizugbesamson / splitter.py
Created November 13, 2022 17:26
split video on timestamp using ffmpeg
import ffmpeg
import json
import time
# from ffmpeg import stream
""" split_wav `audio file` `time listing`
`audio file` is any file known by local FFmpeg
`time listing` is a file containing multiple lines of format:
`start time` `end time` output name
@nwizugbesamson
nwizugbesamson / retention.sql
Created August 25, 2022 19:50
Cohort retention table script
-- CREATE CUSTOMER ACTIVITY TABLE
DROP TABLE customer_details_table;
CREATE TEMPORARY TABLE customer_details_table
WITH cte AS (
SELECT
user_id,
transaction_date,
DATE_ADD(DATE_ADD(MAKEDATE(YEAR(transaction_date), 1), INTERVAL (MONTH(transaction_date))-1 MONTH), INTERVAL (1)-1 DAY) customer_cohort_date
-- ROW_NUMBER() OVER(PARTITION BY user_id, transaction_date ORDER BY transaction_date) as duplicate_flag
FROM retention.customer_record