Skip to content

Instantly share code, notes, and snippets.

View isurfer21's full-sized avatar

Abhishek Kumar isurfer21

View GitHub Profile
@isurfer21
isurfer21 / gen-uml.sh
Created April 17, 2024 14:10
Wrapper to generate UML from TypeScript files using TsUML2 (npm i -g tsuml2) to output an image file with the same filename as the input file.
#!/usr/bin/env bash
if [[ $# -gt 0 ]]
then
filename=$1
tsuml2 --glob $filename -m -o $filename.svg
else
echo "Error: arguments missing!"
echo "Syntax: uml <filename>"
fi
@isurfer21
isurfer21 / fit-in.js
Created March 1, 2024 16:32
A custom function in EcmaScript to insert the template literals (variables) in the given template string using tagged template. It is helpful in keeping all the templates separately.
function fitIn(template, ...values) {
// console.log(template, values);
let result = [];
for (let i = 0; i < template.length; i++) {
result.push(template[i]);
if (i < values.length) {
result.push(values[i]);
}
}
return result.join("");
@isurfer21
isurfer21 / md2htm.js
Last active March 6, 2024 06:26
The md2htm is a CLI utility that converts markdown to HTML using bun & pandoc
#!/usr/bin/env bun
import { parseArgs } from "node:util";
const VERSION = '1.0.0';
const { values, positionals } = parseArgs({
args: Bun.argv,
options: {
file: {
type: "string",
@isurfer21
isurfer21 / pdf2png.sh
Last active January 9, 2024 04:52
PDF to PNG converter CLI wrapper made using Imagemagick
#!/bin/bash
# This script takes two arguments: input filename and output filename
# It uses imagemagick to convert the input file to a png file with specified options
# Check if the number of arguments is correct
if [ $# -ne 2 ]; then
app_name=${0##*/}
echo "Syntax: $app_name <input> <output>"
echo "Usage: "
@isurfer21
isurfer21 / png2pdf.sh
Last active January 9, 2024 04:52
PNG to PDF converter CLI wrapper made using Imagemagick
#!/bin/bash
# This script takes two arguments: input filename and output filename
# It uses imagemagick to convert the input file to a pdf file with specified options
# Check if the number of arguments is correct
if [ $# -ne 2 ]; then
app_name=${0##*/}
echo "Syntax: $app_name <input> <output>"
echo "Usage: "
@isurfer21
isurfer21 / loconv.sh
Created November 26, 2023 09:05
Libre Office file convertor CLI for macOS
#!/bin/zsh
while getopts ":f:" opt; do
case ${opt} in
f )
file=$OPTARG
;;
\? )
echo "Invalid option: -$OPTARG" 1>&2
exit 1
@isurfer21
isurfer21 / md2html.sh
Last active January 9, 2024 04:49
Markdown 2 HTML converter CLI wrapper made using Pandoc
#!/bin/bash
# This script takes two arguments: input filename and output filename
# It uses pandoc to convert the input file to a html file with specified options
# Check if the number of arguments is correct
if [ $# -ne 2 ]; then
echo "Usage: ${0##*/} input.md output.html"
exit 1
fi
@isurfer21
isurfer21 / md2pdf.sh
Last active January 9, 2024 04:49
Markdown to PDF converter CLI wrapper made using Pandoc
#!/bin/zsh
# This script takes three arguments: input filename, output filename and optional font-face name
# It uses pandoc to convert the input file to a pdf file with specified options
# If no font-face name is provided, it defaults to 'Optima'
# Check if the number of arguments is correct
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "Usage: ${0##*/} input.md output.pdf [font-face]"
exit 1
@isurfer21
isurfer21 / remove-clip.sh
Created November 20, 2023 11:51
A CLI wrapper app to use ffmpeg to remove the clip from the given video file based on begin & end timestamp
#!/bin/bash
# Check the number of arguments
if [ $# -ne 4 ]; then
echo "Usage:"
echo " ${0##*/} <input> <output> <start> <end>"
echo "Arguments:"
echo " input the name of the input video file"
echo " output the name of the output video file"
echo " start the start time of the clip to be removed in hh:mm:ss format"
@isurfer21
isurfer21 / fix-nm-dts-av.sh
Created November 20, 2023 11:48
A CLI wrapper app to fix the Non-monotonous DTS in media file using ffmpeg
#!/bin/bash
# Check the number of arguments
if [ $# -ne 1 ]; then
echo "Error: No arguments provided"
exit 1
fi
display_help_menu() {