Skip to content

Instantly share code, notes, and snippets.

View markshust's full-sized avatar
🤓
Working on educational & training material for Magento 2

Mark Shust markshust

🤓
Working on educational & training material for Magento 2
View GitHub Profile
<template>
<div>
<input
type="text"
placeholder="Search Your Interest"
@input="debounceSearch()"
v-model="searchInput"
/>
</div>
</template>
@markshust
markshust / gpt4_text_compression.md
Created August 2, 2023 17:12 — forked from jimsrc/gpt4_text_compression.md
Minimizing the number of tokens usage to interact with GPT-4.

Overview

I just read this trick for text compression, in order to save tokens in subbsequent interactions during a long conversation, or in a subsequent long text to summarize.

SHORT VERSION:

It's useful to give a mapping between common words (or phrases) in a given long text that one intends to pass later. Then pass that long text to gpt-4 but encoded with such mapping. The idea is that the encoded version contains less tokens than the original text. There are several algorithms to identify frequent words or phrases inside a given text, such as NER, TF-IDF, part-of-speech (POS) tagging, etc.

@markshust
markshust / spanish.sh
Created March 20, 2023 23:51
Bash script to translate SRT files in the current directory into another language using Google Translate
#!/bin/bash
languageName='Spanish'
language='es'
for file in *.srt; do
if [[ $file == *.$language.srt ]]; then
# Skip processing of already translated files
continue
fi
@markshust
markshust / captions.py
Last active December 17, 2023 09:49
Python script to use Whisper to create srt's for all mp4's that don't currently have one in the current directory.
import os
import whisper
from whisper.utils import get_writer
# Get the current directory path
directory = os.getcwd()
# Loop through all the files in the directory
for file in sorted(os.listdir(directory)):
@markshust
markshust / translate.sh
Created March 20, 2023 20:30
Translate SRT file into another language using Google Translate
#!/bin/bash
# Requires translate-shell to be installed.
# Get it on GitHub at: https://github.com/soimort/translate-shell
# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--file|-f ) file="$2"; shift ;;
--language|-l ) language="$2"; shift ;;
@markshust
markshust / convertSrtIntoSingleLineCaptions.py
Last active March 9, 2023 17:08
Convert SRT files with multi-line captions into single lines
import os
import textwrap
input_dir = 'input1/'
output_dir = 'output1/'
for filename in sorted(os.listdir(input_dir)):
if filename.endswith('.srt'):
with open(input_dir + filename, 'r') as input_file:
output_filename = output_dir + filename
@markshust
markshust / translate.py
Last active March 8, 2023 22:14
Python script to use Whisper to transcribe audio/video
import os
import whisper
from whisper.utils import get_writer
input_dir = 'input/'
output_dir = 'output/'
for filename in sorted(os.listdir(input_dir)):
if filename.endswith('.mp4'):
input_file = input_dir + filename
@markshust
markshust / file1
Created October 12, 2022 15:43
Here is a my gist
content
@markshust
markshust / genhtml.sh
Last active July 16, 2022 15:11
Generate HTML/markup from folder full of course videos
#!/bin/bash
course="php-101"
totalcount=0
for i in *.mp4; do
[[ $i == *"- clean"* ]] && continue
totalcount=$((totalcount+1))
done;
@markshust
markshust / genthumbs.sh
Created July 16, 2022 05:39
Generate video thumbnails at 15 sec timestamp from directory of MP4 files
#!/bin/bash
for i in *.mp4; do
[[ $i == *"- clean"* ]] && continue # this line excludes files that contain "- clean" in filename
prefix=`echo "$i" | sed "s/^\([0-9]*\)\.\(.*\)/\1/"`;
ffmpeg -i "$i" -ss 00:00:15.00 -vf "thumbnail,scale=480:270" -frames:v 1 "$prefix.webp"
done