Skip to content

Instantly share code, notes, and snippets.

View Brainiarc7's full-sized avatar

Dennis E. Mungai Brainiarc7

View GitHub Profile
@Brainiarc7
Brainiarc7 / xargs-primer-brief.md
Last active December 23, 2023 01:26
Here is a brief primer on xargs, one of the most versatile tools used on the commandline on Linux.

xargs: A brief primer

If you’ve spent any amount of time at a Unix command line you’ve probably used xargs. In case you haven’t, xargs is a command used to execute commands based on arguments from standard input.

Common use cases:

These who use xargs often use it in combination with find in order to do something with the list of files returned by find.

On its' own, find is a very powerful command and it has built in flags such as -exec and -delete that you can often use instead of piping to xargs. With it's simplicity, xargs tends to find more usage than find on its' own.

@Brainiarc7
Brainiarc7 / wget-usage-intro.md
Last active December 12, 2023 11:17
wget usage manual from the notes

wget: Shortcuts to excellent downloads at your fingertips

Install wget first on your Linux distribution, then proceed to usage.

Download a Single File:

Let’s start with something simple. Copy the URL for a file you’d like to download in your browser.

Now head back to the Terminal and type wget followed by the pasted URL. The file will download, and you’ll see progress in real-time as it does.

@Brainiarc7
Brainiarc7 / ffmpeg-howto-localfiles-manipulation.md
Created July 25, 2016 13:43
This is a standard how-to for FFmpeg's usage with local files and streams. Small hand-book detailing common encode scenarios in a standard workflow.

Standard FFmpeg How-to

Table of Contents

* Generic Syntax

* Main Options

* Encoding :
@Brainiarc7
Brainiarc7 / nvenc-capabilities-ffmpeg.md
Last active October 10, 2023 23:26
See the supported NVENC and NPP capabilities in your FFmpeg build

Quickly check for supported NVENC and NPP hardware acceleration capabilities in FFmpeg on your platform:

Depending on how you built ffmpeg, you may want to check the supported NVENC-based hardware acceleration capabilities in ffmpeg by running:

$ for i in encoders decoders filters; do
    echo $i:; ffmpeg -hide_banner -${i} | egrep -i "npp|cuvid|nvenc|cuda|nvdec"
done

Sample output (as on my testbed):

@Brainiarc7
Brainiarc7 / One line to rebuild all DKMS modules on Ubuntu
Last active September 20, 2023 10:09
One line to rebuild all DKMS modules on Ubuntu
Here goes.
ls /usr/src/linux-headers-* -d | sed -e 's/.*linux-headers-//' | \
sort -V | tac | sudo xargs -n1 /usr/lib/dkms/dkms_autoinstaller start
Run as root.
@Brainiarc7
Brainiarc7 / h264_nvenc
Created July 22, 2019 18:41 — forked from nico-lab/h264_nvenc.txt
ffmpeg -h encoder=h264_nvenc
Encoder h264_nvenc [NVIDIA NVENC H.264 encoder]:
General capabilities: delay hardware
Threading capabilities: none
Supported pixel formats: yuv420p nv12 p010le yuv444p p016le yuv444p16le bgr0 rgb0 cuda d3d11
h264_nvenc AVOptions:
-preset <int> E..V..... Set the encoding preset (from 0 to 11) (default medium)
default E..V.....
slow E..V..... hq 2 passes
medium E..V..... hq 1 pass
fast E..V..... hp 1 pass
@Brainiarc7
Brainiarc7 / gnu-parallel-bioinformatics.md
Last active September 6, 2023 13:59
GNU Parallel usage in Bioinformatics with examples: A primer.
@Brainiarc7
Brainiarc7 / build-tensorflow-from-source.md
Last active July 29, 2023 21:28
Build Tensorflow from source, for better performance on Ubuntu.

Building Tensorflow from source on Ubuntu 16.04LTS for maximum performance:

TensorFlow is now distributed under an Apache v2 open source license on GitHub.

On Ubuntu 16.04LTS+:

Step 1. Install NVIDIA CUDA:

To use TensorFlow with NVIDIA GPUs, the first step is to install the CUDA Toolkit as shown:

@Brainiarc7
Brainiarc7 / xclip-copy-to-clipboard.md
Created April 26, 2017 17:53
Using xclip to copy terminal content to the clip board on Linux

Using xclip to copy terminal content to the clip board:

Say you want to pipe shell output to your clipboard on Linux. How would you do it? First, choose the clipboard destination, either the Mouse clip or the system clipboard.

For the mouse clipboard, pipe straight to xclip:

echo 123 | xclip

For the system clip board, pipe to xclip and select clip directly:

@Brainiarc7
Brainiarc7 / ffmpeg-multi-instances-xargs.md
Last active July 7, 2023 08:32
This gist will show you how to launch multiple ffmpeg instances with xargs, very useful for NVIDIA NVENC based encoding where standard GPUs limit the maximum simultaneous encode sessions to two.

Spawning multiple ffmpeg processes with xargs:

On standard NVIDIA GPUs (Not the Quadros and Tesla lines), NVENC encodes are limited to two simultaneous sessions. The sample below illustrates how to pass a list of AVI files to ffmpeg and encode them to HEVC on two encode sessions:

$ find Videos/ -type f -name \*.avi -print | sed 's/.avi$//' |\
  xargs -n 1 -I@ -P 2 ffmpeg -i "@.avi" -c:a aac -c:v hevc_nvenc "@.mp4"

This will find all files with the ending .avi in the directory Videos/ and transcode them into HEVC/H265+AAC files with the ending .mp4. The noteworthy part here is the -P 2 to xargs, which starts up to two processes in parallel.