Skip to content

Instantly share code, notes, and snippets.

View isurfer21's full-sized avatar

Abhishek Kumar isurfer21

View GitHub Profile
@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() {
@isurfer21
isurfer21 / handlebars-cli.js
Last active August 12, 2023 18:50
A CLI app which compiles the template with handlebars, renders it with the data, and prints the output html to the console.
// Import the required modules
const fs = require('fs');
const path = require('path');
const handlebars = require('handlebars');
// Get the template and data file names from the command line arguments
const templateFile = process.argv[2];
const dataFile = process.argv[3];
// Check if the files exist and are valid
@isurfer21
isurfer21 / zipnsync.ps1
Created July 29, 2023 14:26
A PowerShell based CLI app to zip each folder in the source directory and paste them to the target directory.
$help = $false
if ($args -contains "-h" -or $args -contains "--help") {
$help = $true
}
if ($help) {
write-host "Usage"
write-host " zipnsync [options] <source> <target>"
write-host ""
write-host "Arguments"
@isurfer21
isurfer21 / cli-args-parser.rs
Last active July 26, 2023 08:20
Minimalistic embeddable CLI argument parser in rust without any dependencies.
use std::collections::HashMap;
use regex::Regex;
// Define a function that returns a tuple of a hashmap of flags and values and an array of non-flag arguments
fn parse_args() -> (HashMap<String, String>, Vec<String>) {
// Create a hashmap to store the flags and values
let mut flags = HashMap::new();
// Create an array to store the non-flag arguments
let mut args = Vec::new();
// Create regular expressions to match different kinds of flags
@isurfer21
isurfer21 / SnakeToCamelCaseConverter.js
Created July 11, 2023 15:56
The snake_case to camelCase converter CLI app
// Import the file system module
const fs = require('fs');
// Import the process module
const process = require('process');
// Define a function to convert snake_case to camelCase
function snakeToCamel(str) {
// Split the string by underscore
let words = str.split('_');