Skip to content

Instantly share code, notes, and snippets.

View markshust's full-sized avatar
🤓
Currently exploring building production apps with Claude Code & AI.

Mark Shust markshust

🤓
Currently exploring building production apps with Claude Code & AI.
View GitHub Profile
@markshust
markshust / Api\Data\PostSearchResultInterface.php
Last active June 19, 2022 16:54
Search result interface implementation
<?php declare(strict_types=1);
namespace Macademy\Blog\Api\Data;
use Macademy\Blog\Api\Data\PostInterface;
use Magento\Framework\Api\SearchResultsInterface;
/**
* Blog post search result interface.
* @api
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="other_settings">
<fieldset name="head">
<field name="head_includes">
<settings>
<disabled>true</disabled>
</settings>
</field>
</fieldset>
@markshust
markshust / ViewModel\FilteredAttribute.php
Last active July 8, 2022 18:09
Get specific attribute data for the current product with a ViewModel
<?php declare(strict_types=1);
namespace Macademy\ProductInfo\ViewModel;
use Magento\Catalog\Model\ProductRepository;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\View\Element\Block\ArgumentInterface;
class FilteredAttribute implements ArgumentInterface
@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
@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 / file1
Created October 12, 2022 15:43
Here is a my gist
content
@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 / 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.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 / 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)):