Skip to content

Instantly share code, notes, and snippets.

View Shubhayu-Das's full-sized avatar
🎄
What's next🤔

Shubhayu Das Shubhayu-Das

🎄
What's next🤔
View GitHub Profile
@Shubhayu-Das
Shubhayu-Das / remove_old_snaps
Created January 8, 2022 09:42
Script to remove files for older versions of installed packages
#!/bin/bash
# Removes old revisions of snaps
# CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read snapname revision; do
snap remove "$snapname" --revision="$revision"
done
@Shubhayu-Das
Shubhayu-Das / video_duration.sh
Created November 9, 2021 17:38
Shows the name and duration of all videos in a folder
#!/usr/bin/env bash
find . -maxdepth 1 -iname '*.mkv' | while read filename
do
# TODO: format output better
printf "$filename\t"
ffprobe -i "$filename" -show_entries format=duration -v quiet -of csv="p=0"
done
@Shubhayu-Das
Shubhayu-Das / gist:00eb50448900660522165f944f944a64
Created October 11, 2021 06:42
Excel/Libreoffice instruction to merge n rows into a single row
Drag this formula to all relevant cells, changing the $A$1 to $A$2, $3..., assuming data starts from column A
Change $25 to $n, where n is the number of rows we want to merge
=TRANSPOSE(OFFSET($A$1:$A$25,25*(ROWS($1:1)-1),0))
@Shubhayu-Das
Shubhayu-Das / watch_duration.sh
Created October 8, 2021 20:01
Script to find duration of all videos in a folder
find . -maxdepth 1 -iname '*.mp4' -exec ffprobe -v quiet -of csv=p=0 -show_entries format=duration {} \; | paste -sd+ -| bc | awk '{printf("%d:%02d:%02d:%02d\n",($1/60/60/24),($1/60/60%24),($1/60%60),($1%60))}'
@Shubhayu-Das
Shubhayu-Das / compress.sh
Created October 1, 2021 06:16
Script to run HEVC compression using FFmpeg
#!/usr/bin/env bash
name="$1"
# If there are subtitles, keep the part related to "s"
ffmpeg -i "$name" -c:v copy -map 0:v:0 -vcodec libx265 -crf 28 -map 0:a:0 -c:a copy -map 0:s:1 -c:s ass "temp.mkv"
echo "Initial size:"
du -h "$name"
@Shubhayu-Das
Shubhayu-Das / .vimrc
Created October 1, 2021 06:05
My vim configuration file
" Navigation related stuff
nnoremap <S-Left> :tabprevious<CR>
nnoremap <S-Right> :tabnext<CR>
inoremap <S-Left> <ESC>:tabprevious<CR>
inoremap <S-Right> <ESC>:tabnext<CR>
" Shortcuts to make opening and closing vim easier
:nmap <C-q> :q<CR>
:imap <C-q> <ESC>:wq<CR>