Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rsnk96
rsnk96 / bash_text_formatting.sh
Last active July 28, 2023 04:57
Helper functions for any bash script for colour formatting and day-to-day usage
# Load various colour hacks for the terminal
load_colours()
{
# From https://stackoverflow.com/a/28938235
# Reset
NC='\033[0m' # Text Reset
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
@rsnk96
rsnk96 / windows_setup.bat
Last active December 6, 2018 10:27
A chocolatey script to set up programs on windows
choco install chocolatey chocolatey-core.extension -y
choco install googlechrome firefox office365proplus -y
choco install adobereader 7zip vlc ccleaner teracopy bulk-crap-uninstaller -y
:: Optional
choco install aria2 google-backup-and-sync skype dropbox -y
choco install greenshot f.lux -y
choco install bitwarden keepass -y
:: Optional – 2
@rsnk96
rsnk96 / RTK_ITK_build_script.sh
Created November 8, 2018 19:05
Script to build RTK and ITK on Ubuntu with Python Wrappers
#!/bin/bash
sudo apt-get install git cmake build-essential bison -y
sudo apt-get install gcc-4.8 g++-4.8 -y # For nvcc
mkdir ITK_RTK
# Install ITK
git clone git://itk.org/ITK.git
cd ITK && git checkout v4.13.0 && cd ../
mkdir -p ITK-bin && cd ITK-bin
@rsnk96
rsnk96 / merge_video_fragments.py
Created October 21, 2018 17:08
Merging indexed video fragments
import subprocess as sp
with open("temp_files.txt", "w") as f:
for t in ["output_{}.avi".format(i) for i in range(num_processes)]:
f.write("file {} \n".format(t))
ffmpeg_command = "ffmpeg -f concat -safe 0 -i temp_files.txt -vcodec copy"
sp.Popen(ffmpeg_command, shell=True).wait()
@rsnk96
rsnk96 / multiprocessing_cv.py
Last active September 9, 2020 08:36
Outline of a parallelized video processing code
def process_video(group_number):
cap = cv2.VideoCapture("input_file.mp4")
cap.set(cv2.CAP_PROP_POS_FRAMES, frame_jump * group_number)
proc_frames = 0
out = cv2.VideoWriter("output_{}.avi".format(group_number), ...)
while proc_frames < frame_jump:
ret, frame = cap.read()
# ... DO SOME STUFF TO frame ... #
proc_frames += 1
out.write(frame)
@rsnk96
rsnk96 / normal_cv.py
Last active October 21, 2018 17:47
Outline of a normal video processing code
def process_video():
cap = cv2.VideoCapture("input_file.mp4") # Define the input video handler
out = cv2.VideoWriter("output_file.avi", ...) # Define the output video handler
while (cap.isOpened()): # Loop through the video frames
ret, frame = cap.read() # Read a frame
# ... DO SOME STUFF TO frame... # # Perform some operation
out.write(frame) # Define the input video handler
process_video() # Call the actual function
@rsnk96
rsnk96 / build-zsh.sh
Last active July 19, 2018 12:16 — forked from nicoulaj/build-zsh.sh
Build Zsh from sources on Ubuntu
#!/bin/bash
# Build Zsh from sources on Ubuntu.
# From http://zsh.sourceforge.net/Arc/git.html and sources INSTALL file.
execute () {
echo "$ $*"
OUTPUT=$($@ 2>&1)
if [ $? -ne 0 ]; then
echo "$OUTPUT"
echo ""